obsidian-latex-suite icon indicating copy to clipboard operation
obsidian-latex-suite copied to clipboard

Snippet does not work as intended when source mode is disabled [BUG]

Open ValentinRonsseray opened this issue 4 months ago • 1 comments

Description

Hi. Here is the problematic snippet (for Markdown format, not related to LaTeX syntax) :

{trigger: "dn", replacement: "(*$0*)\n$1", options: "t"},

When I use source mode, everything is fine. Otherwise I get this situation where the first mouse cursor is wrongly placed (cursor represented by the | character) :

(|**)

To Reproduce

  • Create an obsidian vault
  • Download LaTeX suite
  • Add the snippet
  • Make sure to not be in source mode
  • Trigger the snippet

Expected Behavior

I should get this configuration

(*|*)

Hint

I think this issue is inherently related to the presence of \n...

ValentinRonsseray avatar Feb 20 '24 22:02 ValentinRonsseray

export const onKeyDown = (event: KeyboardEvent, view: EditorView) => {
    const success = handleKeydown(event.key, event.shiftKey, event.ctrlKey || event.metaKey, view);
    /* at this point */
    if (success) event.preventDefault();
}

At the point indicated above, the content of view.state.selection remains the same regardless of whether it is in "Live Preview" or "Source mode".
Thus, obsidian-latex-suite may not be the cause of this issue.

bdm-k avatar Mar 24 '24 02:03 bdm-k