Backquote auto-close behavior: doesn't skip over closing quote, unlike parens/brackets/braces
What happened?
Logseq auto-closes parens, brackets and braces, which is nice. Typing the left one auto-adds the right one, leaves the cursor between them. Then later when the user types the right one, it skips over it if it's already at the cursor. Backquotes (for code) are almost the same, except for one annoying difference: when the user types the closing (second) one, logseq always adds another pair even if the "closing" backquote is already at the cursor location. This means the user has to remember to move the cursor right rather than typing the closing backquote.
I recommend skipping over the backquote the same way it skips over closing parens, brackets, and braces.
Reproduce the Bug
In a fresh block, type { and then }. Notice it creates a matched pair of braces with the cursor at the end. This is the desired/expected behavior.
In a fresh block, type backquote "`" then another backquote. Notice that it creates four backquotes, with the cursor in the middle of them. This is unlikely to be what the user intends.
Expected Behavior
Backquotes should behave like parens, brackets, and braces. I know it's slightly different because the close char is the same as the open char in that one case, but hopefully the implementation can account for that.
Screenshots
No response
Desktop Platform Information
Win 11, desktop app, 0.6.2
Mobile Platform Information
No response
Additional Context
No response
I'm no expert, but I wonder if this code is responsible for the difference? It seems to deliberately exclude backquote from the auto-close behavior:
https://github.com/logseq/logseq/blob/d8bc074be17d3e4c1b780f9ce08e15f2f45193a6/src/main/frontend/handler/editor.cljs#L2877-L2884
One thought: maybe this is like this to make it easier to type the triple-backquote syntax for multiline code blocks? If so, the logic could just get slightly smarter: only create a new autopair for backquote if previous two chars are not both backquote. So typing one gets you two (`|`), typing two keeps two (` `|), then typing the third with no intervening chars leaves you with three and cursor at the end (```|).
Confirming this behavior still exists. Any idea if there is an acknowledgement of whether or not it is a bug or intended behavior?
I think someone should be looking into this issue, because I'm using quote a lot, but this behavior really annoy me in which I have to move my hand to shift one character before I can continue typing (Which disrupting my workflow a lot0)
Duplicate of #4380
@garyo I believe I've fixed this issue in #6496. I don't know how the Logseq release process works but hopefully this fix will go out soon.
It's in the latest nightly, and working great for me! Thank you!