-
Notifications
You must be signed in to change notification settings - Fork 29.4k
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
Move line autoindent#14390 #23248
Move line autoindent#14390 #23248
Conversation
@ice-blaze, thanks for your PR! By analyzing the history of the files in this pull request, we identified @alexandrudima and @egamma to be potential reviewers. |
Thanks @ice-blaze for your contribution :) The reason that moving lines needs to honor indentation rules is making sure the indentation adjustment is following rules that Language can control. And we should make it as generic as possible because different languages understand indentation differently, making one case happy doesn't solve the problem.
Well
A simple solution in my mind right now is trying to get a good indentation guess for the first line of selected range, calculate the indentation difference, apply it the selected range and keep all others untouched. We are not |
@rebornix Can you write an example where it won't work with the comments ? Well in fact it's true that I don't cover all languages case with open blocks, but at least I cover major big languages (C/C++, Java/C#, Python, Php, Javascript). And at the end, for every languages I use the inherite of the next whitespace line. (except for some cases with comments if I understand right) So maybe would it be better if I put only the inherit whitespace code in the vscode and for everything related on open blocks I create a plugin for it ? For the Ruby, case I can add it. Well I didn't know this file https://github.com/Microsoft/vscode/blob/master/extensions/typescript/language-configuration.json#L6 you are completly right, I should use it. Is there something equivalent for open blocks ? I guess not or you would already say it. |
@rebornix Well I guess this case
|
When the line was less than 2 caracters, it wouldn't indent
Moving lines ignore know one line comments
Sweet, looking forward to this auto-indentation! It's the only remaining feature from Jetbrains IDEs that I'm missing in VS Code. |
@jsonMartin Well I guess we could use the format feature, applied to the moving block or line. I tried to implement it but the VSCode structure is too complex for me so I give up. But I guess if someone have ease to use the VSCode API, it could be quite easy to just make a call "reformat" after the moving line command. |
Considering the complexity of indentation rules management, I'd like to close this PR for now and once we decide to put some time on it, we can reopen this PR and see how we can improve the experience for moving lines with auto indent turned on. Thanks for your help! |
It's better to close it, I have no intent to change it the future. |
Main issue #14390
Another Issue in which it could be related #22093.
Questions, is there a way to test performances ?
The algorithm work like this:
I created some tests, but I need to have some other feedbacks:
For the issue #22093, they are talking aboit a different approache, after moving the lines, we use an auto indent functionality. Why not I would say but it seems for now the current autoindent feature isn't working well for selected code.