Skip to content

Indent Guides Highlight Incorrect Level for Certain Indent Styles and Simple Code Blocks #53737

Closed

Description

Visual Examples

Allman Style Indentation

allman

K&R Style Indentation

k r

Simple Code Block

simpleblock

Whitesmiths Style Indentation

whitesmiths

Steps to Reproduce:

  1. Create a new JavaScript or TypeScript file.
  2. Set the Language/Syntax Highlighting to "TypeScript".
  3. Add the following to the file:
    function test()
    {
        if (window !== undefined)
        {
            console.log("Allman style");
        }
    
        if (window !== undefined) {
            console.log("K&R style");
        }
    
        {
            console.log("Simple block");
        }
    
        if (window !== undefined)
            {
            console.log("Whitesmiths style");
            }
    }
  4. Put the cursor at the bracket on lines 4, 6, 8, and 10. Verify that the highlighted Indent Guide is NOT associated with the associated if statement, but the function statement on line 1.
  5. Move the cursor to the bracket on line 12 or 14. Verify that the highlighted Indent Guide is Not associated with the brackets that define the block, but the encapsulating function statement on line 1.
  6. Move the cursor to the bracket on line 13. Verify that the highlighted Indent Guide is associated with the if statement on line 12.

Discussion

As a user who prefers the Allman indentation style I expect that placing the cursor on a bracket (both opening and closing) associated with a specific block will result in highlighting the block associated with that bracket rather than the encapsulating block. As the reproduction steps show, this also fails with the K&R style and with simple code blocks.

This does work as expected with the Whitesmiths style, the GNU, and likely with any other style that indents the brackets themselves beneath the encapsulating statement.

Environment

Does this issue occur when all extensions are disabled?: Yes

  • VSCode Version: 1.2.5.0
  • OS Version: macOS 10.13.5

Activity

  1. added
    editor-autoindent
    on Jul 6, 2018
  2. changed the title [-]Indent Guides Highlight Incorrect Level for Allman [and K&R]-Style Brackets[/-] [+]Indent Guides Highlight Incorrect Level for Certain Indent Styles and Simple Code Blocks[/+] on Jul 6, 2018
  3. alexdima commented on Jul 26, 2018

    @alexdima
    Member

    Duplicate of #49342

  4. added
    *duplicate
    editor-rendering
    and removed
    editor-autoindent
    on Jul 26, 2018
  5. hassanbinsafdar commented on Aug 6, 2018

    @hassanbinsafdar

    alexandrudima you are saying everywhere this is duplicate i visited all references and in all references you are saying the same thing but not telling the solution 👎

  6. locked and limited conversation to collaborators on Sep 9, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

*duplicateeditor-rendering

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions