fix: pad LSP indicators in both bars
This commit is contained in:
@@ -154,7 +154,7 @@ Each segment's `title` is a literal template supporting only `{index}`, `{view}`
|
||||
|
||||
`margin` adds unstyled space outside both edges of a segment, unlike the styled internal `padding`. `leading_margin` and `trailing_margin` override their respective sides. All accept integers from `0` through `64`; all margins default to zero. Explicit margins are additional to the renderer's one-column separator, so leave them at zero for normal inter-item spacing. Margins count toward anchor placement and collision handling; empty segments consume no margin, and margins yield along with padding and edges when only clipped content fits.
|
||||
|
||||
`padding` adds spaces inside the segment's styling, on both sides of its title, and accepts integers from `0` through `64`. It defaults to `0` for plain-text and custom segments and `1` for tabs, mode, position, battery, diff totals, and shell status. Internal padding is separate from the inter-item separator; explicit padding can deliberately add more whitespace. `leading_edge` and `trailing_edge` are separate styled glyph strings, not padding; `""` removes an edge. Tabs, diff totals, and shell status default to `"░▓"` / `"▓░"` edges; mode has only the trailing `"▓░"` edge, position and battery only the leading `"░▓"` edge, and other segments have none. `first_leading_edge` optionally overrides the first occurrence's leading glyphs: for tabs this is the actual first tab, not the first tab remaining after clipping; other segments have one occurrence. Tabs default this override to `""`, suppressing the first tab's left fade. Unicode widths are measured in terminal cells. Edge strings must be single-line and contain no control characters. Unknown style keys, invalid templates, and wrong types reject configuration.
|
||||
`padding` adds spaces inside the segment's styling, on both sides of its title, and accepts integers from `0` through `64`. It defaults to `0` for plain-text and custom segments and `1` for tabs, mode, position, battery, diff totals, shell status, and LSP indicators. Internal padding is separate from the inter-item separator; explicit padding can deliberately add more whitespace. `leading_edge` and `trailing_edge` are separate styled glyph strings, not padding; `""` removes an edge. Tabs, diff totals, and shell status default to `"░▓"` / `"▓░"` edges; mode has only the trailing `"▓░"` edge, position and battery only the leading `"░▓"` edge, and other segments have none. `first_leading_edge` optionally overrides the first occurrence's leading glyphs: for tabs this is the actual first tab, not the first tab remaining after clipping; other segments have one occurrence. Tabs default this override to `""`, suppressing the first tab's left fade. Unicode widths are measured in terminal cells. Edge strings must be single-line and contain no control characters. Unknown style keys, invalid templates, and wrong types reject configuration.
|
||||
|
||||
Any other segment name is a custom named value, such as `:build_status`. Set initial strings with `config.labels`; an empty value hides the custom segment, including its title override, margins, padding, and edges. Names match `[A-Za-z_][A-Za-z0-9_]*`. Labels are plain text: control characters are replaced rather than interpreted as terminal escapes. The same named value can appear in either bar.
|
||||
|
||||
|
||||
+1
-1
@@ -203,7 +203,7 @@ fn default_segment(name: &str) -> SegmentConfig {
|
||||
}
|
||||
if matches!(
|
||||
name,
|
||||
"tabs" | "mode" | "position" | "battery" | "shell" | "diff"
|
||||
"tabs" | "mode" | "position" | "battery" | "shell" | "diff" | "lsp"
|
||||
) {
|
||||
segment.padding = 1;
|
||||
}
|
||||
|
||||
@@ -4949,6 +4949,17 @@ fn native_lsp_names_are_borrowed_in_either_bar_and_ignore_configured_labels() {
|
||||
groups[0][0].text,
|
||||
Cow::Borrowed("server one + server two")
|
||||
));
|
||||
let mut terminal = Terminal::new(ratatui::backend::TestBackend::new(25, 1)).unwrap();
|
||||
terminal
|
||||
.draw(|frame| draw_chrome(frame, groups, Rect::new(0, 0, 25, 1)))
|
||||
.unwrap();
|
||||
assert_eq!(
|
||||
pane_screen(&terminal, Rect::new(0, 0, 25, 1)),
|
||||
" server one + server two "
|
||||
);
|
||||
for x in [0, 24] {
|
||||
assert_eq!(terminal.backend().buffer()[(x, 0)].bg, Color::Cyan);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4961,6 +4972,7 @@ fn chrome_separates_visible_segments_once_in_every_anchor() {
|
||||
line.left.clear();
|
||||
line.center.clear();
|
||||
line.right.clear();
|
||||
line.segments.entry("lsp".into()).or_default().padding = 0;
|
||||
let names = vec![
|
||||
"before".into(),
|
||||
"lsp".into(),
|
||||
|
||||
Reference in New Issue
Block a user