dima74 / intellij-indent-rainbow

Extension which shows indentation with a faint rainbow colored background to make them more readable
https://plugins.jetbrains.com/plugin/13308-indent-rainbow/
GNU General Public License v3.0
62 stars 14 forks source link

Non-error indentation being highlighted as error #44

Open robfreundlich opened 2 years ago

robfreundlich commented 2 years ago

In Typescript (and possibly other languages - I haven't checked), code that is properly indented is being marked with my error-indent color. Here's an example:

image

Sorry to pixelate the actual content - my company is very strict about source code being visible. But I've left all of the punctuation visible so that you can see what's what. The div is definitely indented properly according to our formatting rules. In fact, if I select it and reformat, it doesn't change at all.

IntelliJ "About" info:

IntelliJ IDEA 2021.3 (Ultimate Edition)
Build #IU-213.5744.223, built on November 27, 2021
Licensed to Ab Initio Software

Runtime version: 11.0.13+7-b1751.19 amd64
VM: OpenJDK 64-Bit Server VM by JetBrains s.r.o.
Windows 10 10.0
GC: G1 Young Generation, G1 Old Generation
Memory: 8192M
Cores: 12
Registry:
    editor.transparent.scrollbar=false
    analyze.exceptions.on.the.fly=true
    debugger.watches.in.variables=false
    documentation.show.toolbar=true
    ide.allow.merge.buttons=false
    search.everywhere.settings=true
    editor.full.width.scrollbar=true
    debugger.valueTooltipAutoShowOnSelection=true
    ide.new.editor.tabs.vertical.borders=true
    ide.tooltip.initialDelay=509
    ide.balloon.shadow.size=0
    js.debugger.webconsole=false
    typescript.service.node.arguments=--max_old_space_size=8092

Non-Bundled Plugins:
    indent-rainbow.indent-rainbow (2.0.2)
    Alt n 8 (2.2.0)
    Batch Scripts Support (1.0.13)
    HighlightBracketPair (1.3.4)
    MultiHighlight (2.1.1)
    SplitHistory (8)
    com.alexey-anufriev.scopes-manager-intellij-plugin (1.6.2)
    com.andrewbrookins.wrap_to_column (1.8.0)
    com.github.rougsig.duck-progress-bar (0.0.1)
    com.github.syuchan1005.revealinprojectview (1.0.2)
    com.intellij.plugins.watcher (213.5744.122)
    com.jinsihou.react.snippets (1.1.0)
    com.tabnine.TabNine (0.6.0)
    de.achimonline.changelistorganizer (1.9)
    mobi.hsz.idea.gitignore (4.4.0)
    org.nik.presentation-assistant (1.0.9)
    org.turbanov.run.configuration.as.action (1.4.5)
    ski.chrzanow.foldableprojectview (1.1.2)
    tabs.id (1.12)
    GrepConsole (12.12.211.6693.0)
    String Manipulation (9.4.0)
    com.intellij.jira (3.9.2)
    org.jeto.taskfocus (1.1)
    wide-task-browser (1.0.3)
    com.yiycf.plugins.mavenDependencyHelper (2.5)
    com.intellij.selenium (213.5744.172)
    com.intellij.guice (213.5744.125)
    com.mallowigi.colorHighlighter (9.2.0)
    com.github.lppedd.idea-return-highlighter (0.8.2)
    izhangzhihao.rainbow.brackets (6.21)
    org.vepanimas.uml.javascript (0.1.0)
    com.intellij.plugins.html.instantEditing (213.5744.122)
    JSTestDriver Plugin (202.5)
    Karma (213.5744.122)
    com.abinitio.cat.idea.karma-extension (0.0.4)
    me.mbolotov.cypress (1.4.2)
    com.intellij.gwt (213.5744.125)

Kotlin: 213-1.5.10-release-949-IJ5744.223
robfreundlich commented 2 years ago

I figured out what's going on here. My indentation is set to increments of 2. However, in this case, the formatting is wrapping to odd character positions in order to line up with the correct positions in the lines above. Here's an example of what I mean, with rulers to show what's happening. I'm showing whitespace indentation as -+ to make it clearer:

0123456789012345678901234567890
foo.someMethod(param1,
-+-+-+-+-+-+-+-param2);
0123456789012345678901234567890

Notice that in order to line up param1 and param2, an extra space (-) is needed after the "correct" indentation. This used to work - I never saw the error indentation color in code like this. I did recently update IntelliJ, and it's possible I also got an update to IndentRainbow along the way. So I'm not sure which change introduced the problem.

dima74 commented 2 years ago

This is a known limitation of the current highlighter, which just checks the number of spaces. We had highlighter based on formatting previously, but it was slow and had other problems (btw you can still enable it in settings, but it is not recommended).

For now I suggest you use option "Never highlight indent as error for languages"