autoClosingPairs with Pascal-like control structures with reserved words such as if, then, else, while, for, and case #503
Replies: 3 comments 1 reply
-
I am looking at this problem again. Do you have any advice? |
Beta Was this translation helpful? Give feedback.
-
For autoClosingPairs it is based on DefaultCharacterPairMatcher which is working only whith char pairs and not with string pairs https://github.com/eclipse/tm4e/blob/0dc90e2d48f9889aea5a35f08a3e5fa734d7aaf4/org.eclipse.tm4e.languageconfiguration/src/main/java/org/eclipse/tm4e/languageconfiguration/internal/LanguageConfigurationCharacterPairMatcher.java#L147 Perhaps you should re implementer the matcher and try to use https://github.com/eclipse-texlipse/texlipse/blob/master/org.eclipse.texlipse/source/org/eclipse/texlipse/editor/TexPairMatcher.java which seems supporting latex According this doc https://github.com/eclipse-texlipse/texlipse/blob/e1f9619b519e6684528d5eb4ee75fd464a0d7256/docs/arch/techspec.tex#L1109 it seems string matcher instead of char matcher is supported. Good luck! |
Beta Was this translation helpful? Give feedback.
-
Thanks for the help. I tested VSCode and it works in the same way as tm4e. In the end I have settled for one auto-closing pair such as
and two on enter rules
one needs to define two on enter rules depending on where the cursor is when the user press enter. It is not ideal and a bit cumbersome, but it looks the most one can get with the current spec. I leave the solution here in case it is helpful for someone else in the future. |
Beta Was this translation helpful? Give feedback.
-
Hi,
we have languages with follow the syntax of Pascal-like control structures with reserved words such as if, then, else, while, for, and case. For these language we would like to use the autoClosingPairs feature to complete the control structure automatically as the user types.
My first try has been
but then the indentation is not respected after the new line, for example, if I insert an space after the "if" in
The editor text will become:
I would have expected that the new line is indented in the same way as the line where the user is typing. So my expected result:
If it is a bug, we can work on a fix. If it is the expected behavior, how would one support Pascal-like control structures?
Even though it is maybe a bit more complicated, I also tried autoClosingPairs together with onEnterRules:
but that is also not working: typing "if " will add the "then" and put the cursor on the right place, but then pressing enter will move the "then" to the new line as well, even though it is part of the
afterText
that matched. So indentation will be correct, but the "then" ends in the wrong line.Any input on how to support the use case? Fixing "autoClosingPairs" to know about indentation? Fixing "onEnterRules" to skip the "afterText" (looks strange to me)?
Thanks
Beta Was this translation helpful? Give feedback.
All reactions