Open thetrompf opened 7 years ago
Tricky, today snippets are always adjusted to the indent of the line it is inserted at. Think of the normal for-loop. We might need some special character to signal this behaviour.
I thought that was what I was doing with \r
?
That's just interpreted as newline, like the elements in the body
array...
Yes I'm aware :) what I meant was, that \r
could be that "special" character?
To me it seems more intuitive to be able to use \b
in snippets (handle ascii backspaces in the json string).
It would also be handy to have a special sequence to remove n levels of indentation, clear line, and have a reference to the starting indent level the cursor was on when the snippet was inserted.
In https://github.com/Microsoft/vscode/issues/57093 we are discussion a flag that tells the snippet controller to not adjust indentation. With that unwanted "extra" indentation can be controlled, but un-indentation isn't part of that. We can then still discuss the \b
idea
The question with the unindent is how far to go? Should \b
unindent by one indentation-unit or to the start of the line? Or should another character be use for start of like, like the start of text ascii control character?
I think, if you want to go that way, we need two special characters, one for start of line, and one for unindent one. Both are useful in different contexts. In my particular example I need, start of line in order to support heredoc.
I've came to an issue where I need to unindent the snippet by 1 indentation-unit. e.g.: imagine a lot of elseif or python's elif statements where the indentation is PART OF THE LANGUAGE.
\b support for unindent by 1 unit would be really great
I think support for unindent a single indentation unit will be great too. Sadly it does not solve this particular issue, because I don't how I need to unindent, I simply need to unindent to the start of the line, which \r
represents. To be honest I don't really care what the token should be.
Is there any update for current case?
I've put else
in both increaseIndentPattern
and decreaseIndentPattern
.
When I type else
; the indentation works perfectly.
But when using a snippet or auto-complete; it fails.
So I'd be happy if the snippet/auto-complete issue is at least fixed.
Example:
@Hezkore I see your issue, but I don't think it's related to this. This is an issue about "calling" formatters when a snippet is "completed" all placeholders has been replaced or the snippet is "tabbed away from".
@thetrompf Well... my bug report was closed in reference to this issue. See #76139
My issue is still very much relevant. And I'm still not sure why my issue was closed if it's not similar to this one. @jrieken any update on my issue (#76139) or why the merge happened? It's driving me insane trying to code with this bug happening.
Maybe related to https://github.com/microsoft/vscode/issues/171439 ?
Maybe related to https://github.com/microsoft/vscode/issues/171439 ?
Maybe. If the issue you're referring to is solved in the way you suggest, it probably/maybe fixes this too.
But I don't agree that there is an issue in 171439. IMO if you select some code and instruct the editor to indent it, the editor shouldn't suddenly not "obey" - it is easy enough to only select the code you want to indent.
In this issue, at least how I imagined the solution, I just want snippets to adhere to the \r
(carriage return) character.
But I don't agree that there is an issue in 171439. IMO if you select some code and instruct the editor to indent it, the editor shouldn't suddenly not "obey" - it is easy enough to only select the code you want to indent.
This should be better discussed on that issue, but the thing is, it's very common having to move and indent big chunks of code and it's really annoying having to select and indent the code per blocks manually or to accidentally introduce syntax errors because you oversaw some HEREDOC tags. You will never want to indent a HEREDOC tag because it simply breaks the code.
Indenting code is a formatting feature, and a formatting feature shouldn't break your code.
How can I control unindentation in code snippets?
When invoking it in indented context:
Expected behavior:
Actual behavior:
This is invalid behavior when using heredoc.
I tried to insert to try removing all indentation,
but it is just translated to a newline and indented according to snippet context.
\r