Skip to content

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

Closed

Description

@amamut

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!

Activity

  1. roslanr18 commented on Feb 11, 2016

    @roslanr18

    [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.

  2. alexdima commented on Feb 12, 2016

    @alexdima
    Member

    Alex Mamut (@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)

  3. added
    info-needed
    on Feb 12, 2016
  4. amamut commented on Feb 12, 2016

    @amamut
    Author

    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.

  5. alexdima commented on Feb 12, 2016

    @alexdima
    Member

    Alex Mamut (@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.

  6. amamut commented on Feb 12, 2016

    @amamut
    Author

    alexandrudima I feel that would make the most sense.

  7. removed
    info-needed
    on Feb 15, 2016
  8. changed the title [-]Indent spacing inconsistent[/-] [+]When pressing Tab on white-space only lines, indent straight to the right spot (similar to empty lines)[/+] on Mar 17, 2016
  9. added
    bug
    on Jul 5, 2016
  10. added
    verified
    verification-found
    and removed
    verified
    on Jul 28, 2016
  11. chrmarti commented on Jul 28, 2016

    @chrmarti
    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

  12. egamma commented on Jul 29, 2016

    @egamma
    Member

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

  13. alexdima commented on Aug 31, 2016

    @alexdima
    Member

    Christof Marti (@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

  14. locked and limited conversation to collaborators on Nov 18, 2017
  15. added a commit that references this issue on Sep 6, 2026
    b16e27a
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

bugverification-foundverified

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions