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

When pressing Tab on white-space only lines, indent straight to the right spot (similar to empty lines) #2938

Closed
amamut opened this issue Feb 11, 2016 · 8 comments
Assignees
Labels
bug Issue identified by VS Code Team member as probable bug verification-found Issue verification failed verified Verification succeeded
Milestone

Comments

@amamut
Copy link

amamut commented Feb 11, 2016

Depending on how my cursor arrives at line of code determines which way the editor indents the line. Let me start by showing what the correct indent spacing looks like:
https://gyazo.com/eca50fd7907e95b870c4b1b5602300c3

  1. If I am on a line of code and there is already a space on the line, which is invisible if the line is selected, indents to the first indent spot encountered.
    https://gyazo.com/687cae9a5b229d24fccb8c958cdbc434
  2. If I am on a line of code, lose focus of VS Code, and then come back to VS Code the indent spacing is incorrect and its a combination of tabs and spaces.
    https://gyazo.com/44a5e6d87122dd59559c047cb8b9336d
  3. If you enable to show invisible spaces, they are still not visible on the current line selected. I think it would be useful to be able to see them as well.

It may be useful stating that this weird spacing is occurring while working with typescript. I am not sure if it occurs for any other languages. And please let me know if I am missing a configuration item.

Thanks!

@roslanr18
Copy link

[email protected]
On Feb 11, 2016 10:51 PM, "Alex Mamut" [email protected] wrote:

Depending on how my cursor arrives at line of code determines which way
the editor indents the line. Let me start by showing what the correct
indent spacing looks like:
[image: https://gyazo.com/eca50fd7907e95b870c4b1b5602300c3]
https://gyazo.com/eca50fd7907e95b870c4b1b5602300c3

If I am on a line of code and there is already a space on the line,
which is invisible if the line is selected, indents to the first indent
spot encountered.
[image: https://gyazo.com/687cae9a5b229d24fccb8c958cdbc434]
https://gyazo.com/687cae9a5b229d24fccb8c958cdbc434
2.

If I am on a line of code, lose focus of VS Code, and then come back
to VS Code the indent spacing is incorrect and its a combination of tabs
and spaces.
[image: https://gyazo.com/44a5e6d87122dd59559c047cb8b9336d]
https://gyazo.com/44a5e6d87122dd59559c047cb8b9336d
3.

If you enable to show invisible spaces, they are still not visible on
the current line selected. I think it would be useful to be able to see
them as well.

It may be useful stating that this weird spacing is occurring while
working with typescript. I am not sure if it occurs for any other
languages. And please let me know if I am missing a configuration item.

Thanks!


Reply to this email directly or view it on GitHub
#2938.

@alexdima
Copy link
Member

@amamut Is it possible you hit #2829 (i.e. if you try one of the workarounds is this reproducible?). Otherwise (if this still occurs after applying one of the workarounds), can you please share your settings? (i.e. do you use formatOnType)

@alexdima alexdima added the info-needed Issue requires more information from poster label Feb 12, 2016
@amamut
Copy link
Author

amamut commented Feb 12, 2016

@alexandrudima I do not use formatOnType. So workaround #1 fixed the weird combination tab and space indenting. The culprit could be "files.autoSave": "onFocusChange" as the workaround made me comment this line out.

However it did not fix the single space on a line bug where it indents to the first indent spot encountered.

It may be useful to add that I am also using OSX El Capitan 10.11.3.

@alexdima
Copy link
Member

@amamut Indeed, only empty lines get indented straight to the right place -- https://github.com/Microsoft/vscode/blob/master/src/vs/editor/common/controller/oneCursor.ts#L1284

I can enhance that logic to also do it for whitespace only lines.

@amamut
Copy link
Author

amamut commented Feb 12, 2016

@alexandrudima I feel that would make the most sense.

@alexdima alexdima self-assigned this Feb 15, 2016
@alexdima alexdima removed the info-needed Issue requires more information from poster label Feb 15, 2016
@alexdima alexdima changed the title Indent spacing inconsistent When pressing Tab on white-space only lines, indent straight to the right spot (similar to empty lines) Mar 17, 2016
@alexdima alexdima added the bug Issue identified by VS Code Team member as probable bug label Jul 5, 2016
@alexdima alexdima added this to the July 2016 milestone Jul 5, 2016
@chrmarti chrmarti added verified Verification succeeded verification-found Issue verification failed and removed verified Verification succeeded labels Jul 28, 2016
@chrmarti
Copy link
Collaborator

Works, except when there is already the full indentation (or more) on the line. It would make sense to make it work the same way in that case:

indent

@chrmarti chrmarti reopened this Jul 28, 2016
@egamma egamma modified the milestones: August 2016, July 2016 Jul 29, 2016
@egamma
Copy link
Member

egamma commented Jul 29, 2016

This is makes sense, but not critical enough for July. Moving to August.

@alexdima
Copy link
Member

@chrmarti I would consider this a separate thing. Mostly, the indentation adds whitespace, in this case it would need to delete whitespace which it never did so far. Let's track your request in #11322

@isidorn isidorn added the verified Verification succeeded label Sep 2, 2016
@vscodebot vscodebot bot locked and limited conversation to collaborators Nov 18, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Issue identified by VS Code Team member as probable bug verification-found Issue verification failed verified Verification succeeded
Projects
None yet
Development

No branches or pull requests

6 participants