Skip to content

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

@ericdrobinson

Description

@ericdrobinson

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

Metadata

Metadata

Labels

*duplicateIssue identified as a duplicate of another issue(s)editor-renderingEditor rendering issues

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions