Skip to content

Add Tab completion and group-name search for slash commands#12592

Open
PlunderStruck wants to merge 6 commits into
logseq:masterfrom
PlunderStruck:dev/slash-command-tab-complete
Open

Add Tab completion and group-name search for slash commands#12592
PlunderStruck wants to merge 6 commits into
logseq:masterfrom
PlunderStruck:dev/slash-command-tab-complete

Conversation

@PlunderStruck
Copy link
Copy Markdown
Contributor

Summary

This PR improves slash command autocomplete in the editor:

  • Allows pressing Tab to complete the currently highlighted slash command.
  • Allows slash commands to be searched by their group label, e.g. task status / priority groups.
  • Keeps group headers visible in filtered slash command results so group-name searches still preserve context.

Why

Slash command results already support keyboard navigation, but completing a highlighted result required Enter or a mouse click. This makes Tab work as a completion key for the slash command picker, which matches the behavior users often expect from command/autocomplete surfaces.

The group-name matching also makes it easier to discover related commands as a set. For example, typing a task-status group query can surface the status commands together instead of requiring the user to remember each individual command label.

Implementation Notes

The Tab behavior is implemented as an opt-in autocomplete behavior via :complete-on-tab?, enabled only for the slash command autocomplete.

I chose this instead of changing the global shortcut config because binding Tab through :auto-complete/complete was not reliable in the running editor. The editor's own Tab indentation handler intentionally does nothing while an editor action is active, so if the autocomplete shortcut handler misses the key, pressing Tab appears to do nothing. Keeping the behavior inside ui/auto-complete makes the handling local to the mounted autocomplete surface while still reusing the existing frontend.handler.ui/auto-complete-complete selection path.

Group-name matching reuses the existing slash command fuzzy search pipeline by adding group-label extractors alongside the existing localized, English, and pinyin command-name extractors.

Tests

Focused tests:

  • bb dev:test -v frontend.commands-test
  • bb dev:test -v frontend.ui-test

Full validation:

  • bb dev:lint-and-test

Result:

  • 1295 tests
  • 6315 assertions
  • 0 failures
  • 0 errors

Manual verification:

  • Verified in the dev Electron app that typing /tod displayed the TASK STATUS group and pressing Tab completed the highlighted Todo command.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant