Create link to non-existing note auto-suggest mismatch bug

Steps to reproduce

In live preview mode, and with the options to automatically created the paired characters (so that typing [[ will automatically insert ]] after the cursor, when typing in a new link to a non-existent file, sometimes the suggestion box comes up with files that don’t match the filename being typed. The filename in the suggestion is a partial match but not a full match, so the suggestion shouldn’t still be there. E.g., I have an existing file named 1-23-23 Daily Tasks and I type in a new link for a file named 3-23-23 Daily Tasks for a file that doesn’t exist yet, and the suggestion box shows the 1-23-23 Daily Tasks file despite it not matching the filename I’ve entered. See screenshot below:

Expected result

When I finish typing the filename, e.g., [[3-23-23 Daily Tasks for the link and press enter, it should complete the link tag with the non-existent filename I typed, allowing me to click-to-create that file and open it to be edited.

Actual result

When I finish typing the filename for the link and press enter (prior to entering the ]] to close the tag manually), it “corrects” the filename to the mismatched suggestion instead, thus inserting the incorrect link to a file that already exists but isn’t intended to be linked.

In the past, this worked as expected, but for at least a month or two, possibly a little longer, this has been happening to me instead. Based on the highlighted characters from my screenshot above, it may be something in the matching logic taking the 3- and using it to match the 3 in the folder name, and then the remainder of the filename 23-23 Daily Tasks to match the already existing 1-23-23 Daily Tasks file which is not intended or expected.

Environment

  • Operating system:

Windows 10

  • Debug info:

SYSTEM INFO:
Obsidian version: v1.1.16
Installer version: v1.1.16
Operating system: Windows 10 Enterprise 10.0.19044
Login status: not logged in
Insider build toggle: off
Live preview: on
Legacy editor: off
Base theme: light
Community theme: none
Snippets enabled: 0
Restricted mode: on

RECOMMENDATIONS:
In the example from the attached screenshot, the expected behavior would be to match no file since the complete filename doesn’t match a file that already exists, so the auto-suggestions should be blank so that pressing enter with the cursor inside the tag will just exit the tag, leaving the link as it was typed originally, so that the non-existent file can be created and opened/edited by clicking.

Or, alternatively, the default selection in the auto-suggestion box should be to enter the filename as typed, with the other partial matches still offered for selection below, so that simply pressing enter doesn’t alter what was typed. That way, if I did intend to link to one of the existing files, I can still do that by selecting it with the mouse or arrow keys and hitting enter to correct the link to the suggested file.


Additional information

I don’t remember unmodified enter opening links. At least not for a long time, many versions ago. I’m pretty sure you need to use alt-enter.

In this case, when you hit enter, your focus is on the auto-suggestion. If you use alt-enter, it should immediately create and go to the new link, as typed. That works for me. Or you can hit escape first to dismiss the suggestion, but then you still have to hit alt-enter to follow the link.

There are associated commands, so you can remap that hotkey too. “Open link under cursor …” with various options.

Alternatively, in this case, it looks like you have a naming convention for your tasks. You could consider using Daily Notes and/or Unique Note Creator. They can automatically create those notes for you, so you don’t have to manually type them. There are also community plugins that can help type natural dates, or use a calendar widget, and format them into your date format of choice.


I agree with your suggestion that your manually typed link should also show up in the list of suggestions, so you can select that too, without having to completely dismiss the auto suggestions.

There are multiple things here. First, enter and tab have always autocompleted with what is current selected. You need to manually type ]].

Second the suggestion is based on the pathname, so the suggestion you see is correct.

I understand the proposal about including what you type in the suggestion box, but I am not sure how that should be ranked or if that’s better than what we currently have.

I don’t remember if there is a FR related to this problem. Anyway, in v1.3.5 if you press shift-enter it will just take what you wrote and put the cursor after ]]