-
Notifications
You must be signed in to change notification settings - Fork 649
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Error linking file in subdirectory #806
Comments
The problem is here: static computeRelativeURI(reference: URI, relativeSlug: string): URI {
// if no extension is provided, use the same extension as the source file
const slug =
posix.extname(relativeSlug) !== ''
? relativeSlug
: `${relativeSlug}${posix.extname(reference.path)}`;
return URI.create({
...reference,
path: posix.join(posix.dirname(reference.path), slug),
});
} In |
I will need some guidance regarding the expected behavior here:
b makes no sense to me. I would like to interpret it as in c and reserve paths starting with The current implementation is compatible with c except for the error message. |
This is the way it's done for Cmd-click: const basedir =
vscode.workspace.workspaceFolders.length > 0
? vscode.workspace.workspaceFolders[0].uri
: vscode.window.activeTextEditor?.document.uri
? URI.getDir(vscode.window.activeTextEditor!.document.uri)
: undefined;
....
URI.createResourceUriFromPlaceholder(basedir, uri) So here the wikilink is taken to hang from the root of the workspace as in (a) instead of (c) above. Hence this results in an error message. |
Hi @memeplex, I have been doing some thinking around it and spoke to other project leads in the space. Here is where my head is at:
Thoughts? |
@riccardoferretti your definitions make sense to me. Regarding the points yet to define:
Given that the meaning could change without the user being aware of it the only safe course of action I see here is to report an error, maybe facilitating the task of entering an unambiguous link, for example: filename is ambiguous, please change it to ./filename, d/filename, ..., not now.
I think /path/to/filename should be file:https:///path/to/filename, because it actually is what's in the url without the protocol part. Also, writing the full URL is cumbersome and it's nice to have a shortcut when the protocol is obvious. |
I see your point, the counter-argument is that, within Foam (which e.g. could be living in a cloud) an absolute path refers to the absolute path of the repo. But I do like
The idea here would be to monitor files and fix things accordingly, using the same principle used to monitor renamed files (see #809) . That means that:
What you say about the error could be surfaced via the diagnostic API, and even provide quick fixes:
Yup, that's a separate task (pretty straightforward in reality once the other pieces are in place) but yeah, not now |
Guys can you help me check if it bug. I have subfolder and on this subfolder in current document I am trying to insert link via Cmd+Click it creates two files. In this subfolder and in root folder and links to root. |
Do you also have markdown-notes installed? |
Yes |
That's likely the cause, try disabling it, but if the problem is still present let's create a new issue |
If to disable markdown-notes - really only one file created but on the root folder not In subfolder. |
hi @memeplex a couple of things related to this issue/
|
This is the current behavior. |
@riccardoferretti sorry for the delay.
It will take some time because I'm currently very busy, so you'll have to be patient. The issue is with dirname, yes, that was my conclusion here too. I've some questions about your new proposal. Do you want to disallow non-unique identifiers? If you want, how would you enforce uniqueness given that a file may be externally created at any moment? If not, what's the point in differentiating them from their unique counterparts? And how do you plan to resolve ambiguities? Maybe it's worth taking a look at how Obsidian manages this. Besides inspiration, intercompatibility with Obsidian seems desirable per se. |
I think I prefer to interpret everything as paths, so |
I've been testing what Obsidian does. While links are unique it allows to specify just the node name. Once you introduce an ambiguity by creating a new "capturing" node, it automatically updates all references so as to make them unique (it prepends the path relative to the vault root to each ambiguous link). But if you create the node from outside, Obsidian does nothing at all to prevent the capture. OTOH everything with a Some thoughts, 1c each:
I think the best move is the first proposal: Obsidian compatible, backwards compatible and it's easier to convey that unqualified names may become ambiguous when referring to other directories, but that this is the one and only case. |
Thanks for the comments @memeplex Here are my thoughts:
We can't disallow them, but we can flag them. We need the following contract with the user:
If a file is added/renamed in Foam and it breaks existing identifiers, like Obsidian we would automatically update the references. Also, with regards to the syntax, given my example above:
Which means that Foam's identifiers are a super set of Obsidian (in my proposal): all Obsidian links are supported by Foam, but Foam multi-part identifier (scenario 6) is only supported by Foam. We could make that configurable. |
Ok, if you assume uniqueness you're right it's a superset, my remark was because your proposal might change the order of resolution vis-a-vis Obsidian in the face of ambiguity. If you have a strong commitment to enforce or at least promote uniqueness I believe it's fine, but to import from another tool you still have to resolve the ambiguity some way or another. That said, I have doubts regarding the value of path prefixes as mere disambiguators, I think they may be confusing, it's natural to interpret a path like
I don't see a great trade off there, you can omit d3 but at the cost of lack of clarity and some degree of lock-in (because this kind of smartness won't likely be part of other tools). I'd prefer |
I retract this statement, at least to some extent. Thinking about more concrete examples I realize there is much more information in the name than a mere position in the tree and often going just one level above the node will be enough (languages/eiffel instead of computer/languages/python to distinguish it from architecture/towers/eiffel) and you always have the choice to keep adding levels up to the root on a semantic basis, that is if they help make things clearer to you. I still think this option entails some degree of lock-in though, as any sophisticated choice will do in this matter. |
This is the way I think about it, maybe I should have made a more tangible example to highlight the benefits (might steal yours when the time comes ;) ) I agree with your point about interoperability because it is a Foam format here. |
Impressive! Thank you @riccardoferretti |
@riccardoferretti have you added a setting like this? Is it possible to use full paths in order to ensure intercompatibility? |
Mmmm I've been playing with a Foam generated tree inside Obsidian and the short identifiers that you proposed seem to be supported after all. They're not the ones that Obsidian inserts but it seemingly can follow them anyway. |
That's good news. |
Summary
Steps to reproduce
[[d/b]]
to a.mdScreen.Recording.2021-10-29.at.06.22.49.mov
The text was updated successfully, but these errors were encountered: