Repository navigation
fix(powerline): customize a theme with the colors it showed - #677
Open
eric-engberg wants to merge 1 commit into
Open
eric-engberg wants to merge 1 commit into
eric-engberg wants to merge 1 commit into
Conversation
Customizing a Powerline theme (c in the theme list) copied the theme's colors onto the widgets by counting every widget in a line, restarting at the first color on each line. The renderer counts differently: a widget merged into the next one shares that group's color, and with Continue Theme on, each line picks up where the previous one stopped. So the copy could differ from what the theme had just shown. With Model merged into Context Length, the pair shared one background under the theme, but the copy gave Context Length the next color and shifted every widget after it; with Continue Theme on, every line after the first restarted at the first color. Number the widgets with the same slot rule the renderer uses to carry the theme across lines, now shared from powerline-theme-index, and continue the numbering across lines when Continue Theme is on. Lines without merges and with Continue Theme off get the same colors as before.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Customizing a Powerline theme (
cin Powerline Setup → Themes, then Yes) now copies the colors the theme was showing. Merged widgets keep their shared color, and with Continue Theme on, lines after the first keep the colors they had.Why
Customize numbered every widget in a line and restarted at the first theme color on each line. The renderer numbers them differently: a widget merged into the next one shares that group's color, and with Continue Theme on, each line picks up where the previous one stopped. So pressing Yes could recolor the line it was meant to freeze.
Nord Aurora at 256 colors, Model merged into Context Length on line 1, Git Changes and Version on line 2, Continue Theme on. Backgrounds in the preview:
cmain, after YesHow
powerline-theme-index.tsalready holds the rule the renderer uses to carry the theme index from one line to the next: a widget merged into the previous shown widget shares its slot, and separators break merges. That loop now returns each widget's slot as well as the count (assignPowerlineThemeSlots), andcountPowerlineThemeSlotsis a thin wrapper over it, so the status line and the preview count exactly as before. Customize numbers each line with it and starts each line where the previous one stopped when Continue Theme is on, or at 0 when it's off.Customize works from the settings, not from rendered output, so it treats every widget as shown. Lines without merges, with Continue Theme off, get the same colors as before, and separators are still left alone. The only widgets that render nothing in the preview are a Custom Text or Custom Symbol with no text, which still take a color in the copy, as before.
Demo
Nord Aurora with Model merged into Context Length and Continue Theme on (the preview's sample data): open Themes, press
c, choose Yes. Powerline only: themes only apply in Powerline mode, and the Themes entry is disabled in plain mode.Powerline: before
Powerline: after
Testing
PowerlineThemeSelector.test.tsrender each line from the theme and from the customized copy, carrying the theme index across lines as the status line does, and expect identical output: a merged group, Continue Theme on, and Continue Theme off. The first two failed onmain(the merged widget got 220 instead of 131, line 2 restarted at 131); the third passes on both.bun test: 2785 pass, 0 fail.bun run lintpasses.mainpasses its 10.mainthe preview backgrounds go from131 220 / 68 108to131 220 68 / 131 220after Yes; on this branch they stay131 220 / 68 108.