Closed linduxed closed 1 month ago
Hey @linduxed, I like the idea of only giving header/anchor link completion when the current prompt ends with #
or ^
. That seems perfectly reasonable to me and I think would regain the previous performance. I didn't know about Obsidian's [[##
/ [[^^
global search prompt, but that seems like a good feature to add here as well.
I like the idea of only giving header/anchor link completion when the current prompt ends with # or ^.
@linduxed I just opened a PR for this. Can you test this out?
Hello @epwalsh! Thank you for the very quick response and code!
I checked out the PR locally and tested. Observations:
[[
only searches for note names.[[
does not show aliases in the completion. Not sure if this is expected or not.[[#
does not seem to give any results.
b. Writing [[##
seems to give a short list of inaccurate results: I have a Purchases.md
note with a ## Books
heading, and this heading does not get found, while 3 other results that are totally unrelated get returned. The same 3 results seem to be returned for some other queries, so the text after [[##
does not seem to matter. For a brief moment, however, there seems to be a flash of a long list of completion results that cover the screen, and maybe those results are good, but the flash is too quickly gone to tell.Oh, wait, my bad:
when the current prompt ends with # or ^.
I misunderstood. That seems to work. In that case, I guess my only relevant observation is the part about aliases not being shown.
Further observations upon closer inspection:
Purchases.md
with a header called ## Books
, and a note called Purchase of apartment.md
that does not have a header containing the word "books". Nonetheless, Purchase of apartment#books
is one of the completions for [[purchase#books
.[[
, but they get listed in the completion as actual notes, and get inserted as actual note titles. Example: let's presume I have a note called Books.md
with the alias To read
. To read
will be listed as a completion, and if one selects that, at least what one would expect that what would be inserted as text in the document would be [[Books|To read]]
, but instead [[To read]]
is inserted.Question: how is one to reference headers in the same document with this PR, excluding writing out the name of the current note and then the header (i.e. in a note called Foo.md
, writing [[Foo#
?
Would you want me to move some of the content in my previous messages to the PR thread, to have it all in context there?
🚀 The feature, motivation and pitch
Since
v3.7.0
, the addition of support for anchor and block search has resulted in the default behavior of the completion to change.Previously typing
[[
would (after a configurable amount of characters) initiate search among the note names and their aliases, much like how Obsidian works. The recent addition of the support for anchors and blocks changes two things:[[
for initiating a completion different than note names and aliases ([[#
for headings in the current note,[[##
in all notes;[[^
for blocks in this note, and[[^^
in all notes).While having the ability to get completion for anchors and blocks is useful, to both be more in line with the working of Obsidian, and to avoid the performance penalty of always completing for everything (notes, aliases, anchors, and blocks), would it be a good idea to introduce a similar kind of prefix detection (i.e. looking for something like
[[#
) to the completion triggering?Alternatives
An alternative would be making it possible to disable the anchor and block completion, to go back to the previous way things worked. The README made me think that this should be possible by changing the
wiki_link_func
config opt, but (unless I've missed something) this does not seem to do the trick.Additional context
No response