Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Live Snippet Cursor stepts out of paranthesis #384

Open
PlisJan opened this issue Apr 12, 2023 · 8 comments · May be fixed by #385
Open

Live Snippet Cursor stepts out of paranthesis #384

PlisJan opened this issue Apr 12, 2023 · 8 comments · May be fixed by #385

Comments

@PlisJan
Copy link

PlisJan commented Apr 12, 2023

Bug Report

Disable all the other extensions except for LaTeX Workshop and LaTeX Utilities, and check that you still see this issue.

You still see this issue?: Yes

Describe the bug

Live Snippet skips out of paranthesis if using +

image

To Reproduce

Steps to reproduce the behaviour:

  1. Use math environment e.g. align or `equation´
  2. Type (a -> vscode automatically closes the bracket -> (a)
  3. insert a plus sign (a+)

Expected behaviour

The cursor should stay inside the paranthesis.
image

Logs

Please paste the whole log messages here, not parts of ones. It is very important to identify problems. If you think the logs are unrelated, please say so.

LaTeX Workshop Output
No usefull logs exists
LaTeX Utilities Output
[13:45:51] Initializing LaTeX Utilities.
[13:45:51] Live Snippets Loaded
[13:45:51] Completion Watcher Initialised
[13:45:51] LaTeX Utilities Started
[13:45:52] LaTeX Utilities version: 0.4.10
[13:48:09] onDidChangeActiveTextEditor_tex_wordcounter
[13:48:09] onDidChangeActiveTextEditor_tex_wordcounter
[13:48:09] TexCount args: -merge,-brief
[13:48:10] TeXCount output for word: 15+0+0 (0/0/3/1) File: 1.tex

[13:48:10] TexCount args: -merge,-brief,-char
[13:48:10] TeXCount output for char: 105+0+0 (0/0/3/1) File: 1.tex

[13:52:51] onDidChangeTextDocument
[13:52:52] onDidChangeTextDocument
[13:52:56] onDidChangeTextDocument
[13:52:56] onDidChangeTextDocument
Developer Tools Console
No usefull logs exists

Screenshots

If applicable, add screenshots to help explain your problem.

Desktop

  • OS: Linux (Fedora 37)
  • VS Code version: 1.77.1
  • Extension version: 0.4.10

Additional context

@khkrishna18
Copy link

I am experiencing the same problem. How to solve this?

@Physicsphobia
Copy link

just add $$1,$$2,$$3,...,$$0 in your snippets file, which can help you put the cursor in the right place

@gusss1234
Copy link

gusss1234 commented Oct 28, 2023

just add $$1,$$2,$$3,...,$$0 in your snippets file, which can help you put the cursor in the right place

@Physicsphobia How do you do that exactly? I am not sure I particularly understand, very new to this. I think I just need an example (better if there is a bit of explanation). Thanks!

@PlisJan
Copy link
Author

PlisJan commented Oct 29, 2023

@gusss1234
Hit Ctrl+Shift+P, select LateX Utilities: Edit Live Snippets file and in the file that opens replace these lines

    {
    "prefix": "([^ &\\\\\\+\\-=<>\\|!~@])([\\+\\-=<>])$",
    "body": "$1 $2",
    "mode": "maths",
    "priority": -1,
    "description": "whitespace before operators",
    "triggerWhenComplete": true
  },
  {
    "prefix": "([\\+\\-=<>])([^ &\\\\\\+\\-=<>\\|!~])$",
    "body": "$1 $2",
    "mode": "maths",
    "priority": -1,
    "description": "whitespace after operators",
    "triggerWhenComplete": true
  },

against

  {
    "prefix": "([^ &\\\\\\+\\-=<>\\|!~@])([\\+\\-=<>])$",
    "body": "$1 $2$$1",
    "mode": "maths",
    "priority": -1,
    "description": "whitespace before operators",
    "triggerWhenComplete": true
  },
  {
    "prefix": "([\\+\\-=<>])([^ &\\\\\\+\\-=<>\\|!~])$",
    "body": "$1 $2$$1",
    "mode": "maths",
    "priority": -1,
    "description": "whitespace after operators",
    "triggerWhenComplete": true
  },

Then it should work.

@gusss1234
Copy link

@PlisJan Thanks! I think it fixed it, need to add it to everything else now since it's not the only affected by operators. This should definitely be fixed in the main codebase.

@gusss1234
Copy link

gusss1234 commented Oct 30, 2023

Before that is done, I think this fixes all space problems. Beware, I deleted dot(a) and ddot(a) snippets.
latexUtilsLiveSnippets_guss.json

@grepgrok
Copy link

grepgrok commented Mar 3, 2024

Yeah, I was having this same problem. Without looking at the code, I'm betting it has to do with VSCode not being told where to place the cursor after executing the snippet (or maybe being told to put it in the wrong place). I notice that when I have a snippet with a trigger 2 characters long which expands into 10 characters, the cursor is placed 10 - 2 = 8 characters after the end of the expansion.

This definitely seems like a bug. As a temporary fix, using the guss provided above would work well. For a cleaner fix, it should probably address the issue directly.

@jhanschoo
Copy link

For another minimal example, in inline math delimiters \( \), keep typing inn with live reformat on and watch the cursor get misplaced.

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 a pull request may close this issue.

6 participants