Repository navigation
fix(powerline): keep separator inversion list dense when editing - #673
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
The separator editor wrote `separatorInvertBackground[i]` straight into a copy of the saved list. That list is often shorter than the separators: its schema default is `[false]`, and hand-edited or imported configs commonly add separators without extending it. Toggling (t) or cycling (left/right) a separator past the end of the list left holes in the array, which JSON saves as `null`. With three separators and the default list, selecting the third and pressing `t` saved `[false, null, true]`; the next load failed validation, so both the TUI and the status line fell back to defaults with the invalid-config warning. Pad the list to one entry per separator, defaulting to false, before any edit. Missing entries already rendered as not inverted, so nothing changes visually; add, insert and delete now also work on aligned entries.
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
Editing a Powerline separator no longer saves a settings file that fails to load. Toggling inversion (
t) or cycling the glyph (←/→) on a separator now always saves onetrue/falseper separator.Why
separatorInvertBackgroundis often shorter thanseparators: its schema default is[false], and hand-edited or imported configs usually add separators without extending it. The separator editor wrote the selected index straight into a copy of that list, so editing any separator past its end left a hole, which JSON saves asnull.With three separators and the default list: Powerline Setup → Separator, ↓ ↓,
t(or →), ctrl+s. The file then holdsand the next load fails validation (
powerline.separatorInvertBackground.1: Invalid input: expected boolean, received null). Both the TUI and the status line fall back to the default settings, and the status line starts with⚠ invalid config. The file is left as is, so it stays broken until edited by hand.How
The editor pads the list to one entry per separator, filling missing entries with
false, before any edit. Every edit path (toggle, cycle, add, insert, delete) then works on aligned entries, and the saved list always matches the separators in length.A missing entry already rendered as not inverted (the renderer reads
invertBgs[i] ?? falseand only for indexes below the separator count), so nothing changes on screen. Start and end cap editing doesn't touch the list. Entries beyond the last separator, which the renderer never reads, are dropped on the next edit, as the hex-input path already did.Demo
Three separators with the default one-entry inversion list: toggle inversion on the third separator, save, then render the status line from the saved file (sample data). Powerline only: the separator editor is disabled in plain mode, so plain mode can't reach this.
Powerline: before
Powerline: after
Testing
PowerlineSetup.test.ts: three separators withseparatorInvertBackground: [false], ↓ ↓, thentand → as separate cases. Each expects[false, false, true], and that the saved JSON passes the settings schema. Both failed onmain([false, undefined, true]); looped 10 times, no failures.bun test: 2784 pass, 0 fail.bun run lintpasses.mainpasses its 6.mainsaves[false, null, true], and the relaunched TUI and the piped render both print the parse error and fall back to defaults. This branch saves[false, false, true], still[false, false, true]after a following → turns the third separator into Triangle Left, and both load it cleanly.