A Logseq plugin (v0.10.14+) that restores the tag autocomplete dropdown when returning the cursor to an existing hashtag.
In Logseq, the tag autocomplete menu only appears during the initial typing of the # symbol. If you move the cursor elsewhere (to another line or outside the hashtag) and then return it to the end of an existing #tag to continue typing, the text is edited as plain text—the autocomplete menu does not reappear.
The plugin listens for keystrokes in the block editor. If the cursor is at the end of an existing hashtag and the user types a printable character:
- The standard character insertion is canceled (
preventDefault). - Step 1: The entire
#tagis replaced with a single#viadocument.execCommand('insertText', ...). This forces Logseq's internalhandle-last-inputto recognize the#as the last entered character and open the dropdown. - Polling Wait: The plugin waits for a short period (typically 20-40ms) until it detects that the autocomplete popup has physically appeared in the DOM.
- Step 2: Once the popup is detected, the plugin inserts the full tag tail (the original text plus the newly typed character) in a single
execCommandcall. The menu stays open, and its filter updates reactively.
This approach ensures that the undo history only gains 2 steps instead of one step per character, and the search popup correctly anchors to the hashtag.
- Open Logseq.
- Go to
Settings→Advancedand enableDeveloper mode. - In the top bar, click the plugin icon (puzzle piece) →
Plugins. - Click
Load unpacked pluginand select this project directory. - Ensure the plugin is enabled in the list.
No configuration is required. Once activated, the plugin works automatically:
- Type
#tag— autocomplete opens as usual. - Click elsewhere in the document.
- Click back to the end of
#tagand type any character — the autocomplete menu reappears.
- The cursor must be at the end of the hashtag. Inserting characters into the middle of a hashtag will trigger the menu, but trailing text will not be part of the filter (native Logseq limitation).
- IME (Chinese, Japanese, etc.) is not supported—the plugin listens only for
keydownwith single-characterevent.key. - Pasting from the clipboard inside a tag does not trigger the menu.
- Each trigger creates 2 steps in the undo history (
Ctrl+Z). - The plugin works only in the standard block editor (
textarea.normal-block). It does not target code blocks or other special editors.
The index.js file registers a single keydown listener on top.document during the capture phase. It uses a polling mechanism to synchronize with Logseq's asynchronous React rendering, ensuring the autocomplete state is fully initialized before restoring the tag content.
MIT