Skip to content

Commit d120a35

Browse files
committed
feat: use padding for color swatches
1 parent ca5c96b commit d120a35

File tree

3 files changed

+12
-7
lines changed

3 files changed

+12
-7
lines changed

helix-term/src/commands/lsp.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1479,7 +1479,7 @@ fn compute_color_swatches_for_view(
14791479
swatches.sort_by_key(|inlay_hint| inlay_hint.range.start);
14801480

14811481
let mut color_swatches = Vec::with_capacity(swatches.len());
1482-
// let mut color_swatches_padding = Vec::with_capacity(swatches.len());
1482+
let mut color_swatches_padding = Vec::with_capacity(swatches.len());
14831483
let mut colors = Vec::with_capacity(swatches.len());
14841484

14851485
let doc_text = doc.text();
@@ -1492,7 +1492,8 @@ fn compute_color_swatches_for_view(
14921492
continue;
14931493
};
14941494

1495-
color_swatches.push(InlineAnnotation::new(swatch_index, "■ "));
1495+
color_swatches.push(InlineAnnotation::new(swatch_index, "■"));
1496+
color_swatches_padding.push(InlineAnnotation::new(swatch_index, " "));
14961497
colors.push(Color::Rgb(
14971498
(swatch.color.red * 255.) as u8,
14981499
(swatch.color.green * 255.) as u8,
@@ -1506,6 +1507,7 @@ fn compute_color_swatches_for_view(
15061507
id: new_doc_color_swatches_id,
15071508
colors,
15081509
color_swatches,
1510+
color_swatches_padding,
15091511
},
15101512
);
15111513

helix-view/src/document.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -283,6 +283,7 @@ pub struct DocumentColorSwatches {
283283
pub id: ColorSwatchesId,
284284

285285
pub color_swatches: Vec<InlineAnnotation>,
286+
pub color_swatches_padding: Vec<InlineAnnotation>,
286287
pub colors: Vec<Color>,
287288
}
288289

@@ -292,6 +293,7 @@ impl DocumentColorSwatches {
292293
Self {
293294
id,
294295
color_swatches: Vec::new(),
296+
color_swatches_padding: Vec::new(),
295297
colors: Vec::new(),
296298
}
297299
}
@@ -1470,9 +1472,11 @@ impl Document {
14701472
id: _,
14711473
colors: _,
14721474
color_swatches,
1475+
color_swatches_padding,
14731476
} = text_annotation;
14741477

14751478
apply_inlay_hint_changes(color_swatches);
1479+
apply_inlay_hint_changes(color_swatches_padding);
14761480
}
14771481

14781482
helix_event::dispatch(DocumentDidChange {

helix-view/src/view.rs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -485,13 +485,12 @@ impl View {
485485
id: _,
486486
colors: _,
487487
color_swatches,
488+
color_swatches_padding,
488489
}) = doc.color_swatches.get(&self.id)
489490
{
490-
let type_style = theme
491-
.and_then(|t| t.find_scope_index("ui.background"))
492-
.map(Highlight);
493-
494-
text_annotations.add_inline_annotations(color_swatches, type_style);
491+
text_annotations
492+
.add_inline_annotations(color_swatches, None)
493+
.add_inline_annotations(color_swatches_padding, None);
495494
};
496495
let config = doc.config.load();
497496
let width = self.inner_width(doc);

0 commit comments

Comments
 (0)