joeyuping / quick_latex_obsidian

MIT License
327 stars 21 forks source link

Interactions between autocompletes and undo/redo are inconsistent #109

Open skritch opened 11 months ago

skritch commented 11 months ago

This is pretty nitty, but it's annoying when it comes up:

When the plugin autocompletes, and then the user hits undo (ctrl-z), it can either:

  1. Remove the character the user typed and the autocompleted result
    • This is the behavior of Obsidian core for autocompletes like __.
    • This is the current behavior of the plugin for "Greek symbols math mode" autocompletes, for [] etc, and for $ -> $$ autocomplete if "move cursor between $$ symbols" is disabled.
  2. Remove just the autocompleted result, but with the cursor in a different place than before the autocomplete
    • This is the current behavior of the plugin for $ -> $$ autocomplete if "move cursor between $$ symbols" is enabled. I don't think it's intentional; it's a weird interaction: you type $, autocompletes to $$, then if you ctrl-z you end up with one $ but the cursor is to the left of it.
      1. Restore the state to after the user typed but before the autocomplete result was applied.
    • This is the behavior of e.g. google docs spellchecker
    • Also—I think—Copilot, though Copilot has an extra Tab keystroke to accept results so it makes more sense there.

Case (2) is definitely undesirable, and is related to https://github.com/joeyuping/quick_latex_obsidian/issues/107 . When I started writing this I thought it was a broken version of (3) but it's clearly just a weird interaction.

I personally like (3) the most—would make the plugin feel very slick—but I'll grant that (1) is most consistent with the rest of Obsidian and closest to how things are implemented now.