Get tests passing and project diagnostics view working w/ new excerpt headers
This commit is contained in:
parent
3d9c39d0eb
commit
5b4c0d64bc
6 changed files with 160 additions and 122 deletions
|
@ -68,7 +68,6 @@ struct ProjectDiagnosticsEditor {
|
||||||
|
|
||||||
struct PathState {
|
struct PathState {
|
||||||
path: ProjectPath,
|
path: ProjectPath,
|
||||||
header: Option<BlockId>,
|
|
||||||
diagnostic_groups: Vec<DiagnosticGroupState>,
|
diagnostic_groups: Vec<DiagnosticGroupState>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -258,7 +257,6 @@ impl ProjectDiagnosticsEditor {
|
||||||
ix,
|
ix,
|
||||||
PathState {
|
PathState {
|
||||||
path: path.clone(),
|
path: path.clone(),
|
||||||
header: None,
|
|
||||||
diagnostic_groups: Default::default(),
|
diagnostic_groups: Default::default(),
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
@ -365,14 +363,6 @@ impl ProjectDiagnosticsEditor {
|
||||||
),
|
),
|
||||||
disposition: BlockDisposition::Above,
|
disposition: BlockDisposition::Above,
|
||||||
});
|
});
|
||||||
} else {
|
|
||||||
group_state.block_count += 1;
|
|
||||||
blocks_to_add.push(BlockProperties {
|
|
||||||
position: header_position,
|
|
||||||
height: 1,
|
|
||||||
render: context_header_renderer(self.build_settings.clone()),
|
|
||||||
disposition: BlockDisposition::Above,
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
for entry in &group.entries[*start_ix..ix] {
|
for entry in &group.entries[*start_ix..ix] {
|
||||||
|
@ -421,7 +411,6 @@ impl ProjectDiagnosticsEditor {
|
||||||
});
|
});
|
||||||
|
|
||||||
self.editor.update(cx, |editor, cx| {
|
self.editor.update(cx, |editor, cx| {
|
||||||
blocks_to_remove.extend(path_state.header);
|
|
||||||
editor.remove_blocks(blocks_to_remove, cx);
|
editor.remove_blocks(blocks_to_remove, cx);
|
||||||
let block_ids = editor.insert_blocks(
|
let block_ids = editor.insert_blocks(
|
||||||
blocks_to_add.into_iter().map(|block| {
|
blocks_to_add.into_iter().map(|block| {
|
||||||
|
@ -440,7 +429,6 @@ impl ProjectDiagnosticsEditor {
|
||||||
for group_state in &mut groups_to_add {
|
for group_state in &mut groups_to_add {
|
||||||
group_state.blocks = block_ids.by_ref().take(group_state.block_count).collect();
|
group_state.blocks = block_ids.by_ref().take(group_state.block_count).collect();
|
||||||
}
|
}
|
||||||
path_state.header = block_ids.next();
|
|
||||||
});
|
});
|
||||||
|
|
||||||
for ix in group_ixs_to_remove.into_iter().rev() {
|
for ix in group_ixs_to_remove.into_iter().rev() {
|
||||||
|
@ -704,17 +692,6 @@ fn diagnostic_header_renderer(
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
fn context_header_renderer(build_settings: BuildSettings) -> RenderBlock {
|
|
||||||
Arc::new(move |cx| {
|
|
||||||
let settings = build_settings(cx);
|
|
||||||
let text_style = settings.style.text.clone();
|
|
||||||
Label::new("…".to_string(), text_style)
|
|
||||||
.contained()
|
|
||||||
.with_padding_left(cx.gutter_padding + cx.scroll_x * cx.em_width)
|
|
||||||
.named("collapsed context")
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
pub(crate) fn render_summary(
|
pub(crate) fn render_summary(
|
||||||
summary: &DiagnosticSummary,
|
summary: &DiagnosticSummary,
|
||||||
text_style: &TextStyle,
|
text_style: &TextStyle,
|
||||||
|
@ -939,8 +916,9 @@ mod tests {
|
||||||
[
|
[
|
||||||
(0, "path header block".into()),
|
(0, "path header block".into()),
|
||||||
(2, "diagnostic header".into()),
|
(2, "diagnostic header".into()),
|
||||||
(15, "diagnostic header".into()),
|
(15, "collapsed context".into()),
|
||||||
(24, "collapsed context".into()),
|
(16, "diagnostic header".into()),
|
||||||
|
(25, "collapsed context".into()),
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
|
@ -965,6 +943,7 @@ mod tests {
|
||||||
" c(y);\n",
|
" c(y);\n",
|
||||||
"\n", // supporting diagnostic
|
"\n", // supporting diagnostic
|
||||||
" d(x);\n",
|
" d(x);\n",
|
||||||
|
"\n", // context ellipsis
|
||||||
// diagnostic group 2
|
// diagnostic group 2
|
||||||
"\n", // primary message
|
"\n", // primary message
|
||||||
"\n", // padding
|
"\n", // padding
|
||||||
|
@ -1027,8 +1006,9 @@ mod tests {
|
||||||
(2, "diagnostic header".into()),
|
(2, "diagnostic header".into()),
|
||||||
(7, "path header block".into()),
|
(7, "path header block".into()),
|
||||||
(9, "diagnostic header".into()),
|
(9, "diagnostic header".into()),
|
||||||
(22, "diagnostic header".into()),
|
(22, "collapsed context".into()),
|
||||||
(31, "collapsed context".into()),
|
(23, "diagnostic header".into()),
|
||||||
|
(32, "collapsed context".into()),
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
|
@ -1064,6 +1044,7 @@ mod tests {
|
||||||
" c(y);\n",
|
" c(y);\n",
|
||||||
"\n", // supporting diagnostic
|
"\n", // supporting diagnostic
|
||||||
" d(x);\n",
|
" d(x);\n",
|
||||||
|
"\n", // collapsed context
|
||||||
// diagnostic group 2
|
// diagnostic group 2
|
||||||
"\n", // primary message
|
"\n", // primary message
|
||||||
"\n", // filename
|
"\n", // filename
|
||||||
|
@ -1138,11 +1119,13 @@ mod tests {
|
||||||
[
|
[
|
||||||
(0, "path header block".into()),
|
(0, "path header block".into()),
|
||||||
(2, "diagnostic header".into()),
|
(2, "diagnostic header".into()),
|
||||||
(7, "diagnostic header".into()),
|
(7, "collapsed context".into()),
|
||||||
(12, "path header block".into()),
|
(8, "diagnostic header".into()),
|
||||||
(14, "diagnostic header".into()),
|
(13, "path header block".into()),
|
||||||
(27, "diagnostic header".into()),
|
(15, "diagnostic header".into()),
|
||||||
(36, "collapsed context".into()),
|
(28, "collapsed context".into()),
|
||||||
|
(29, "diagnostic header".into()),
|
||||||
|
(38, "collapsed context".into()),
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
|
@ -1159,6 +1142,7 @@ mod tests {
|
||||||
"const a: i32 = 'a';\n",
|
"const a: i32 = 'a';\n",
|
||||||
"\n", // supporting diagnostic
|
"\n", // supporting diagnostic
|
||||||
"const b: i32 = c;\n",
|
"const b: i32 = c;\n",
|
||||||
|
"\n", // context ellipsis
|
||||||
// diagnostic group 2
|
// diagnostic group 2
|
||||||
"\n", // primary message
|
"\n", // primary message
|
||||||
"\n", // padding
|
"\n", // padding
|
||||||
|
@ -1184,6 +1168,7 @@ mod tests {
|
||||||
" c(y);\n",
|
" c(y);\n",
|
||||||
"\n", // supporting diagnostic
|
"\n", // supporting diagnostic
|
||||||
" d(x);\n",
|
" d(x);\n",
|
||||||
|
"\n", // context ellipsis
|
||||||
// diagnostic group 2
|
// diagnostic group 2
|
||||||
"\n", // primary message
|
"\n", // primary message
|
||||||
"\n", // filename
|
"\n", // filename
|
||||||
|
@ -1221,7 +1206,15 @@ mod tests {
|
||||||
})
|
})
|
||||||
.name()?
|
.name()?
|
||||||
.to_string(),
|
.to_string(),
|
||||||
TransformBlock::ExcerptHeader { .. } => "path header block".to_string(),
|
TransformBlock::ExcerptHeader {
|
||||||
|
starts_new_buffer, ..
|
||||||
|
} => {
|
||||||
|
if *starts_new_buffer {
|
||||||
|
"path header block".to_string()
|
||||||
|
} else {
|
||||||
|
"collapsed context".to_string()
|
||||||
|
}
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
Some((row, name))
|
Some((row, name))
|
||||||
|
|
|
@ -43,6 +43,7 @@ impl DisplayMap {
|
||||||
font_id: FontId,
|
font_id: FontId,
|
||||||
font_size: f32,
|
font_size: f32,
|
||||||
wrap_width: Option<f32>,
|
wrap_width: Option<f32>,
|
||||||
|
buffer_header_height: u8,
|
||||||
excerpt_header_height: u8,
|
excerpt_header_height: u8,
|
||||||
cx: &mut ModelContext<Self>,
|
cx: &mut ModelContext<Self>,
|
||||||
) -> Self {
|
) -> Self {
|
||||||
|
@ -50,7 +51,7 @@ impl DisplayMap {
|
||||||
let (fold_map, snapshot) = FoldMap::new(buffer.read(cx).snapshot(cx));
|
let (fold_map, snapshot) = FoldMap::new(buffer.read(cx).snapshot(cx));
|
||||||
let (tab_map, snapshot) = TabMap::new(snapshot, tab_size);
|
let (tab_map, snapshot) = TabMap::new(snapshot, tab_size);
|
||||||
let (wrap_map, snapshot) = WrapMap::new(snapshot, font_id, font_size, wrap_width, cx);
|
let (wrap_map, snapshot) = WrapMap::new(snapshot, font_id, font_size, wrap_width, cx);
|
||||||
let block_map = BlockMap::new(snapshot, excerpt_header_height);
|
let block_map = BlockMap::new(snapshot, buffer_header_height, excerpt_header_height);
|
||||||
cx.observe(&wrap_map, |_, _, cx| cx.notify()).detach();
|
cx.observe(&wrap_map, |_, _, cx| cx.notify()).detach();
|
||||||
DisplayMap {
|
DisplayMap {
|
||||||
buffer,
|
buffer,
|
||||||
|
@ -472,6 +473,7 @@ mod tests {
|
||||||
|
|
||||||
let font_cache = cx.font_cache().clone();
|
let font_cache = cx.font_cache().clone();
|
||||||
let tab_size = rng.gen_range(1..=4);
|
let tab_size = rng.gen_range(1..=4);
|
||||||
|
let buffer_start_excerpt_header_height = rng.gen_range(1..=5);
|
||||||
let excerpt_header_height = rng.gen_range(1..=5);
|
let excerpt_header_height = rng.gen_range(1..=5);
|
||||||
let family_id = font_cache.load_family(&["Helvetica"]).unwrap();
|
let family_id = font_cache.load_family(&["Helvetica"]).unwrap();
|
||||||
let font_id = font_cache
|
let font_id = font_cache
|
||||||
|
@ -505,6 +507,7 @@ mod tests {
|
||||||
font_id,
|
font_id,
|
||||||
font_size,
|
font_size,
|
||||||
wrap_width,
|
wrap_width,
|
||||||
|
buffer_start_excerpt_header_height,
|
||||||
excerpt_header_height,
|
excerpt_header_height,
|
||||||
cx,
|
cx,
|
||||||
)
|
)
|
||||||
|
@ -728,6 +731,7 @@ mod tests {
|
||||||
font_size,
|
font_size,
|
||||||
wrap_width,
|
wrap_width,
|
||||||
1,
|
1,
|
||||||
|
1,
|
||||||
cx,
|
cx,
|
||||||
)
|
)
|
||||||
});
|
});
|
||||||
|
@ -809,7 +813,7 @@ mod tests {
|
||||||
.unwrap();
|
.unwrap();
|
||||||
let font_size = 14.0;
|
let font_size = 14.0;
|
||||||
let map = cx.add_model(|cx| {
|
let map = cx.add_model(|cx| {
|
||||||
DisplayMap::new(buffer.clone(), tab_size, font_id, font_size, None, 1, cx)
|
DisplayMap::new(buffer.clone(), tab_size, font_id, font_size, None, 1, 1, cx)
|
||||||
});
|
});
|
||||||
buffer.update(cx, |buffer, cx| {
|
buffer.update(cx, |buffer, cx| {
|
||||||
buffer.edit(
|
buffer.edit(
|
||||||
|
@ -888,8 +892,8 @@ mod tests {
|
||||||
.unwrap();
|
.unwrap();
|
||||||
let font_size = 14.0;
|
let font_size = 14.0;
|
||||||
|
|
||||||
let map =
|
let map = cx
|
||||||
cx.add_model(|cx| DisplayMap::new(buffer, tab_size, font_id, font_size, None, 1, cx));
|
.add_model(|cx| DisplayMap::new(buffer, tab_size, font_id, font_size, None, 1, 1, cx));
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
cx.update(|cx| chunks(0..5, &map, &theme, cx)),
|
cx.update(|cx| chunks(0..5, &map, &theme, cx)),
|
||||||
vec![
|
vec![
|
||||||
|
@ -977,7 +981,7 @@ mod tests {
|
||||||
let font_size = 16.0;
|
let font_size = 16.0;
|
||||||
|
|
||||||
let map = cx.add_model(|cx| {
|
let map = cx.add_model(|cx| {
|
||||||
DisplayMap::new(buffer, tab_size, font_id, font_size, Some(40.0), 1, cx)
|
DisplayMap::new(buffer, tab_size, font_id, font_size, Some(40.0), 1, 1, cx)
|
||||||
});
|
});
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
cx.update(|cx| chunks(0..5, &map, &theme, cx)),
|
cx.update(|cx| chunks(0..5, &map, &theme, cx)),
|
||||||
|
@ -1022,7 +1026,7 @@ mod tests {
|
||||||
.unwrap();
|
.unwrap();
|
||||||
let font_size = 14.0;
|
let font_size = 14.0;
|
||||||
let map = cx.add_model(|cx| {
|
let map = cx.add_model(|cx| {
|
||||||
DisplayMap::new(buffer.clone(), tab_size, font_id, font_size, None, 1, cx)
|
DisplayMap::new(buffer.clone(), tab_size, font_id, font_size, None, 1, 1, cx)
|
||||||
});
|
});
|
||||||
let map = map.update(cx, |map, cx| map.snapshot(cx));
|
let map = map.update(cx, |map, cx| map.snapshot(cx));
|
||||||
|
|
||||||
|
@ -1066,7 +1070,7 @@ mod tests {
|
||||||
let font_size = 14.0;
|
let font_size = 14.0;
|
||||||
|
|
||||||
let map = cx.add_model(|cx| {
|
let map = cx.add_model(|cx| {
|
||||||
DisplayMap::new(buffer.clone(), tab_size, font_id, font_size, None, 1, cx)
|
DisplayMap::new(buffer.clone(), tab_size, font_id, font_size, None, 1, 1, cx)
|
||||||
});
|
});
|
||||||
let map = map.update(cx, |map, cx| map.snapshot(cx));
|
let map = map.update(cx, |map, cx| map.snapshot(cx));
|
||||||
assert_eq!(map.text(), "✅ α\nβ \n🏀β γ");
|
assert_eq!(map.text(), "✅ α\nβ \n🏀β γ");
|
||||||
|
@ -1124,7 +1128,7 @@ mod tests {
|
||||||
.unwrap();
|
.unwrap();
|
||||||
let font_size = 14.0;
|
let font_size = 14.0;
|
||||||
let map = cx.add_model(|cx| {
|
let map = cx.add_model(|cx| {
|
||||||
DisplayMap::new(buffer.clone(), tab_size, font_id, font_size, None, 1, cx)
|
DisplayMap::new(buffer.clone(), tab_size, font_id, font_size, None, 1, 1, cx)
|
||||||
});
|
});
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
map.update(cx, |map, cx| map.snapshot(cx)).max_point(),
|
map.update(cx, |map, cx| map.snapshot(cx)).max_point(),
|
||||||
|
|
|
@ -24,6 +24,7 @@ pub struct BlockMap {
|
||||||
wrap_snapshot: RefCell<WrapSnapshot>,
|
wrap_snapshot: RefCell<WrapSnapshot>,
|
||||||
blocks: Vec<Arc<Block>>,
|
blocks: Vec<Arc<Block>>,
|
||||||
transforms: RefCell<SumTree<Transform>>,
|
transforms: RefCell<SumTree<Transform>>,
|
||||||
|
buffer_header_height: u8,
|
||||||
excerpt_header_height: u8,
|
excerpt_header_height: u8,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -150,13 +151,18 @@ pub struct BlockBufferRows<'a> {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl BlockMap {
|
impl BlockMap {
|
||||||
pub fn new(wrap_snapshot: WrapSnapshot, excerpt_header_height: u8) -> Self {
|
pub fn new(
|
||||||
|
wrap_snapshot: WrapSnapshot,
|
||||||
|
buffer_header_height: u8,
|
||||||
|
excerpt_header_height: u8,
|
||||||
|
) -> Self {
|
||||||
let row_count = wrap_snapshot.max_point().row() + 1;
|
let row_count = wrap_snapshot.max_point().row() + 1;
|
||||||
let map = Self {
|
let map = Self {
|
||||||
next_block_id: AtomicUsize::new(0),
|
next_block_id: AtomicUsize::new(0),
|
||||||
blocks: Vec::new(),
|
blocks: Vec::new(),
|
||||||
transforms: RefCell::new(SumTree::from_item(Transform::isomorphic(row_count), &())),
|
transforms: RefCell::new(SumTree::from_item(Transform::isomorphic(row_count), &())),
|
||||||
wrap_snapshot: RefCell::new(wrap_snapshot.clone()),
|
wrap_snapshot: RefCell::new(wrap_snapshot.clone()),
|
||||||
|
buffer_header_height,
|
||||||
excerpt_header_height,
|
excerpt_header_height,
|
||||||
};
|
};
|
||||||
map.sync(
|
map.sync(
|
||||||
|
@ -352,7 +358,11 @@ impl BlockMap {
|
||||||
TransformBlock::ExcerptHeader {
|
TransformBlock::ExcerptHeader {
|
||||||
buffer: excerpt_boundary.buffer,
|
buffer: excerpt_boundary.buffer,
|
||||||
range: excerpt_boundary.range,
|
range: excerpt_boundary.range,
|
||||||
height: self.excerpt_header_height,
|
height: if excerpt_boundary.starts_new_buffer {
|
||||||
|
self.buffer_header_height
|
||||||
|
} else {
|
||||||
|
self.excerpt_header_height
|
||||||
|
},
|
||||||
starts_new_buffer: excerpt_boundary.starts_new_buffer,
|
starts_new_buffer: excerpt_boundary.starts_new_buffer,
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
@ -980,7 +990,7 @@ mod tests {
|
||||||
let (fold_map, folds_snapshot) = FoldMap::new(buffer_snapshot.clone());
|
let (fold_map, folds_snapshot) = FoldMap::new(buffer_snapshot.clone());
|
||||||
let (tab_map, tabs_snapshot) = TabMap::new(folds_snapshot.clone(), 1);
|
let (tab_map, tabs_snapshot) = TabMap::new(folds_snapshot.clone(), 1);
|
||||||
let (wrap_map, wraps_snapshot) = WrapMap::new(tabs_snapshot, font_id, 14.0, None, cx);
|
let (wrap_map, wraps_snapshot) = WrapMap::new(tabs_snapshot, font_id, 14.0, None, cx);
|
||||||
let mut block_map = BlockMap::new(wraps_snapshot.clone(), 1);
|
let mut block_map = BlockMap::new(wraps_snapshot.clone(), 1, 1);
|
||||||
|
|
||||||
let mut writer = block_map.write(wraps_snapshot.clone(), Default::default());
|
let mut writer = block_map.write(wraps_snapshot.clone(), Default::default());
|
||||||
writer.insert(vec![
|
writer.insert(vec![
|
||||||
|
@ -1158,7 +1168,7 @@ mod tests {
|
||||||
let (_, folds_snapshot) = FoldMap::new(buffer_snapshot.clone());
|
let (_, folds_snapshot) = FoldMap::new(buffer_snapshot.clone());
|
||||||
let (_, tabs_snapshot) = TabMap::new(folds_snapshot.clone(), 1);
|
let (_, tabs_snapshot) = TabMap::new(folds_snapshot.clone(), 1);
|
||||||
let (_, wraps_snapshot) = WrapMap::new(tabs_snapshot, font_id, 14.0, Some(60.), cx);
|
let (_, wraps_snapshot) = WrapMap::new(tabs_snapshot, font_id, 14.0, Some(60.), cx);
|
||||||
let mut block_map = BlockMap::new(wraps_snapshot.clone(), 1);
|
let mut block_map = BlockMap::new(wraps_snapshot.clone(), 1, 1);
|
||||||
|
|
||||||
let mut writer = block_map.write(wraps_snapshot.clone(), Default::default());
|
let mut writer = block_map.write(wraps_snapshot.clone(), Default::default());
|
||||||
writer.insert(vec![
|
writer.insert(vec![
|
||||||
|
@ -1203,6 +1213,7 @@ mod tests {
|
||||||
.select_font(family_id, &Default::default())
|
.select_font(family_id, &Default::default())
|
||||||
.unwrap();
|
.unwrap();
|
||||||
let font_size = 14.0;
|
let font_size = 14.0;
|
||||||
|
let buffer_start_header_height = rng.gen_range(1..=5);
|
||||||
let excerpt_header_height = rng.gen_range(1..=5);
|
let excerpt_header_height = rng.gen_range(1..=5);
|
||||||
|
|
||||||
log::info!("Wrap width: {:?}", wrap_width);
|
log::info!("Wrap width: {:?}", wrap_width);
|
||||||
|
@ -1222,7 +1233,11 @@ mod tests {
|
||||||
let (tab_map, tabs_snapshot) = TabMap::new(folds_snapshot.clone(), tab_size);
|
let (tab_map, tabs_snapshot) = TabMap::new(folds_snapshot.clone(), tab_size);
|
||||||
let (wrap_map, wraps_snapshot) =
|
let (wrap_map, wraps_snapshot) =
|
||||||
WrapMap::new(tabs_snapshot, font_id, font_size, wrap_width, cx);
|
WrapMap::new(tabs_snapshot, font_id, font_size, wrap_width, cx);
|
||||||
let mut block_map = BlockMap::new(wraps_snapshot.clone(), excerpt_header_height);
|
let mut block_map = BlockMap::new(
|
||||||
|
wraps_snapshot.clone(),
|
||||||
|
buffer_start_header_height,
|
||||||
|
excerpt_header_height,
|
||||||
|
);
|
||||||
let mut custom_blocks = Vec::new();
|
let mut custom_blocks = Vec::new();
|
||||||
|
|
||||||
for _ in 0..operations {
|
for _ in 0..operations {
|
||||||
|
@ -1350,7 +1365,11 @@ mod tests {
|
||||||
(
|
(
|
||||||
position.row(),
|
position.row(),
|
||||||
ExpectedBlock::ExcerptHeader {
|
ExpectedBlock::ExcerptHeader {
|
||||||
height: excerpt_header_height,
|
height: if boundary.starts_new_buffer {
|
||||||
|
buffer_start_header_height
|
||||||
|
} else {
|
||||||
|
excerpt_header_height
|
||||||
|
},
|
||||||
starts_new_buffer: boundary.starts_new_buffer,
|
starts_new_buffer: boundary.starts_new_buffer,
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
|
|
@ -810,6 +810,7 @@ impl Editor {
|
||||||
settings.style.text.font_size,
|
settings.style.text.font_size,
|
||||||
None,
|
None,
|
||||||
2,
|
2,
|
||||||
|
1,
|
||||||
cx,
|
cx,
|
||||||
)
|
)
|
||||||
});
|
});
|
||||||
|
@ -7892,21 +7893,23 @@ mod tests {
|
||||||
build_editor(multibuffer, settings, cx)
|
build_editor(multibuffer, settings, cx)
|
||||||
});
|
});
|
||||||
view.update(cx, |view, cx| {
|
view.update(cx, |view, cx| {
|
||||||
view.select_display_ranges(
|
assert_eq!(view.text(cx), "aaaa\nbbbb");
|
||||||
&[
|
view.select_ranges(
|
||||||
DisplayPoint::new(0, 0)..DisplayPoint::new(0, 0),
|
[
|
||||||
DisplayPoint::new(1, 0)..DisplayPoint::new(1, 0),
|
Point::new(0, 0)..Point::new(0, 0),
|
||||||
|
Point::new(1, 0)..Point::new(1, 0),
|
||||||
],
|
],
|
||||||
|
None,
|
||||||
cx,
|
cx,
|
||||||
);
|
);
|
||||||
|
|
||||||
view.handle_input(&Input("X".to_string()), cx);
|
view.handle_input(&Input("X".to_string()), cx);
|
||||||
assert_eq!(view.text(cx), "Xaaaa\nXbbbb");
|
assert_eq!(view.text(cx), "Xaaaa\nXbbbb");
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
view.selected_display_ranges(cx),
|
view.selected_ranges(cx),
|
||||||
&[
|
[
|
||||||
DisplayPoint::new(0, 1)..DisplayPoint::new(0, 1),
|
Point::new(0, 1)..Point::new(0, 1),
|
||||||
DisplayPoint::new(1, 1)..DisplayPoint::new(1, 1),
|
Point::new(1, 1)..Point::new(1, 1),
|
||||||
]
|
]
|
||||||
)
|
)
|
||||||
});
|
});
|
||||||
|
@ -7944,31 +7947,32 @@ mod tests {
|
||||||
build_editor(multibuffer, settings, cx)
|
build_editor(multibuffer, settings, cx)
|
||||||
});
|
});
|
||||||
view.update(cx, |view, cx| {
|
view.update(cx, |view, cx| {
|
||||||
view.select_display_ranges(
|
view.select_ranges(
|
||||||
&[
|
[
|
||||||
DisplayPoint::new(1, 1)..DisplayPoint::new(1, 1),
|
Point::new(1, 1)..Point::new(1, 1),
|
||||||
DisplayPoint::new(2, 3)..DisplayPoint::new(2, 3),
|
Point::new(2, 3)..Point::new(2, 3),
|
||||||
],
|
],
|
||||||
|
None,
|
||||||
cx,
|
cx,
|
||||||
);
|
);
|
||||||
|
|
||||||
view.handle_input(&Input("X".to_string()), cx);
|
view.handle_input(&Input("X".to_string()), cx);
|
||||||
assert_eq!(view.text(cx), "aaaa\nbXbbXb\nbXbbXb\ncccc");
|
assert_eq!(view.text(cx), "aaaa\nbXbbXb\nbXbbXb\ncccc");
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
view.selected_display_ranges(cx),
|
view.selected_ranges(cx),
|
||||||
&[
|
[
|
||||||
DisplayPoint::new(1, 2)..DisplayPoint::new(1, 2),
|
Point::new(1, 2)..Point::new(1, 2),
|
||||||
DisplayPoint::new(2, 5)..DisplayPoint::new(2, 5),
|
Point::new(2, 5)..Point::new(2, 5),
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
|
|
||||||
view.newline(&Newline, cx);
|
view.newline(&Newline, cx);
|
||||||
assert_eq!(view.text(cx), "aaaa\nbX\nbbX\nb\nbX\nbbX\nb\ncccc");
|
assert_eq!(view.text(cx), "aaaa\nbX\nbbX\nb\nbX\nbbX\nb\ncccc");
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
view.selected_display_ranges(cx),
|
view.selected_ranges(cx),
|
||||||
&[
|
[
|
||||||
DisplayPoint::new(2, 0)..DisplayPoint::new(2, 0),
|
Point::new(2, 0)..Point::new(2, 0),
|
||||||
DisplayPoint::new(6, 0)..DisplayPoint::new(6, 0),
|
Point::new(6, 0)..Point::new(6, 0),
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
@ -8003,11 +8007,12 @@ mod tests {
|
||||||
);
|
);
|
||||||
let (_, editor) = cx.add_window(Default::default(), |cx| {
|
let (_, editor) = cx.add_window(Default::default(), |cx| {
|
||||||
let mut editor = build_editor(multibuffer.clone(), settings, cx);
|
let mut editor = build_editor(multibuffer.clone(), settings, cx);
|
||||||
editor.select_display_ranges(
|
editor.select_ranges(
|
||||||
&[
|
[
|
||||||
DisplayPoint::new(1, 3)..DisplayPoint::new(1, 3),
|
Point::new(1, 3)..Point::new(1, 3),
|
||||||
DisplayPoint::new(2, 1)..DisplayPoint::new(2, 1),
|
Point::new(2, 1)..Point::new(2, 1),
|
||||||
],
|
],
|
||||||
|
None,
|
||||||
cx,
|
cx,
|
||||||
);
|
);
|
||||||
editor
|
editor
|
||||||
|
@ -8017,10 +8022,10 @@ mod tests {
|
||||||
editor.update(cx, |editor, cx| {
|
editor.update(cx, |editor, cx| {
|
||||||
editor.refresh_selections(cx);
|
editor.refresh_selections(cx);
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
editor.selected_display_ranges(cx),
|
editor.selected_ranges(cx),
|
||||||
[
|
[
|
||||||
DisplayPoint::new(1, 3)..DisplayPoint::new(1, 3),
|
Point::new(1, 3)..Point::new(1, 3),
|
||||||
DisplayPoint::new(2, 1)..DisplayPoint::new(2, 1),
|
Point::new(2, 1)..Point::new(2, 1),
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
@ -8031,10 +8036,10 @@ mod tests {
|
||||||
editor.update(cx, |editor, cx| {
|
editor.update(cx, |editor, cx| {
|
||||||
// Removing an excerpt causes the first selection to become degenerate.
|
// Removing an excerpt causes the first selection to become degenerate.
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
editor.selected_display_ranges(cx),
|
editor.selected_ranges(cx),
|
||||||
[
|
[
|
||||||
DisplayPoint::new(0, 0)..DisplayPoint::new(0, 0),
|
Point::new(0, 0)..Point::new(0, 0),
|
||||||
DisplayPoint::new(0, 1)..DisplayPoint::new(0, 1)
|
Point::new(0, 1)..Point::new(0, 1)
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -8042,10 +8047,10 @@ mod tests {
|
||||||
// location.
|
// location.
|
||||||
editor.refresh_selections(cx);
|
editor.refresh_selections(cx);
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
editor.selected_display_ranges(cx),
|
editor.selected_ranges(cx),
|
||||||
[
|
[
|
||||||
DisplayPoint::new(0, 1)..DisplayPoint::new(0, 1),
|
Point::new(0, 1)..Point::new(0, 1),
|
||||||
DisplayPoint::new(0, 3)..DisplayPoint::new(0, 3)
|
Point::new(0, 3)..Point::new(0, 3)
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
|
@ -679,15 +679,22 @@ impl EditorElement {
|
||||||
em_width,
|
em_width,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
TransformBlock::ExcerptHeader { buffer, .. } => {
|
TransformBlock::ExcerptHeader {
|
||||||
|
buffer,
|
||||||
|
starts_new_buffer,
|
||||||
|
..
|
||||||
|
} => {
|
||||||
|
if *starts_new_buffer {
|
||||||
let style = &self.settings.style.diagnostic_path_header;
|
let style = &self.settings.style.diagnostic_path_header;
|
||||||
let font_size =
|
let font_size = (style.text_scale_factor
|
||||||
(style.text_scale_factor * self.settings.style.text.font_size).round();
|
* self.settings.style.text.font_size)
|
||||||
|
.round();
|
||||||
|
|
||||||
let mut filename = None;
|
let mut filename = None;
|
||||||
let mut parent_path = None;
|
let mut parent_path = None;
|
||||||
if let Some(path) = buffer.path() {
|
if let Some(path) = buffer.path() {
|
||||||
filename = path.file_name().map(|f| f.to_string_lossy().to_string());
|
filename =
|
||||||
|
path.file_name().map(|f| f.to_string_lossy().to_string());
|
||||||
parent_path =
|
parent_path =
|
||||||
path.parent().map(|p| p.to_string_lossy().to_string() + "/");
|
path.parent().map(|p| p.to_string_lossy().to_string() + "/");
|
||||||
}
|
}
|
||||||
|
@ -703,7 +710,10 @@ impl EditorElement {
|
||||||
.boxed(),
|
.boxed(),
|
||||||
)
|
)
|
||||||
.with_children(parent_path.map(|path| {
|
.with_children(parent_path.map(|path| {
|
||||||
Label::new(path, style.path.text.clone().with_font_size(font_size))
|
Label::new(
|
||||||
|
path,
|
||||||
|
style.path.text.clone().with_font_size(font_size),
|
||||||
|
)
|
||||||
.contained()
|
.contained()
|
||||||
.with_style(style.path.container)
|
.with_style(style.path.container)
|
||||||
.boxed()
|
.boxed()
|
||||||
|
@ -715,6 +725,13 @@ impl EditorElement {
|
||||||
.with_padding_left(gutter_padding + scroll_x * em_width)
|
.with_padding_left(gutter_padding + scroll_x * em_width)
|
||||||
.expanded()
|
.expanded()
|
||||||
.named("path header block")
|
.named("path header block")
|
||||||
|
} else {
|
||||||
|
let text_style = self.settings.style.text.clone();
|
||||||
|
Label::new("…".to_string(), text_style)
|
||||||
|
.contained()
|
||||||
|
.with_padding_left(gutter_padding + scroll_x * em_width)
|
||||||
|
.named("collapsed context")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -257,10 +257,10 @@ mod tests {
|
||||||
});
|
});
|
||||||
|
|
||||||
let display_map =
|
let display_map =
|
||||||
cx.add_model(|cx| DisplayMap::new(multibuffer, 2, font_id, 14.0, None, 2, cx));
|
cx.add_model(|cx| DisplayMap::new(multibuffer, 2, font_id, 14.0, None, 2, 2, cx));
|
||||||
|
|
||||||
let snapshot = display_map.update(cx, |map, cx| map.snapshot(cx));
|
let snapshot = display_map.update(cx, |map, cx| map.snapshot(cx));
|
||||||
assert_eq!(snapshot.text(), "\n\nabc\ndefg\n\n\n\nhijkl\nmn");
|
assert_eq!(snapshot.text(), "\n\nabc\ndefg\n\n\nhijkl\nmn");
|
||||||
|
|
||||||
// Can't move up into the first excerpt's header
|
// Can't move up into the first excerpt's header
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
|
@ -284,22 +284,22 @@ mod tests {
|
||||||
|
|
||||||
// Move up and down across second excerpt's header
|
// Move up and down across second excerpt's header
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
up(&snapshot, DisplayPoint::new(7, 5), SelectionGoal::Column(5)).unwrap(),
|
up(&snapshot, DisplayPoint::new(6, 5), SelectionGoal::Column(5)).unwrap(),
|
||||||
(DisplayPoint::new(3, 4), SelectionGoal::Column(5)),
|
(DisplayPoint::new(3, 4), SelectionGoal::Column(5)),
|
||||||
);
|
);
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
down(&snapshot, DisplayPoint::new(3, 4), SelectionGoal::Column(5)).unwrap(),
|
down(&snapshot, DisplayPoint::new(3, 4), SelectionGoal::Column(5)).unwrap(),
|
||||||
(DisplayPoint::new(7, 5), SelectionGoal::Column(5)),
|
(DisplayPoint::new(6, 5), SelectionGoal::Column(5)),
|
||||||
);
|
);
|
||||||
|
|
||||||
// Can't move down off the end
|
// Can't move down off the end
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
down(&snapshot, DisplayPoint::new(8, 0), SelectionGoal::Column(0)).unwrap(),
|
down(&snapshot, DisplayPoint::new(7, 0), SelectionGoal::Column(0)).unwrap(),
|
||||||
(DisplayPoint::new(8, 2), SelectionGoal::Column(2)),
|
(DisplayPoint::new(7, 2), SelectionGoal::Column(2)),
|
||||||
);
|
);
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
down(&snapshot, DisplayPoint::new(8, 2), SelectionGoal::Column(2)).unwrap(),
|
down(&snapshot, DisplayPoint::new(7, 2), SelectionGoal::Column(2)).unwrap(),
|
||||||
(DisplayPoint::new(8, 2), SelectionGoal::Column(2)),
|
(DisplayPoint::new(7, 2), SelectionGoal::Column(2)),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -314,8 +314,8 @@ mod tests {
|
||||||
let font_size = 14.0;
|
let font_size = 14.0;
|
||||||
|
|
||||||
let buffer = MultiBuffer::build_simple("a bcΔ defγ hi—jk", cx);
|
let buffer = MultiBuffer::build_simple("a bcΔ defγ hi—jk", cx);
|
||||||
let display_map =
|
let display_map = cx
|
||||||
cx.add_model(|cx| DisplayMap::new(buffer, tab_size, font_id, font_size, None, 1, cx));
|
.add_model(|cx| DisplayMap::new(buffer, tab_size, font_id, font_size, None, 1, 1, cx));
|
||||||
let snapshot = display_map.update(cx, |map, cx| map.snapshot(cx));
|
let snapshot = display_map.update(cx, |map, cx| map.snapshot(cx));
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
prev_word_boundary(&snapshot, DisplayPoint::new(0, 12)),
|
prev_word_boundary(&snapshot, DisplayPoint::new(0, 12)),
|
||||||
|
@ -370,8 +370,8 @@ mod tests {
|
||||||
.unwrap();
|
.unwrap();
|
||||||
let font_size = 14.0;
|
let font_size = 14.0;
|
||||||
let buffer = MultiBuffer::build_simple("lorem ipsum dolor\n sit", cx);
|
let buffer = MultiBuffer::build_simple("lorem ipsum dolor\n sit", cx);
|
||||||
let display_map =
|
let display_map = cx
|
||||||
cx.add_model(|cx| DisplayMap::new(buffer, tab_size, font_id, font_size, None, 1, cx));
|
.add_model(|cx| DisplayMap::new(buffer, tab_size, font_id, font_size, None, 1, 1, cx));
|
||||||
let snapshot = display_map.update(cx, |map, cx| map.snapshot(cx));
|
let snapshot = display_map.update(cx, |map, cx| map.snapshot(cx));
|
||||||
|
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue