-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
remove leading spaces when <Esc>... is pressed #685 #962
Conversation
This is not the case for all filetypes, if a file is not named, it does not do this. Not a big deal though... |
From my observation, the leading white spaces are only deleted if they are added by Vim's autoindent feature. It means if the indentation is added by users and then you press So right now, the question is how we detect whether the white spaces are added by users or not? And how we avoid deleting users' input. |
I think that's maybe why I say there is no easy issue any more ;( |
Yeah, this is a hard one. It should be easy to get current file type from VSCode. But how to avoid deleting spaces input by users is difficult. 😥 where do we store user keyboard input? And I noticed that if you create newlines by pressing Enter and then press Esc, vim will clear current line and lines above (Though VSCode has remove the trailing spaces, nice) |
It seems that removing leading spaces is triggered only if the last action is inserting new line, ie, pressing o in normal mode, press Enter in insert mode. |
How about this? Only when the last action before |
@Zzzen I love your trick here, even though it might not be the same implementation as Vim. To avoid confusing other maintainers, do you mind adding comments before the change then we should be good to go. And of course, rebase to the master :) |
That should look better now. One problem remains that I cannot create a test case it takes effect since filename is created randomly and vscode regards them as plaintext. It seems that currently we are not able to switch language mode programmatically. |
@Zzzen LGTM thanks! |
fix #685
I found it annoying that doesn't remove leading spaces in insert mode. Today, I'm going to fix it myself, contributing to this aaaaaawesome project. You guys have done a great job. 👍