Vscode: Indent guide highlighting is not semantic

Created on 7 May 2018  路  41Comments  路  Source: microsoft/vscode

Shouldn't the highlighted guide be the one with the blue arrow instead the one with the red when the cursor is at the green line?
screen shot 2018-05-07 at 09 39 40

editor-indent-guides feature-request

Most helpful comment

Wow. Did I miss something, or the VS Team did something with this?
At the moment I tested it and it looks as it working as we expect (more or less)

indent

All 41 comments

It's debatable, if you put cursor at "**/*.txt" you expect it to mark it's parent indent which is "todohighlight.include", and in this case you are marking "todohighlight.include" who's parent is whatever is at the top level, so it work correctly.

One could argue that if selected child node has nodes it's children indent should be selected instead.

I agree that it is debatable... In my point of view if the cursor is after the block start it should move the highlighted guide to the next one. On the other hand, if the cursor is before, I agree with you @Jupakabra

Another example from @Tresky in #49384

Sample Code

function foo (cb) { // this scope gets highlighted
|   // placing cursor on if-statement on the below line will highlight the tab for the function-scope; expected the if-scope.
|   if (this.bar) { // < --- this tab-line *should* be highlighted
|       cb()
|   }
}

Screenshot

screen shot 2018-05-07 at 1 26 05 pm

@alexandrudima Thank you for combining these together.

I'm facing the same error. I think if I am positioning the cursor after the beginning of a block (curly brace, BEGIN keyword, etc -depending on the programming language-) then I'm definitely inside the block and it should be highlighted. See the following screenshot:

vsbug

I know it's horribly indented, but I just want to make a point. I mean, it's still valid code, and the cursor is definitely inside the method block. However, VS Code is highlighting the parent block, which is wrong imo.

This bug is driving our team nuts. We have always expected the block within the brackets where the cursor is placed to be highlighted.

In our opinion, the highlight should be at the blue arrow. I personally don't know of any other editors that do it this way; it's very counterintuitive

doesn't seem logical to me either - maybe there are people who prefer it the way it is - if so then an additional setting to select parent or current would suit all. I would imagine they are the minority though..

Same issue. It's very confusing in HTML as well.
vscode

I'd expect the <div id="container"> indent line to be highlighted. Instead <body> tag indent line is being highlighted.

There are more good examples in https://github.com/Microsoft/vscode/issues/53737#issue-339017155

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

@hassanbinsafdar With respect to your comments:

you are saying everywhere this is duplicate

He said that for the actual duplicates, including the one that I opened. _This_ issue (#49342), you will note, is left in the Open state to track the problem.

in all refrences you are saying the same thing but not telling the solution

Currently, there _is_ no solution. It's an Open issue and is currently in the Backlog, effectively marking it for "future fix" consideration.

The only "solution" available today is to disable the feature in your Settings:

// Controls whether the editor should highlight the active indent guide
"editor.highlightActiveIndentGuide": false,

_[See here for more details.]_

You could then use a third-party extension like Bracket Pair Colorizer to get the feature.

The current behavior is not intuitive to me as well.

Bracket Pair Colorizer extension does work as I would expect, and has some great features (such as underlining the statement which defines the scope). Unfortunately it causes severe input lag when moving the cursor vertically very quickly.

@quicksnap Thanks for the feedback. I'm the author of bracket pair coloring and am developing v2 which is much faster, if you wish you can try it out and if you still have performance concerns please file an issue and I will try to address it 馃憤

https://marketplace.visualstudio.com/items?itemName=CoenraadS.bracket-pair-colorizer-2

@CoenraadS I've actually installed your bracket pair colorizer 2 and it does, in fact, solve the problem well enough that I'm satisfied, for most editors. however, it doesn't solve the issue, for example, in HTML markup (since there's not really any "brackets" for it to highlight). would it be possible to use your extension to enable the indent guides for HTML/Vue single file component templates?

The UX provided by @CoenraadS's extension, IMO, is something that should be in core VSCode. It's _really_ awesome.

@quicksnap I agree, the way the built-in indent guides work has been my biggest gripe/annoyance since day 1. @CoenraadS's extension has stopped my from pulling my hair out on many an occasion. The built-in indent guides are _really_ not how I'd expect or want them to work.

I have a similar issue with javascript, on recent update today

7 months later... yawn. Even if someone deems this to be the "correct" functionality then it seems plenty of others do not - just make it a setting.

The Bracket Pair Colorizer extension does not support Vue single file components. Always got confused by this tiny indent guide not being on the correct indentation (I mean, as i expect it to be).
When you're scrolling through some lines expecting to visually match the ending tag it gets confusing.

The Bracket Pair Colorizer extension does not support Vue single file components.

Bracket pair colorizer works OK for me in Vue components. See attached

clipboard01

@julesgilson I was talking about the indent guide being misplaced, my bad.

This is issue is driving me nuts too. Guys, this is simply so badly not intuitive. The idea is to highlight the current scope after all and currently it highlights ... what ?! All of the examples above are really good and valid, including the HTML one. If there are some (crazy) people that like the current behavior outhere, just add a setting, so everyone can set it they want and let's get it done.

@lllopo microsoft not want to leave his legacy They start anything with very good but with passage of time they start to annoy users I was quiet happy but now i switch to webstorm cause of these types of problems

@lllopo yeah its getting pretty ridiculous that this isn't fixed..... I'm holding out hope, but I may just have to switch if this isn't fixed soon.

Everyone, please keep the comments constructive. VSCode team does a great job with the product. Nothing is stopping any of you from creating a PR. In the mean time, the aforementioned extension is available: marketplace.visualstudio.com/items?itemName=CoenraadS.bracket-pair-colorizer-2

Being negative toward the VSCode team doesn't encourage them to improve this feature.

@quicksnap I don't really understand how I have been 'negative' towards the team, as you state. I fully appreciate the great work the VS Code team does overall. It is a great product and actually the best of class free product IMO (maybe only SublimeText is coming close, but it's not really free). And just because of that, having such an essential functionality working in such a weird way (actually not working) for such a long time is totally strange, having that I've seen many other, peripheral issues to get much more love from the team than this one. The simple truth is : the bigger the group of people expressing their dissatisfaction with the current way of working - the bigger the chance of something actually get moving (just like you did a few comments above, btw ;-) ). Simple as that and that's what I did.
As of bracket pair colorizer 2 - it is a nice one, but it's a no go, of course. I have a few small issues with it, annoying, but doesn't worth mentioning and there is the big one - it doesn't support HTML. Full stop.

I'm considering going back to the previous editor because of this

Nothing updates on this? I'm thinking vscode is awesome, but this issue is VERY IMPORTANT to work with html. Unfortunately, I'm considering going back to another editor too...

I miss so much with this function. This is one good functions that Notepad++ have. It REALLY improve coding workflow. Please make it,i beg

obraz
obraz

Just leaving my 2 cents that this is still present in mid july and also driving me insane. going to try CoenraadS pair colorizer 2

@CoenraadS I'm having trouble getting your plugin to work.. does it only work with certain langauges?

I was going to perhaps take a stab at this, but is this an acceptable change? If so, can this be marked with help-wanted or bug?

>

I'm having trouble getting your plugin to work.. does it only work with certain langauges?

Please, don't mix cases. This is VSCode repo, not Bracket Pair.
If you have a problem with CoenraadS plugin, open ticket in his repository
Keeping tickets clean is good for all of us 鉂わ笍


I was going to perhaps take a stab at this, but is this an acceptable change? If so, can this be marked with help-wanted or bug?

I hope it is possible/acceptable and VS Team will implement that.


The Bracket Pair plugin is not a perfect solution because:

  • it does not recognize semantics in tags (html div, etc.)
  • it has a lot of problems with Extension causes high cpu load

Another screen from N++
obraz

This, in combination with #58713, provides for some unintuitive code navigation.

FYI, for anyone looking to solve this issue with Bracket Pair Colorizer without getting all of the distracting colors shown in the screenshots, the following settings work well:

{
  // Disable distracting bracket pair colors (prefer styling of Subtle Bracket matching pairs)
  "bracket-pair-colorizer-2.colors": [],

  // Customizes indent guide and scope line. Modify style to fit your theme. This works well with
  // Material Theme.
  "bracket-pair-colorizer-2.scopeLineCSS": [
    "borderStyle : solid",
    "borderWidth : 1px",
    "borderColor : #606d75",
    "opacity: 1"
  ],

  // // Set to false if wanting to remove the horizontal scope line that connects to the active indent
  // // guide.
  // "bracket-pair-colorizer-2.showHorizontalScopeLine": false,

  // Turn off built-in active indent guides since they aren't semantic (parent scope gets
  // highlighted in some scenarios).
  "editor.highlightActiveIndentGuide": false,
}

I also think the current functionally in vs code is unacceptable especially since there seems to be no fix for html ATM which is what I need it for. Please add this feature, this is a deal breaker for many people.

There's over 5000 open issues in this repo. It's not helpful to keep saying the feature is crucial for your particular workflow. Just add your 馃憤 on the parent comment, that is something the team can search on too.

So if you came here to say "me too", please refrain from doing so, it is counterproductive.

I completed a pull request 2 months ago that mostly fixed this. Can I get some feedback on that?

I really hate this! I hope there was some way to configure it. Leaving a comment in hopes that this is fixed.

Wow. Did I miss something, or the VS Team did something with this?
At the moment I tested it and it looks as it working as we expect (more or less)

indent

Woah! What?! You're right @kanlukasz it's fixed now!

Yep! This is 90% fixed now with this PR: https://github.com/microsoft/vscode/pull/77762 This bug still isn't closed, because the PR doesn't actually do semantic detection (it's just based on the indentation of the above and below lines) so there will still be edge cases where it doesn't work, but for the vast majority of cases and codebases, it will work just fine. See the PR for details about what cases it won't work in.

@LadyCailin I've been watching this issue for almost 2 years. you are my hero!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

biij5698 picture biij5698  路  3Comments

VitorLuizC picture VitorLuizC  路  3Comments

shanalikhan picture shanalikhan  路  3Comments

v-pavanp picture v-pavanp  路  3Comments

mrkiley picture mrkiley  路  3Comments