Oskar-Idland / hsnips

HyperSnips: a powerful snippet engine for VS Code, inspired by vim's UltiSnips
MIT License
2 stars 1 forks source link

tabstops break when there are many #4

Closed superle3 closed 6 days ago

superle3 commented 1 week ago

Another problem within vscode itself. Tabstops break sometimes into multicursor or delete further tabstops when you place "too many". This also breaks with normal snippets from vscode but this below is an example

test snippets:

snippet trigger1 "Trigger 1" iA
b_${1} b_${2} b_${3} b_${4} b_${5} b_${6} b_${7} b_${8} b_${9} b_${10}
endsnippet

snippet trigger2 "Trigger 2" iA
a_${1} a_${2} a_${3} a_${4} a_${5} a_${6} a_${7} a_${8} a_${9} a_${10}
endsnippet

expected behaviour: when typing trigger1 trigger2 and tabbing through the whole thing, without it going into multicursor.

actual behaviour: trigger1 trigger2 breaks when at b_ a_ a_ a_ a_ a_ a_ a_ a_ a_ a_| b_| b_ b_ b_ b_ b_ b_ b_ b_ where | is the cursor. Seems to only break when transitioning from one snippet to another

Oskar-Idland commented 1 week ago

Yeah, testing it, it seems like the second trigger is the determinering factor. If the second trigger has 10 or more tabstops, we get the issue. I think it is some parsing issue, because when i have these triggers:

snippet trigger1 "Trigger 1" iA
a_${1} a_${2} a_${3} a_${4} a_${5} a_${6}
endsnippet

snippet trigger2 "Trigger 2" iA
b_${1} b_${2} b_${3} b_${4} b_${5} b_${6} b_${7} b_${8} b_${9} b_${10} b_${11} b_${12} 
endsnippet

Then, I use trigger1 first, and trigger2 second, we get the double cursor at the 10'th tabstop of trigger2, and the first of trigger1:

a_b_ b_ b_ b_ b_ b_ b_ b_ b_ b_| b_ b_  a_|a_ a_ a_ a_

This seems like some parsing problem as the number 10 and the number 1, both begin in 1.

superle3 commented 1 week ago

That connection is interesting, that makes it easier to report to vscode. But this is an issue of vscode since those same snippets also break with normal user snipets. Will report to them when I have the time, this is just to track if it gets fixed.

[
    "test1": {
        "prefix": "test1",
        "body": [
            "a_$1 a_$2 a_$3 a_$4 a_$5 a_$6 a_$7 a_$8 a_$9 a_$10"
        ],
        "description": "test1"
    },
    "test2": {
        "prefix": "test2",
        "body": [
            "b_$1 b_$2 b_$3 b_$4 b_$5 b_$6 b_$7 b_$8 b_$9 b_$10"
        ],
        "description": "test2"
    }]
superle3 commented 1 week ago

reported in https://github.com/microsoft/vscode/issues/230149

superle3 commented 6 days ago

and its marked as duplicate. Closest thing I could find was https://github.com/microsoft/vscode/issues/87226. The STUPID work around that I found was to avoid certain numbers like when test2 goes up to $10 then all other snippets should avoid $2 to avoid this issue. When it goes up to $20 then $2 and $3 should be avoided. Using "a_$1 a_$12" does avoid this issue but "a_$11 a_$12" doesn't. I don't where this issue should go further.

Oskar-Idland commented 6 days ago

I agree. We can add a "known issues" part to the README. I will close this as there is nothing more to do here. Can you explain in detail your solution so I can add to the README, or add this to the README in a PR?