helix-editor / helix

A post-modern modal text editor.
https://helix-editor.com
Mozilla Public License 2.0
33.95k stars 2.51k forks source link

Cursor changes color on whitespaces and indent guides #5675

Closed imsuck closed 12 months ago

imsuck commented 1 year ago

Summary

Even if you set the cursor's foreground and the reverse modifier, it would still change its color if it was on a virtual whitespace or indent guide. Which is not expected since on normal text it stays white.

theme.toml to replicate ```toml "ui.selection" = { bg = "gray" } "ui.cursor" = { fg = "light-gray", modifiers = ["reversed"] } "ui.virtual.indent-guide" = { fg = "blue" } "ui.virtual.whitespace" = { fg = "blue" } ```

Reproduction Steps

I tried this: [![asciicast](https://asciinema.org/a/79vFx0OJmmdrp6qEDhalNGeKL.svg)](https://asciinema.org/a/79vFx0OJmmdrp6qEDhalNGeKL) I expected this to happen: Whitespaces and indent guides should respect the cursor's foreground, and the cursor should stay white. Instead, this happened: The cursor changes its color. Note: I use gray `▏` indent guides. And my selection bg has the same color. Which makes it hard to tell which side is the selection anchor on is if it was on the `▏`. I used blue for the asciinema just to make it stand out. ### Helix log Since this is a theme related problem logs wouldn't be useful. I still left it here just in case.
~/.cache/helix/helix.log ``` 2023-01-24T12:29:59.292 helix_view::editor [ERROR] Failed to initialize the LSP for `source.toml` { cannot find binary path } 2023-01-24T12:40:28.317 helix_view::editor [ERROR] Failed to initialize the LSP for `source.bash` { cannot find binary path } 2023-01-24T13:35:50.586 helix_view::editor [ERROR] editor error: 1 unsaved buffer(s) remaining: ["hyprland.conf"] 2023-01-24T20:15:58.854 helix_view::editor [ERROR] editor error: No definition found. 2023-01-24T20:19:57.833 helix_view::editor [ERROR] editor error: No definition found. 2023-01-25T05:57:24.824 helix_view::editor [ERROR] Failed to initialize the LSP for `source.bash` { cannot find binary path } 2023-01-25T05:59:36.373 helix_view::editor [ERROR] Failed to initialize the LSP for `source.bash` { cannot find binary path } 2023-01-25T06:46:01.835 helix_view::editor [ERROR] editor error: No more matches 2023-01-25T08:36:37.703 helix_term::application [WARN] lsp position out of bounds - Diagnostic { range: Range { start: Position { line: 6, character: 71 }, end: Position { line: 6, character: 71 } }, severity: Some(Error), code: None, code_description: None, source: Some("rustc"), message: "expected `;`, found `}`", related_information: Some([DiagnosticRelatedInformation { location: Location { uri: Url { scheme: "file", cannot_be_a_base: false, username: "", password: None, host: None, port: None, path: "/home/imsuck/Yes/amogus/src/main.rs", query: None, fragment: None }, range: Range { start: Position { line: 7, character: 0 }, end: Position { line: 7, character: 1 } } }, message: "unexpected token" }, DiagnosticRelatedInformation { location: Location { uri: Url { scheme: "file", cannot_be_a_base: false, username: "", password: None, host: None, port: None, path: "/home/imsuck/Yes/amogus/src/main.rs", query: None, fragment: None }, range: Range { start: Position { line: 6, character: 71 }, end: Position { line: 6, character: 71 } } }, message: "add `;` here: `;`" }]), tags: None, data: Some(Object {"rendered": String("error: expected `;`, found `}`\n --> src/main.rs:7:72\n |\n7 | let (h, m) = (h.parse::().unwrap(), m.parse::().unwrap())\n | ^ help: add `;` here\n8 | }\n | - unexpected token\n\n")}) } 2023-01-25T08:36:37.703 helix_term::application [WARN] lsp position out of bounds - Diagnostic { range: Range { start: Position { line: 6, character: 71 }, end: Position { line: 6, character: 71 } }, severity: Some(Hint), code: None, code_description: None, source: Some("rustc"), message: "add `;` here: `;`", related_information: Some([DiagnosticRelatedInformation { location: Location { uri: Url { scheme: "file", cannot_be_a_base: false, username: "", password: None, host: None, port: None, path: "/home/imsuck/Yes/amogus/src/main.rs", query: None, fragment: None }, range: Range { start: Position { line: 6, character: 71 }, end: Position { line: 6, character: 71 } } }, message: "original diagnostic" }]), tags: None, data: None } 2023-01-25T09:22:15.737 helix_view::editor [ERROR] Failed to initialize the LSP for `source.toml` { cannot find binary path } 2023-01-25T09:23:02.500 helix_view::editor [ERROR] Failed to initialize the LSP for `source.toml` { cannot find binary path } 2023-01-25T09:23:50.640 helix_view::editor [ERROR] Failed to initialize the LSP for `source.toml` { cannot find binary path } 2023-01-25T09:27:16.856 helix_view::editor [ERROR] editor error: 1 unsaved buffer(s) remaining: ["~/Yes/amogus/Cargo.toml"] 2023-01-25T09:27:26.056 helix_view::editor [ERROR] Failed to initialize the LSP for `source.toml` { cannot find binary path } 2023-01-25T14:58:54.620 helix_view::editor [ERROR] Failed to initialize the LSP for `source.bash` { cannot find binary path } 2023-01-25T14:59:51.534 helix_view::editor [ERROR] Failed to initialize the LSP for `source.bash` { cannot find binary path } 2023-01-25T15:00:44.700 helix_view::editor [ERROR] Failed to initialize the LSP for `source.bash` { cannot find binary path } 2023-01-25T15:13:24.096 helix_view::editor [ERROR] Failed to initialize the LSP for `source.bash` { cannot find binary path } 2023-01-25T15:52:11.248 helix_view::editor [ERROR] Failed to initialize the LSP for `source.lua` { cannot find binary path } 2023-01-25T19:08:22.683 helix_view::editor [ERROR] Failed to initialize the LSP for `source.lua` { cannot find binary path } 2023-01-25T19:12:48.562 helix_view::editor [ERROR] editor error: Can't save with no path set! 2023-01-25T19:12:50.972 helix_view::editor [ERROR] editor error: Can't save with no path set! 2023-01-25T19:47:37.910 helix_view::editor [ERROR] Failed to initialize the LSP for `source.lua` { cannot find binary path } 2023-01-25T19:59:56.660 helix_view::editor [ERROR] Failed to initialize the LSP for `source.toml` { cannot find binary path } 2023-01-25T20:15:03.470 helix_view::editor [ERROR] Failed to initialize the LSP for `source.toml` { cannot find binary path } 2023-01-25T20:16:03.978 helix_view::editor [ERROR] editor error: failed to load theme `base16_terminal_edit` - Failed to deserialize theme 2023-01-25T20:16:07.695 helix_view::editor [ERROR] editor error: failed to load theme `base16_terminal_edit` - Failed to deserialize theme 2023-01-25T20:16:10.341 helix_view::editor [ERROR] editor error: failed to load theme `base16_terminal_edit` - Failed to deserialize theme 2023-01-25T20:16:21.879 helix_view::editor [ERROR] editor error: failed to load theme `base16_terminal_edit` - Failed to deserialize theme 2023-01-25T20:20:32.049 helix_view::editor [ERROR] editor error: 1 unsaved buffer(s) remaining: ["[scratch]"] 2023-01-25T20:26:12.970 helix_view::editor [ERROR] editor error: 1 unsaved buffer(s) remaining: ["[scratch]"] 2023-01-25T20:30:30.145 helix_lsp::transport [ERROR] err <- "[ERROR rust_analyzer] failed to find any projects in [AbsPathBuf(\"/home/imsuck\")]\n" 2023-01-25T20:30:30.276 helix_lsp::transport [ERROR] err <- "[ERROR rust_analyzer::lsp_utils] rust-analyzer failed to discover workspace\n" 2023-01-25T20:30:30.292 helix_term::application [WARN] unhandled window/showMessage: ShowMessageParams { typ: Error, message: "rust-analyzer failed to discover workspace" } 2023-01-25T20:30:30.318 helix_lsp::transport [ERROR] err <- "[ERROR rust_analyzer::lsp_utils] rust-analyzer failed to discover workspace\n" 2023-01-25T20:30:30.319 helix_term::application [WARN] unhandled window/showMessage: ShowMessageParams { typ: Error, message: "rust-analyzer failed to discover workspace" } 2023-01-25T20:30:37.649 helix_lsp::transport [ERROR] err: <- StreamClosed 2023-01-25T20:30:37.649 helix_lsp::transport [ERROR] err: <- Other(failed to send a message to server Caused by: channel closed) 2023-01-25T20:30:59.258 helix_lsp::transport [ERROR] err <- "[ERROR rust_analyzer] failed to find any projects in [AbsPathBuf(\"/home/imsuck\")]\n" 2023-01-25T20:30:59.259 helix_lsp::transport [ERROR] err <- "[ERROR rust_analyzer::lsp_utils] rust-analyzer failed to discover workspace\n" 2023-01-25T20:30:59.259 helix_term::application [WARN] unhandled window/showMessage: ShowMessageParams { typ: Error, message: "rust-analyzer failed to discover workspace" } 2023-01-25T20:30:59.260 helix_lsp::transport [ERROR] err <- "[ERROR rust_analyzer::lsp_utils] rust-analyzer failed to discover workspace\n" 2023-01-25T20:30:59.260 helix_term::application [WARN] unhandled window/showMessage: ShowMessageParams { typ: Error, message: "rust-analyzer failed to discover workspace" } 2023-01-25T20:31:04.467 helix_lsp::transport [ERROR] err: <- Other(failed to send a message to server Caused by: channel closed) 2023-01-25T20:31:04.468 helix_lsp::transport [ERROR] err: <- StreamClosed 2023-01-25T20:32:50.770 helix_lsp::transport [ERROR] err <- "[ERROR rust_analyzer] failed to find any projects in [AbsPathBuf(\"/home/imsuck\")]\n" 2023-01-25T20:32:50.771 helix_lsp::transport [ERROR] err <- "[ERROR rust_analyzer::lsp_utils] rust-analyzer failed to discover workspace\n" 2023-01-25T20:32:50.771 helix_term::application [WARN] unhandled window/showMessage: ShowMessageParams { typ: Error, message: "rust-analyzer failed to discover workspace" } 2023-01-25T20:32:50.773 helix_lsp::transport [ERROR] err <- "[ERROR rust_analyzer::lsp_utils] rust-analyzer failed to discover workspace\n" 2023-01-25T20:32:50.773 helix_term::application [WARN] unhandled window/showMessage: ShowMessageParams { typ: Error, message: "rust-analyzer failed to discover workspace" } 2023-01-25T20:33:30.177 helix_view::theme [WARN] Theme: malformed hexcode: none 2023-01-25T20:33:43.211 helix_view::theme [WARN] Theme: malformed hexcode: 2023-01-25T20:33:45.180 helix_lsp::transport [ERROR] err: <- Other(failed to send a message to server Caused by: channel closed) 2023-01-25T20:33:45.180 helix_lsp::transport [ERROR] err: <- StreamClosed 2023-01-25T20:33:46.475 helix_view::theme [WARN] Theme: malformed hexcode: 2023-01-25T20:33:46.573 helix_lsp::transport [ERROR] err <- "[ERROR rust_analyzer] failed to find any projects in [AbsPathBuf(\"/home/imsuck\")]\n" 2023-01-25T20:33:46.575 helix_lsp::transport [ERROR] err <- "[ERROR rust_analyzer::lsp_utils] rust-analyzer failed to discover workspace\n" 2023-01-25T20:33:46.575 helix_term::application [WARN] unhandled window/showMessage: ShowMessageParams { typ: Error, message: "rust-analyzer failed to discover workspace" } 2023-01-25T20:33:46.575 helix_lsp::transport [ERROR] err <- "[ERROR rust_analyzer::lsp_utils] rust-analyzer failed to discover workspace\n" 2023-01-25T20:33:46.575 helix_term::application [WARN] unhandled window/showMessage: ShowMessageParams { typ: Error, message: "rust-analyzer failed to discover workspace" } 2023-01-25T20:33:49.213 helix_lsp::transport [ERROR] err: <- Other(failed to send a message to server Caused by: channel closed) 2023-01-25T20:33:49.213 helix_lsp::transport [ERROR] err: <- StreamClosed 2023-01-25T20:33:50.187 helix_view::theme [WARN] Theme: malformed hexcode: 2023-01-25T20:33:50.286 helix_lsp::transport [ERROR] err <- "[ERROR rust_analyzer] failed to find any projects in [AbsPathBuf(\"/home/imsuck\")]\n" 2023-01-25T20:33:50.287 helix_lsp::transport [ERROR] err <- "[ERROR rust_analyzer::lsp_utils] rust-analyzer failed to discover workspace\n" 2023-01-25T20:33:50.287 helix_term::application [WARN] unhandled window/showMessage: ShowMessageParams { typ: Error, message: "rust-analyzer failed to discover workspace" } 2023-01-25T20:33:50.287 helix_lsp::transport [ERROR] err <- "[ERROR rust_analyzer::lsp_utils] rust-analyzer failed to discover workspace\n" 2023-01-25T20:33:50.287 helix_term::application [WARN] unhandled window/showMessage: ShowMessageParams { typ: Error, message: "rust-analyzer failed to discover workspace" } 2023-01-25T20:33:51.067 helix_view::theme [WARN] Theme: malformed hexcode: 2023-01-25T20:33:51.751 helix_lsp::transport [ERROR] err: <- StreamClosed 2023-01-25T20:33:51.751 helix_lsp::transport [ERROR] err: <- Other(failed to send a message to server Caused by: channel closed) 2023-01-25T20:34:03.328 helix_lsp::transport [ERROR] err <- "[ERROR rust_analyzer] failed to find any projects in [AbsPathBuf(\"/home/imsuck\")]\n" 2023-01-25T20:34:03.331 helix_lsp::transport [ERROR] err <- "[ERROR rust_analyzer::lsp_utils] rust-analyzer failed to discover workspace\n" 2023-01-25T20:34:03.333 helix_term::application [WARN] unhandled window/showMessage: ShowMessageParams { typ: Error, message: "rust-analyzer failed to discover workspace" } 2023-01-25T20:34:03.333 helix_lsp::transport [ERROR] err <- "[ERROR rust_analyzer::lsp_utils] rust-analyzer failed to discover workspace\n" 2023-01-25T20:34:03.333 helix_term::application [WARN] unhandled window/showMessage: ShowMessageParams { typ: Error, message: "rust-analyzer failed to discover workspace" } 2023-01-25T20:36:46.787 helix_view::editor [ERROR] Failed to initialize the LSP for `source.toml` { cannot find binary path } 2023-01-25T20:37:15.981 helix_view::editor [ERROR] editor error: Invalid theme: `ui.selection` required 2023-01-25T20:37:16.407 helix_view::editor [ERROR] editor error: Invalid theme: `ui.selection` required 2023-01-25T20:39:10.251 helix_lsp::transport [ERROR] err <- "[ERROR rust_analyzer] failed to find any projects in [AbsPathBuf(\"/home/imsuck\")]\n" 2023-01-25T20:39:10.253 helix_lsp::transport [ERROR] err <- "[ERROR rust_analyzer::lsp_utils] rust-analyzer failed to discover workspace\n" 2023-01-25T20:39:10.253 helix_term::application [WARN] unhandled window/showMessage: ShowMessageParams { typ: Error, message: "rust-analyzer failed to discover workspace" } 2023-01-25T20:39:10.253 helix_lsp::transport [ERROR] err <- "[ERROR rust_analyzer::lsp_utils] rust-analyzer failed to discover workspace\n" 2023-01-25T20:39:10.253 helix_term::application [WARN] unhandled window/showMessage: ShowMessageParams { typ: Error, message: "rust-analyzer failed to discover workspace" } 2023-01-25T20:41:08.853 helix_lsp::transport [ERROR] err <- "[ERROR rust_analyzer] failed to find any projects in [AbsPathBuf(\"/home/imsuck\")]\n" 2023-01-25T20:41:08.854 helix_lsp::transport [ERROR] err <- "[ERROR rust_analyzer::lsp_utils] rust-analyzer failed to discover workspace\n" 2023-01-25T20:41:08.854 helix_lsp::transport [ERROR] err <- "[ERROR rust_analyzer::lsp_utils] rust-analyzer failed to discover workspace\n" 2023-01-25T20:41:08.854 helix_term::application [WARN] unhandled window/showMessage: ShowMessageParams { typ: Error, message: "rust-analyzer failed to discover workspace" } 2023-01-25T20:41:08.855 helix_term::application [WARN] unhandled window/showMessage: ShowMessageParams { typ: Error, message: "rust-analyzer failed to discover workspace" } 2023-01-25T20:41:11.061 helix_lsp::transport [ERROR] err: <- Other(failed to send a message to server Caused by: channel closed) 2023-01-25T20:41:11.061 helix_lsp::transport [ERROR] err: <- StreamClosed ```
### Platform Linux ### Terminal Emulator wezterm 20221119-145034-49b9839f ### Helix Version helix 22.12
archseer commented 1 year ago

This is because you're using the reversed modifier on the cursor.

imsuck commented 1 year ago

But why aren't they working like other characters?

the-mikedavis commented 1 year ago

Oh I see, this is happening because whitespace and indent guides are rendered on top of highlights like cursor colors in the rendering code. So the ui.cursor fg color is overridden by the ui.virtual.whitespace fg color.

imsuck commented 1 year ago

I'm not sure if this is related but rulers also act weirdly.

https://user-images.githubusercontent.com/49095435/218452138-e21fb736-671b-4805-bb13-5175cf347fe8.mp4

chtenb commented 1 year ago

What causes the ui.virtual.whitespace to have a higher precedence than the ui.cursor scope? If it's not too involved, I could attempt a PR fix.

Tudyx commented 1 year ago

This is even more problematic if you set the indent guide and the cursor to . If you are in insert mode and at the place of an indentation guidelines, the cursor became invisible.

[editor.cursor-shape]
insert = "bar"

[editor.indent-guides]
render = true
character = "▏"

Here the cursor at the begin of the statement

Screenshot from 2023-10-09 23-37-44

Here is the cursor at the level of the indent guide at the left:

Screenshot from 2023-10-09 23-35-29

the-mikedavis commented 12 months ago

Continued in https://github.com/helix-editor/helix/issues/8909 (indent guides) and https://github.com/helix-editor/helix/issues/7371 (rulers). The whitespace case was fixed in https://github.com/helix-editor/helix/pull/8879