AtomMaterialUI / color-highlighter

JetBrains plugin to preview colors directly from within the code.
MIT License
42 stars 25 forks source link

The `Detect Color.FromArgb` option seems to break when placed in list along with other element #46

Closed VapidLinus closed 2 months ago

VapidLinus commented 2 years ago

Describe the bug

The Detect Color.FromArgb option seems to break when placed in list along with other elements:

image

This is what it looks like without the option enabled:

image

To Reproduce

  1. Create a list initializer and place a Color.FromArgb() call as the first element and something else as the second entry.

Expected Behavior

For each line to contain its own color and not spread over other lines.

Environment

  • JetBrains Rider 2021.2.1 Build #RD-212.5080.71, built on August 26, 2021 Licensed to [REDACTED] Subscription is active until [REDACTED]. Runtime version: 11.0.11+9-b1504.16 amd64 VM: Dynamic Code Evolution 64-Bit Server VM by JetBrains s.r.o. Windows 10 10.0 .NET Framework 4.0.30319.42000 GC: G1 Young Generation, G1 Old Generation Memory: 3000M Cores: 12 Registry: debugger.new.debug.tool.window.view=true, ide.tree.horizontal.default.autoscrolling=false, ide.tooltip.showAllSeverities=true, ide.mac.bigsur.alerts.enabled=TRUE, show.diff.preview.as.editor.tab.with.single.click=true, ea.enable.developers.list=false, parameter.info.max.visible.rows=10, ide.win.file.chooser.native=true, ide.mac.file.chooser.native=TRUE, search.everywhere.pattern.checking=false, ide.mac.bigsur.window.with.tabs.enabled=false, performance.watcher.sampling.interval.ms=200, ide.borderless.tab.caption.in.title=false, awt.file.dialog.enable.filter=FALSE, debugger.show.values.use.inlays=TRUE, light.edit.file.open.enabled=false, performance.watcher.unresponsive.interval.ms=1000, vcs.enable.add.ignored.directories.to.exclude=false, ide.allow.merge.buttons=TRUE, search.everywhere.settings=true, debugger.valueTooltipAutoShowOnSelection=true, use.winp.for.graceful.process.termination=FALSE, ide.tooltip.initialDelay=0, ide.require.transaction.for.model.changes=false, ide.debug.in.title=true, rdclient.asyncActions=false Non-Bundled Plugins: fr.socolin.application-insights-debug-log-viewer (1.2.1), com.intellij.resharper.HeapAllocationsViewer (2021.2.0), com.gmike.visual-studio-2019-dark (1.5.3), Abc.MoqComplete.Rider (1.4.10), lermitage.intellij.extratci (1.12.0.201), de.santiv.fastscrolling (1.2), com.github.copilot (1.0.3), GrepConsole (12.0.211.6086.4), com.mallowigi.colorHighlighter (9.1.1), com.intellij.resharper.StructuredLogging (2021.2.0.168), idea.plugin.protoeditor (212.5080.8), com.jetbrains.sh (212.4746.58), com.microsoft.vso.idea (1.162.0), com.intellij.resharper.azure (3.50.0.1253-2021.2), izhangzhihao.rainbow.brackets (6.21)
mallowigi commented 2 years ago

Interesting. Is it happening with the latest eap ?

mallowigi commented 2 years ago

I've taken a look, and this doesn't look like it's possible to do anything about it. Contrary to other languages, C# does not recognize expressions as a single token, instead, it parses and recognizes individual tokens separately.

What that means is that, unlike in Java or Kotlin, the expression Color.FromArgb(r, g, b) is not recognized as a token, but Color, ., FromArgb etc., separately. As a result, I can't colorize the expression directly. However, I do offer the option to colorize the whole line, with the caveats that:

For now I don't want to do extra work for C#, especially since it's not my language of choice. If someone wants to take upon this task and find a solution, or even open an issue in Rider's YouTrack to better tokenize C# expressions, be my guest.