-
-
Notifications
You must be signed in to change notification settings - Fork 258
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
Unindent for snippets #1945
Comments
Related to this discussion: #1913 If we do this, it would likely only be done when injection "sections" or I guess also when specific line numbers are specified. A full file should already be dedented, and if not, that's on the user. This does run into an issue if you are injecting an indented code block, it would get dedented...but I guess if you indent the snippet syntax, then maybe it'll all work out. I'd have to verify. This is of course if we just go the simple route and dedent all snippet partials automatically. If we have some syntax (and I don't know what that would even look like) that is meant to signify a dedent should occur, then the user would have complete control of when this does or does not happen. The actual dedenting should be pretty easy as there are already built-in tools in Python to do so. Anyways, stuff to think about. |
👍
Yeah, actually having a way to intentionally indent would probably be nice if you combine different snippets or a snippet with accompanying lines. |
Yeah, snippets can be nested too, so it is something to think about. The idea behind snippets was to just very dumbly insert a file. Feature creep is making it a bit more complicated these days, not that it's a bad thing per se. I'd need to find a way to extend the syntax in a reasonable way if we want an explicit approach. |
Actually I just tried, adding indent is possible by indenting the scissors |
Yeah, that is what I figured. We try to respect the indentation of insertion. |
For now, we are going to add an option that always dedents sectional inserts. Assuming that resolves the problem generally well, we might make it the default in the future. We'll see if that is sufficient or if there is a need for manual dedenting. |
I tested the dedent, works perfectly fine here, thanks. |
I have it in beta mainly for the new general-purpose blocks. I'm thinking everything is pretty much cemented there, but I'm getting some active feedback, so just making sure there are no more minor tweaks before I pull the trigger. I'd say soon-ish? I have no plans for any additional features in 9.10. I'm hoping maybe a week or two, but we'll see. |
Great, thanks :-) |
Description
It would be nice if snippets would be unindented, so that the leading whitespace that is common to all lines in the snippet is removed, so it starts left-most with the first character.
This should imho even be the default behavior if it will be configurable.
Benefits
No need to cram the snippet code to beginning of line in the source file to have it nice in the docs.
Solution Idea
Just get the leading whitespace of all lines, take the shortest one and remove that from all lines.
If someone has mixed space and tab indents, it is his own fault. :-D
The text was updated successfully, but these errors were encountered: