Folder auto complete

Recently @Trinkes really nicely described a feature I wished we had for a long time, so I took the liberty to implement it. I want to create a discussion here, to make it more accessible, programmers tend to have weird opinions on UX.

The way I see it is that it takes the highlighted page and fills the search term in following ways:

  • Directory/Page to Directory/
  • Deep/Dir/Page to Deep/Dir/
  • Page to Page/

Let me know what you think :smile:

(I may or may not have consumed caffeine at an utterly irresponsible hour)

1 Like

This sounds cool. Just updated my instance to edge to try it out.

That is pretty nice! But conversely I think it is also a possible solution (or more often used when I was using obsidian) is add command for moving an existing file to a folder (and allow folder completion here as well).

@Maarrk is there any particular reason to choose shift + space over tab for the autocomplete? is shift + space used for autocomplete in other contexts?

Another suggestion is to put the cursor at the end of the edit text after the auto complete. I also notice this behaviour when creating a new page and its name must be confirmed.

I didnā€™t use Tab, because besides auto-completion it is used to change focus between inputs. This is an accessibility feature, and I donā€™t have enough knowledge on the topic, nor someone to consult with, to risk breaking anything about it. There are already multiple requests for improving accessibility #294, #295, #938, that have had no progress for some time.

Regarding the choice of Shift+Tab: the previous shortcuts were Enter for ā€œconfirmā€, Shift+Enter for ā€œthe other confirmā€, Space for ā€œcomplete folderā€, so it seemed consistent to add Shift+Space for ā€œthe other complete folderā€.

Also, some code editors use Ctrl+Space to open the autocomplete hint list, this seemed not far off. The only context where I found Shift+Space being used was to scroll the page up in web browsers (opposite of Space), but I decided that with the picker open it wouldnā€™t collide in any way.

It is on the end for me after I press the shortcut, I canā€™t reproduce it. However I noticed that when using the up and down arrow to move around the list of suggestions the cursor jumps to beginning and end, respectively. Could this be what you are referring to?

I see that it is related from the UX perspective, but for implementation this would be two different features:

  • auto complete folder names in Page Namer
  • auto complete folder names in Page: Batch Rename Prefix command (and maybe other prompts expecting a page name)

The complication here is that both of these places currently donā€™t have any list of options to select from (like Editor and Page Picker), so this would be a much bigger effort than just adding a shortcut. Iā€™m not complaining, just explaining the reasoning why the feature seems ā€œhalf-doneā€ now


I noticed that I donā€™t have a way to do Shift+Space (or Tab) on the mobile, thinking about handling long press on an option the same way, just need to understand if that can be done reasonably easily.

2 Likes

Thank you for your detailed answer. That makes perfect sense!

Youā€™re right, I didnā€™t realize that was the issue :+1:

I think itā€™d make more sense to start out with the current folder, so if nothing has been typed yet, shift+space would fill in the current folder and not what is highlighted.

Of course after typing or selecting (arrow keys or mouse) it should very much move to get the folder for the highlighted page.

This is precisely what Space does, we already had this function even before I contributed my change. Quoting Page Picker:

  • Space: with an empty filter phrase will attempt to do something intelligent:
    • If the currently opened page is nested in a [[Folders|folder]], it will auto complete the current folder name in its place.

aargh all this time!

Well, thanks! Moved to edge to try out your changes and I do love it.

1 Like

Is there any shortcut to add to the picker the current page full path? thatā€™s useful when you want to create ā€œsubpagesā€

I donā€™t think thereā€™s a shortcut for it, but now I think it would make sense to just do it on second press of the auto complete key. And even if you press it twice by accident, you can Ctrl+Backspace by whole words to remove it.

But for now, since you want to create a page this way, you donā€™t need to add it to the picker itself, which allows an entirely different way of getting that:

```space-script
silverbullet.registerCommand({name: "Page: Create Subpage"}, async () => {
  const current = await syscall("editor.getCurrentPage");
  const name = await syscall("editor.prompt", "Enter name of new page", current + "/");
  if (!name) {
    return;
  }
  await syscall("editor.navigate", name);
});
```

The problem is that sometimes the cursor is placed at the start of the prompt, but if you press down arrow, it moves to the end.

2 Likes