microsoft / vscode

Visual Studio Code
https://code.visualstudio.com
MIT License
164.45k stars 29.36k forks source link

Indent guide highlighting is not semantic #49342

Closed augustocdias closed 3 years ago

augustocdias commented 6 years ago

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

Jupakabra commented 6 years ago

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.

augustocdias commented 6 years ago

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

alexdima commented 6 years ago

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
Tresky commented 6 years ago

@alexandrudima Thank you for combining these together.

lucas-labs commented 6 years ago

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.

RoyHP commented 6 years ago

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

julesgilson commented 6 years ago

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

ghost commented 6 years ago

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.

alexdima commented 6 years ago

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

hassanbinsafdar commented 6 years ago

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

ericdrobinson commented 6 years ago

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

quicksnap commented 6 years ago

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.

CoenraadS commented 6 years ago

@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

mrjones2014 commented 6 years ago

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

quicksnap commented 6 years ago

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

mrjones2014 commented 6 years ago

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

shimondoodkin commented 6 years ago

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

julesgilson commented 5 years ago

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.

rigwild commented 5 years ago

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.

julesgilson commented 5 years ago

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

rigwild commented 5 years ago

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

lllopo commented 5 years ago

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.

hassanbinsafdar commented 5 years ago

@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

mrjones2014 commented 5 years ago

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

quicksnap commented 5 years ago

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.

lllopo commented 5 years ago

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

santaclaus21 commented 5 years ago

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

rikusen0335 commented 5 years ago

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

kanlukasz commented 5 years ago

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

malonnnn commented 5 years ago

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?

LadyCailin commented 5 years ago

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?

kanlukasz commented 5 years ago

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:

Another screen from N++ obraz

jabacchetta commented 5 years ago

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,
}
MatteCrystal commented 5 years ago

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.

wmertens commented 5 years ago

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.

LadyCailin commented 5 years ago

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

reneolivo commented 4 years ago

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

kanlukasz commented 4 years ago

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

quicksnap commented 4 years ago

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

LadyCailin commented 4 years ago

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.

mrjones2014 commented 4 years ago

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

hediet commented 3 years ago

The issue shown in the screenshot has been fixed for indentation guides.

For the remaining cases, we now have "Bracket Pair Guides", which are exact:

recording

In contrast to indentation guides, bracket pair guides use bracket pairs as ground truth (independend of any indentation).