Repository: alacritty/alacritty (language: rust)

Issue:
Incorrect cursor color when using default cursor config (OSC12)
Using the default config, i.e. `cursor = { text = "CellBackground", cursor = "CellForeground" }`, querying the cursor color returns invalid color.

<img width="236" alt="image" src="https://github.com/user-attachments/assets/348cd747-04ac-4790-be90-f6f16726bd94">

Should return the appropriate color using the `CellForeground` color value `^[]12;rgb:acf1/b277/be84^G`

### System

OS: macOS
Version: alacritty 0.13.2 (bb8ea18)




Discussion / hints:
There's no point in returning the current cell color, why do you want this?
> There's no point in returning the current cell color, why do you want this?

I mean, what's the point of implementing OSC12 then? I respectfully disagree, I think it's important to _know_ what is the current set cursor color.

In my case, I'm writing programs that change the terminal colors and want to be able to restore them _after_ a program exits. This means when a program starts, it queries the terminal and store the fg/bg/cursor colors, then on exit, it resets these colors if they were changed.
> I mean, what's the point of implementing OSC12 then?

It's only useful for static colors. Arguably for the cursor it's not really that useful at all, since it usually isn't static.

> In my case, I'm writing programs that change the terminal colors and want to be able to restore them after a program exits. This means when a program starts, it queries the terminal and store the fg/bg/cursor colors, then on exit, it resets these colors if they were changed.

See, this would behave **incorrectly**, so if anything that's an argument for not changing the behavior since this issue report just caught a bug in your application.
> See, this would behave incorrectly, so if anything that's an argument for not changing the behavior since this issue report just caught a bug in your application.

I don't think this is an issue in my application. Alacritty is reporting the _wrong_ color. Visually, I have a gray cursor. Alacritty reports that the cursor color is black `#000000` or `rgb:0000/0000/0000` as seen in the image above.

I switched to using `OSC 112` in my application instead. However, I still believe that Alacritty _should_ return the cursor configured color instead of `#000000` black.

I will leave this open as I believe this is a bug and OSC12 should behave the same as OSC10 and OSC11 for foreground and background colors.

Fix patch:
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 20df64f0dc1..38584ca5d06 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -37,6 +37,7 @@ Notable changes to the `alacritty_terminal` crate are documented in its
 - Kitty keyboard protocol reporting shifted key codes
 - Broken search with words broken across line boundary on the first character
 - Config import changes not being live reloaded
+- Cursor color requests with default cursor colors
 
 ## 0.13.2
 
diff --git a/alacritty/src/event.rs b/alacritty/src/event.rs
index 72009d88875..f10346af540 100644
--- a/alacritty/src/event.rs
+++ b/alacritty/src/event.rs
@@ -34,6 +34,7 @@ use alacritty_terminal::index::{Boundary, Column, Direction, Line, Point, Side};
 use alacritty_terminal::selection::{Selection, SelectionType};
 use alacritty_terminal::term::search::{Match, RegexSearch};
 use alacritty_terminal::term::{self, ClipboardType, Term, TermMode};
+use alacritty_terminal::vte::ansi::NamedColor;
 
 #[cfg(unix)]
 use crate::cli::{IpcConfig, ParsedOptions};
@@ -1737,9 +1738,12 @@ impl input::Processor<EventProxy, ActionContext<'_, Notifier, EventProxy>> {
                         }
                     },
                     TerminalEvent::ColorRequest(index, format) => {
-                        let color = self.ctx.terminal().colors()[index]
-                            .map(Rgb)
-                            .unwrap_or(self.ctx.display.colors[index]);
+                        let color = match self.ctx.terminal().colors()[index] {
+                            Some(color) => Rgb(color),
+                            // Ignore cursor color requests unless it was changed.
+                            None if index == NamedColor::Cursor as usize => return,
+                            None => self.ctx.display.colors[index],
+                        };
                         self.ctx.write_to_pty(format(color.0).into_bytes());
                     },
                     TerminalEvent::TextAreaSizeRequest(format) => {


Test patch: