-
Notifications
You must be signed in to change notification settings - Fork 30k
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
Code snippet control indentation #20112
Comments
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 |
That's just interpreted as newline, like the elements in the |
Yes I'm aware :) what I meant was, that |
To me it seems more intuitive to be able to use 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 #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 |
The question with the unindent is how far to go? Should |
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 |
Is there any update for current case? |
@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. |
This comment has been minimized.
This comment has been minimized.
Maybe related to #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 |
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. 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
\r
to try removing all indentation,but it is just translated to a newline and indented according to snippet context.
The text was updated successfully, but these errors were encountered: