Skip to content
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

Editor improvements (#4637, #3685) #5423

Conversation

outcoldman
Copy link
Contributor

@outcoldman outcoldman commented Apr 17, 2016

Implement trim whitespaces on enter #4637

When use double enter with automatic indention - in most cases user does
not want to keep identation on skipped lines. This change introduces new
editor configuration editor.trimWhitespacesOnEnter, which is false
by default (for backcompatibility).

On every enter command cursor checks if the line which will be on the
left has some whitespaces which can be trimmed - and extend cursor
range to remove whitespaces.

Backspaces decreases indent #3685

In case when on the left side of the line there are only spaces - help
user to delete whole indent = tabSize.

@msftclas
Copy link

Hi @outcoldman, I'm your friendly neighborhood Microsoft Pull Request Bot (You can call me MSBOT). Thanks for your contribution!

In order for us to evaluate and accept your PR, we ask that you sign a contribution license agreement. It's all electronic and will take just minutes. I promise there's no faxing. https://cla.microsoft.com.

TTYL, MSBOT;

@msftclas
Copy link

@outcoldman, Thanks for signing the contribution license agreement so quickly! Actual humans will now validate the agreement and then evaluate the PR.

Thanks, MSBOT;

@outcoldman outcoldman force-pushed the 4637-implement-trim-whitespaces-on-enter branch from 5b0205e to 2becfdf Compare April 18, 2016 01:24
@wyntau
Copy link

wyntau commented Apr 18, 2016

Should the option only trim empty lines(only contain space characters) and not trim trailing spaces if the line have other content?

Thus, the markdown file's wanted trailing spaces will not be removed when we press enter.
I checked the test specs and found the wanted trailing spaces will also be removed in this case.

@outcoldman
Copy link
Contributor Author

@treri yeah, that makes sense, I will do appropriate changes (also checked with Sublime Text on default behaviors):

  • I will remove configuration, does not seem like we need to have editor.trimWhitespacesOnEnter configurable.
  • Spaces will be trimmed only in situation where you are on the line, where only empty whitespaces and your cursor is at the end of this line.

@wyntau
Copy link

wyntau commented Apr 18, 2016

@outcoldman Thanks for your awesome work 👍

@outcoldman outcoldman force-pushed the 4637-implement-trim-whitespaces-on-enter branch from 2becfdf to d0893f0 Compare April 18, 2016 12:33
@outcoldman
Copy link
Contributor Author

@alexandrudima @egamma could you take a look on fix for the test Bug 9121: Auto indent + undo + redo is funky after I did this change. I do not have access to original bug (seems like it is not on github), so cannot tell where was original issue and on what I should pay attention.

@outcoldman
Copy link
Contributor Author

@treri you are welcome :) This "feature" also annoys me, good to have an option to fix editor you use.

@outcoldman outcoldman changed the title Implement trim whitespaces on enter option #4637 Implement trim whitespaces on enter #4637 Apr 18, 2016
@egamma
Copy link
Member

egamma commented Apr 18, 2016

@outcoldman thanks for the contribution. Some of the team members are on vacation expect some delays until we get back to you.

@outcoldman outcoldman changed the title Implement trim whitespaces on enter #4637 Editor improvements (#4637, #3685) Apr 19, 2016
@outcoldman
Copy link
Contributor Author

@egamma @alexandrudima I updated this PR with one more change for the editor. I keep changes in separate commits, but the same PR, because one is depend on another one (just a common helper function).

Travis failed with some unrelated problem, could you guys bump it to run it again?

@outcoldman outcoldman force-pushed the 4637-implement-trim-whitespaces-on-enter branch from 7e04814 to c875ade Compare April 19, 2016 14:15
@outcoldman outcoldman force-pushed the 4637-implement-trim-whitespaces-on-enter branch from ac1cdea to 30ae671 Compare April 20, 2016 12:29
@outcoldman
Copy link
Contributor Author

@egamma @alexandrudima can we get it to the April milestone? I made it configurable, so if it will break something - will be possible to turn it off.

When use double enter with automatic indention - in most cases user does
not want to keep indentation on skipped lines.

On every enter command cursor checks if the line which will be on the
left has only whitespaces - and extend cursor range to remove whitespaces.
In case when on the left side of the line there are only spaces - help
user to delete whole indent = tab size.
@outcoldman outcoldman force-pushed the 4637-implement-trim-whitespaces-on-enter branch from 30ae671 to 07cc283 Compare April 21, 2016 21:12
@outcoldman
Copy link
Contributor Author

Fixed merge conflict. @alexandrudima @egamma any updates on this PR? Could you add it to April milestone?

@wyntau
Copy link

wyntau commented Apr 22, 2016

👍

ping @alexandrudima @egamma

@Tyriar
Copy link
Member

Tyriar commented Apr 22, 2016

@outcoldman April's development is finishing up on Monday and @alexandrudima is still out. Since he's the one who needs to review this I don't think it will make it in.

@wyntau
Copy link

wyntau commented Apr 27, 2016

Could anyone add this PR to May milestone?

@Tyriar Tyriar added this to the May 2016 milestone Apr 28, 2016
@alexdima alexdima mentioned this pull request Apr 28, 2016
alexdima added a commit that referenced this pull request May 3, 2016
…sed changes

- add `editor.useTabStops` for tab/backspace behaviour
- add `editor.trimAutoWhitespace` for auto inserted whitespace cleanup
@alexdima
Copy link
Member

alexdima commented May 3, 2016

@outcoldman Thank you for the contribution! ❤️

I have merged the proposed changes in fb5b68d and I also did quite some improvements to them, specifically:

  • in the backspace case to better handle mixed whitespace (e.g. a space followed by a tab)
  • in the trim whitespace case to better handle:
    • remove only whitespace that the editor has added.
    • editing a file in two editors at the same time (the auto whitespace lines are recorded in the model)
    • when pressing Tab or Enter, the whitespace only-lines introduced are marked as auto whitespace lines
    • on any edit of the model that involves the undo/redo stack (i.e. normal editors, not output editors) the marked auto whitespace lines are trimmed if trimming does not interfere with the current edit operations to execute.

P.S. It does not appear as a merge here because this PR contains two 2 MB files and I dropped the parent reference on the merge commit to try to keep our repo .git folder footprint small.

@outcoldman
Copy link
Contributor Author

[sarcasm]
Nice, so you are basically took my work and sign it with your name.
This is how folks in Microsoft are getting promotions :D
[/sarcasm]

@outcoldman outcoldman deleted the 4637-implement-trim-whitespaces-on-enter branch May 3, 2016 17:53
@alexdima
Copy link
Member

alexdima commented May 4, 2016

@outcoldman I am very sorry, it was not my intention to not give you credit for your work, you get all the credit for what you have contributed! ❤️ .

I have tried my best to do the right thing (give credit where it's due) in the commit message (fb5b68d) and in the comments of #4637 and #3685. We will also link to this pull request and mention it in the VSCode May release notes.

Looking forward to further contributions from you where I can just click the merge button -- you can ignore .vscode/.browse.VC.db and .vscode/.browse.VC.db-wal in your local vscode git repo by editing .git/info/exclude such that they don't get committed by accident.

@wyntau
Copy link

wyntau commented May 4, 2016

Maybe you can firstly checkout this PR locally, and then edit as you like, and then use git commit --amend to append your code onto this PR.

Then the commit log will be outcoldman committed with alexandrudima. like this one neovim/neovim@f931e78

@outcoldman
Copy link
Contributor Author

@alexandrudima next time you could ask. I know rebase/reset magic which allows me to remove these files from the history. I actually did it right after I relalized that there were checked in, but got distracted and forgot to update my branch.

Anyway, no bad feelings. Thank you for accepting the work and making improvements.

@martellaj
Copy link
Member

Thanks so much, @outcoldman! Probs my favorite update in 1.2!

@yisibl
Copy link
Contributor

yisibl commented Jun 8, 2016

@outcoldman I think you can add a option, when selected to show indentation, like Sublime Text.

@github-actions github-actions bot locked and limited conversation to collaborators Mar 27, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants