WT resets palette on input language change #23706

Closed
opened 2026-01-31 08:49:53 +00:00 by claunia · 6 comments
Owner

Originally created by @alabuzhev on GitHub (Oct 15, 2025).

Windows Terminal version

1.25.251014001-llm

Windows build number

10.0.19045.6332

Other Software

No response

Steps to reproduce

  1. Add any extra language or keyboard layout to your system.
  2. Rename the attached file (pal.cmd.txt) to *.cmd or *.bat
  3. Run it in WT
  4. You should see the default palette (e.g. campbell)
  5. Press any key
  6. You should see the reversed vintage palette
  7. Switch the input language or the keyboard layout (Ctrl+Shift or Alt+Shift or Win+Space etc.)

Expected Behavior

Nothing. Why would anything happen, right?
Except for the language or the layout change obviously.

Actual Behavior

The palette resets back to the default (e.g. campbell)
What the... How the... Why?

https://github.com/user-attachments/assets/dd322885-6a9b-4c59-8b13-d52787cb11ff

It does not happen in openconsole.

Also, it is interesting that in openconsole changing the palette affects the whole buffer:

Image

But it does not happen in WT. No idea if that is also a bug or by design.

Originally created by @alabuzhev on GitHub (Oct 15, 2025). ### Windows Terminal version 1.25.251014001-llm ### Windows build number 10.0.19045.6332 ### Other Software _No response_ ### Steps to reproduce 0. Add any extra language or keyboard layout to your system. 1. Rename the attached file ([pal.cmd.txt](https://github.com/user-attachments/files/22933930/pal.cmd.txt)) to *.cmd or *.bat 2. Run it in WT 3. You should see the default palette (e.g. campbell) 4. Press any key 5. You should see the reversed vintage palette 6. Switch the input language or the keyboard layout (Ctrl+Shift or Alt+Shift or Win+Space etc.) ### Expected Behavior Nothing. Why would anything happen, right? Except for the language or the layout change obviously. ### Actual Behavior The palette resets back to the default (e.g. campbell) What the... How the... Why? https://github.com/user-attachments/assets/dd322885-6a9b-4c59-8b13-d52787cb11ff It does not happen in openconsole. Also, it is interesting that in openconsole changing the palette affects the whole buffer: <img width="653" height="245" alt="Image" src="https://github.com/user-attachments/assets/dc2a1b0a-ed84-4a91-b8fc-6a235384f1d6" /> But it does not happen in WT. No idea if that is also a bug or by design.
claunia added the Needs-TriageIssue-Bug labels 2026-01-31 08:49:54 +00:00
Author
Owner

@lhecker commented on GitHub (Oct 16, 2025):

Why?

For what it's worth, we reload the settings because keybindings are layout specific. This then triggers a reset of the selected theme. (It should not be doing that, to be clear.)

@lhecker commented on GitHub (Oct 16, 2025): > Why? For what it's worth, we reload the settings because keybindings are layout specific. This then triggers a reset of the selected theme. (It should not be doing that, to be clear.)
Author
Owner

@alabuzhev commented on GitHub (Oct 16, 2025):

Thanks for the explanaiton.

we reload the settings because keybindings are layout specific

Oh that's interesting. May I ask why?
Indeed, a key like / can come from VK_OEM_2 or Shift+VK_OEM_5 or who knows what else depending on the layout, but who cares?
Or are you trying to resolve that back to the physical key combos in the current layout that would have produced that key if pressed and show that in the UI? It feels like it might have funny consequences and is not bug-free by definition, but I'll probably describe that in a different issue.

Also, keybindings are layout specific, but the config isn't, why do you need to reload it?
The actions look like trivial key-value pairs in json, why not just keep those config-specific key names like ctrl+comma in memory? It's not like the users will have millions of actions for it to have any measurable impact.

In some situations the user might need to switch the layout every several seconds (imagine writing a piece of HTML in a non-Latin language, but with Latin tags etc.) Attaching disk IO, config parsing and UI updates to such events looks a bit excessive.

@alabuzhev commented on GitHub (Oct 16, 2025): Thanks for the explanaiton. > we reload the settings because keybindings are layout specific Oh that's interesting. May I ask why? Indeed, a key like `/` can come from VK_OEM_2 or Shift+VK_OEM_5 or who knows what else depending on the layout, but who cares? Or are you trying to resolve that back to the physical key combos in the current layout that would have produced that key if pressed and show _that_ in the UI? It feels like it might have funny consequences and is not bug-free by definition, but I'll probably describe that in a different issue. Also, keybindings are layout specific, but the config isn't, why do you need to reload it? The actions look like trivial key-value pairs in json, why not just keep those config-specific key names like `ctrl+comma` in memory? It's not like the users will have millions of actions for it to have any measurable impact. In some situations the user might need to switch the layout every several seconds (imagine writing a piece of HTML in a non-Latin language, but with Latin tags etc.) Attaching disk IO, config parsing and UI updates to such events looks a bit excessive.
Author
Owner

@lhecker commented on GitHub (Oct 16, 2025):

Oh that's interesting. May I ask why?

Initially because of the Quake-mode keybinding. It's bound to a scancode (whatever key is below Esc) but the RegisterHotKey API takes a vkey. So, we need to map the scancode to a vkey after loading settings and update it whenever the layout changes.

Also, keybindings are layout specific, but the config isn't, why do you need to reload it?

It was the easiest solution. 🙈 Keybindings with their assigned actions get put into various hashmaps and there's a lot of spaghetti code between the settings load and those hashmaps. The intention has been for a while to fix that and do exactly what you suggest.

@lhecker commented on GitHub (Oct 16, 2025): > Oh that's interesting. May I ask why? Initially because of the Quake-mode keybinding. It's bound to a scancode (whatever key is below Esc) but the `RegisterHotKey` API takes a vkey. So, we need to map the scancode to a vkey after loading settings and update it whenever the layout changes. > Also, keybindings are layout specific, but the config isn't, why do you need to reload it? It was the easiest solution. 🙈 Keybindings with their assigned actions get put into various hashmaps and there's a lot of spaghetti code between the settings load and those hashmaps. The intention has been for a while to fix that and do exactly what you suggest.
Author
Owner

@alabuzhev commented on GitHub (Oct 16, 2025):

It feels like it might have funny consequences and is not bug-free by definition, but I'll probably describe that in a different issue.

It can get funny indeed. Described in #19464.

@alabuzhev commented on GitHub (Oct 16, 2025): > It feels like it might have funny consequences and is not bug-free by definition, but I'll probably describe that in a different issue. It can get funny indeed. Described in #19464.
Author
Owner

@j4james commented on GitHub (Oct 16, 2025):

FYI, this is a duplicate of #11522.

Also, it is interesting that in openconsole changing the palette affects the whole buffer:

@alabuzhev This is because the openconsole background color is mapped to palette entry 0 by default, so when you update that entry in your script, it affects the entire buffer. In Windows Terminal the default background color is a separate palette entry outside the basic ANSI range, and your script doesn't update that entry.

If you look at the Terminal tab in the openconsole settings properties dialog, there's a checkbox labelled Use Separate Background. If you check that option it should work the same way as Windows Terminal.

@j4james commented on GitHub (Oct 16, 2025): FYI, this is a duplicate of #11522. > Also, it is interesting that in openconsole changing the palette affects the whole buffer: @alabuzhev This is because the openconsole background color is mapped to palette entry 0 by default, so when you update that entry in your script, it affects the entire buffer. In Windows Terminal the default background color is a separate palette entry outside the basic ANSI range, and your script doesn't update that entry. If you look at the _Terminal_ tab in the openconsole settings properties dialog, there's a checkbox labelled _Use Separate Background_. If you check that option it should work the same way as Windows Terminal.
Author
Owner

@DHowett commented on GitHub (Oct 22, 2025):

Indeed! I'm gonna merge this one over there. Sorry/thanks!

@DHowett commented on GitHub (Oct 22, 2025): Indeed! I'm gonna merge this one over there. Sorry/thanks!
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/terminal#23706