Add basic infrastructure for inlay hints map
This commit is contained in:
parent
6e3d1b962a
commit
2ead3de7de
6 changed files with 366 additions and 85 deletions
|
@ -1,5 +1,5 @@
|
|||
use super::{
|
||||
suggestion_map::SuggestionBufferRows,
|
||||
editor_addition_map::EditorAdditionBufferRows,
|
||||
tab_map::{self, TabEdit, TabPoint, TabSnapshot},
|
||||
TextHighlights,
|
||||
};
|
||||
|
@ -65,7 +65,7 @@ pub struct WrapChunks<'a> {
|
|||
|
||||
#[derive(Clone)]
|
||||
pub struct WrapBufferRows<'a> {
|
||||
input_buffer_rows: SuggestionBufferRows<'a>,
|
||||
input_buffer_rows: EditorAdditionBufferRows<'a>,
|
||||
input_buffer_row: Option<u32>,
|
||||
output_row: u32,
|
||||
soft_wrapped: bool,
|
||||
|
@ -762,19 +762,29 @@ impl WrapSnapshot {
|
|||
let mut prev_fold_row = 0;
|
||||
for display_row in 0..=self.max_point().row() {
|
||||
let tab_point = self.to_tab_point(WrapPoint::new(display_row, 0));
|
||||
let editor_addition_point = self
|
||||
.tab_snapshot
|
||||
.to_editor_addition_point(tab_point, Bias::Left)
|
||||
.0;
|
||||
let suggestion_point = self
|
||||
.tab_snapshot
|
||||
.to_suggestion_point(tab_point, Bias::Left)
|
||||
.0;
|
||||
.editor_addition_snapshot
|
||||
.to_suggestion_point(editor_addition_point, Bias::Left);
|
||||
let fold_point = self
|
||||
.tab_snapshot
|
||||
.editor_addition_snapshot
|
||||
.suggestion_snapshot
|
||||
.to_fold_point(suggestion_point);
|
||||
if fold_point.row() == prev_fold_row && display_row != 0 {
|
||||
expected_buffer_rows.push(None);
|
||||
} else {
|
||||
let buffer_point = fold_point
|
||||
.to_buffer_point(&self.tab_snapshot.suggestion_snapshot.fold_snapshot);
|
||||
let buffer_point = fold_point.to_buffer_point(
|
||||
&self
|
||||
.tab_snapshot
|
||||
.editor_addition_snapshot
|
||||
.suggestion_snapshot
|
||||
.fold_snapshot,
|
||||
);
|
||||
expected_buffer_rows.push(input_buffer_rows[buffer_point.row as usize]);
|
||||
prev_fold_row = fold_point.row();
|
||||
}
|
||||
|
@ -1038,7 +1048,10 @@ fn consolidate_wrap_edits(edits: &mut Vec<WrapEdit>) {
|
|||
mod tests {
|
||||
use super::*;
|
||||
use crate::{
|
||||
display_map::{fold_map::FoldMap, suggestion_map::SuggestionMap, tab_map::TabMap},
|
||||
display_map::{
|
||||
editor_addition_map::EditorAdditionMap, fold_map::FoldMap,
|
||||
suggestion_map::SuggestionMap, tab_map::TabMap,
|
||||
},
|
||||
MultiBuffer,
|
||||
};
|
||||
use gpui::test::observe;
|
||||
|
@ -1093,7 +1106,13 @@ mod tests {
|
|||
log::info!("FoldMap text: {:?}", fold_snapshot.text());
|
||||
let (suggestion_map, suggestion_snapshot) = SuggestionMap::new(fold_snapshot.clone());
|
||||
log::info!("SuggestionMap text: {:?}", suggestion_snapshot.text());
|
||||
let (tab_map, _) = TabMap::new(suggestion_snapshot.clone(), tab_size);
|
||||
let (editor_addition_map, editors_additions_snapshot) =
|
||||
EditorAdditionMap::new(suggestion_snapshot.clone());
|
||||
log::info!(
|
||||
"EditorAdditionsMap text: {:?}",
|
||||
editors_additions_snapshot.text()
|
||||
);
|
||||
let (tab_map, _) = TabMap::new(editors_additions_snapshot.clone(), tab_size);
|
||||
let tabs_snapshot = tab_map.set_max_expansion_column(32);
|
||||
log::info!("TabMap text: {:?}", tabs_snapshot.text());
|
||||
|
||||
|
@ -1141,8 +1160,10 @@ mod tests {
|
|||
for (fold_snapshot, fold_edits) in fold_map.randomly_mutate(&mut rng) {
|
||||
let (suggestion_snapshot, suggestion_edits) =
|
||||
suggestion_map.sync(fold_snapshot, fold_edits);
|
||||
let (editor_addition_snapshot, editor_addition_edits) =
|
||||
editor_addition_map.sync(suggestion_snapshot, suggestion_edits);
|
||||
let (tabs_snapshot, tab_edits) =
|
||||
tab_map.sync(suggestion_snapshot, suggestion_edits, tab_size);
|
||||
tab_map.sync(editor_addition_snapshot, editor_addition_edits, tab_size);
|
||||
let (mut snapshot, wrap_edits) =
|
||||
wrap_map.update(cx, |map, cx| map.sync(tabs_snapshot, tab_edits, cx));
|
||||
snapshot.check_invariants();
|
||||
|
@ -1153,8 +1174,10 @@ mod tests {
|
|||
40..=59 => {
|
||||
let (suggestion_snapshot, suggestion_edits) =
|
||||
suggestion_map.randomly_mutate(&mut rng);
|
||||
let (editor_addition_snapshot, editor_addition_edits) =
|
||||
editor_addition_map.sync(suggestion_snapshot, suggestion_edits);
|
||||
let (tabs_snapshot, tab_edits) =
|
||||
tab_map.sync(suggestion_snapshot, suggestion_edits, tab_size);
|
||||
tab_map.sync(editor_addition_snapshot, editor_addition_edits, tab_size);
|
||||
let (mut snapshot, wrap_edits) =
|
||||
wrap_map.update(cx, |map, cx| map.sync(tabs_snapshot, tab_edits, cx));
|
||||
snapshot.check_invariants();
|
||||
|
@ -1178,8 +1201,10 @@ mod tests {
|
|||
let (suggestion_snapshot, suggestion_edits) =
|
||||
suggestion_map.sync(fold_snapshot, fold_edits);
|
||||
log::info!("SuggestionMap text: {:?}", suggestion_snapshot.text());
|
||||
let (editor_addition_snapshot, editor_addition_edits) =
|
||||
editor_addition_map.sync(suggestion_snapshot, suggestion_edits);
|
||||
let (tabs_snapshot, tab_edits) =
|
||||
tab_map.sync(suggestion_snapshot, suggestion_edits, tab_size);
|
||||
tab_map.sync(editor_addition_snapshot, editor_addition_edits, tab_size);
|
||||
log::info!("TabMap text: {:?}", tabs_snapshot.text());
|
||||
|
||||
let unwrapped_text = tabs_snapshot.text();
|
||||
|
@ -1227,7 +1252,7 @@ mod tests {
|
|||
if tab_size.get() == 1
|
||||
|| !wrapped_snapshot
|
||||
.tab_snapshot
|
||||
.suggestion_snapshot
|
||||
.editor_addition_snapshot
|
||||
.text()
|
||||
.contains('\t')
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue