Immediate edit step resolution (#16447)
## Todo * [x] Parse and present new XML output * [x] Resolve new edits to buffers and anchor ranges * [x] Surface resolution errors * [x] Steps fail to resolve because language hasn't loaded yet * [x] Treat empty `<symbol>` tag as None * [x] duplicate assists when editing steps * [x] step footer blocks can appear *below* the following message header block ## Release Notes: - N/A --------- Co-authored-by: Mikayla <mikayla@zed.dev> Co-authored-by: Peter <peter@zed.dev> Co-authored-by: Marshall <marshall@zed.dev> Co-authored-by: Antonio <antonio@zed.dev> Co-authored-by: Antonio Scandurra <me@as-cii.com>
This commit is contained in:
parent
fc4c533d0a
commit
f84ef5e48a
16 changed files with 2737 additions and 2336 deletions
|
@ -105,7 +105,7 @@ pub struct DisplayMap {
|
|||
inlay_highlights: InlayHighlights,
|
||||
/// A container for explicitly foldable ranges, which supersede indentation based fold range suggestions.
|
||||
crease_map: CreaseMap,
|
||||
fold_placeholder: FoldPlaceholder,
|
||||
pub(crate) fold_placeholder: FoldPlaceholder,
|
||||
pub clip_at_line_ends: bool,
|
||||
pub(crate) masked: bool,
|
||||
}
|
||||
|
|
|
@ -10388,6 +10388,10 @@ impl Editor {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn default_fold_placeholder(&self, cx: &AppContext) -> FoldPlaceholder {
|
||||
self.display_map.read(cx).fold_placeholder.clone()
|
||||
}
|
||||
|
||||
pub fn set_gutter_hovered(&mut self, hovered: bool, cx: &mut ViewContext<Self>) {
|
||||
if hovered != self.gutter_hovered {
|
||||
self.gutter_hovered = hovered;
|
||||
|
|
|
@ -41,8 +41,12 @@ use gpui::{
|
|||
ViewContext, WeakView, WindowContext,
|
||||
};
|
||||
use itertools::Itertools;
|
||||
use language::language_settings::{
|
||||
IndentGuideBackgroundColoring, IndentGuideColoring, IndentGuideSettings, ShowWhitespaceSetting,
|
||||
use language::{
|
||||
language_settings::{
|
||||
IndentGuideBackgroundColoring, IndentGuideColoring, IndentGuideSettings,
|
||||
ShowWhitespaceSetting,
|
||||
},
|
||||
ChunkRendererContext,
|
||||
};
|
||||
use lsp::DiagnosticSeverity;
|
||||
use multi_buffer::{Anchor, MultiBufferPoint, MultiBufferRow};
|
||||
|
@ -1872,6 +1876,7 @@ impl EditorElement {
|
|||
line_number_layouts: &[Option<ShapedLine>],
|
||||
snapshot: &EditorSnapshot,
|
||||
style: &EditorStyle,
|
||||
editor_width: Pixels,
|
||||
cx: &mut WindowContext,
|
||||
) -> Vec<LineWithInvisibles> {
|
||||
if rows.start >= rows.end {
|
||||
|
@ -1922,6 +1927,7 @@ impl EditorElement {
|
|||
rows.len(),
|
||||
line_number_layouts,
|
||||
snapshot.mode,
|
||||
editor_width,
|
||||
cx,
|
||||
)
|
||||
}
|
||||
|
@ -1966,6 +1972,7 @@ impl EditorElement {
|
|||
line_height: Pixels,
|
||||
em_width: Pixels,
|
||||
text_hitbox: &Hitbox,
|
||||
editor_width: Pixels,
|
||||
scroll_width: &mut Pixels,
|
||||
resized_blocks: &mut HashMap<CustomBlockId, u32>,
|
||||
cx: &mut WindowContext,
|
||||
|
@ -1981,7 +1988,7 @@ impl EditorElement {
|
|||
line_layouts[align_to.row().minus(rows.start) as usize]
|
||||
.x_for_index(align_to.column() as usize)
|
||||
} else {
|
||||
layout_line(align_to.row(), snapshot, &self.style, cx)
|
||||
layout_line(align_to.row(), snapshot, &self.style, editor_width, cx)
|
||||
.x_for_index(align_to.column() as usize)
|
||||
};
|
||||
|
||||
|
@ -2418,6 +2425,7 @@ impl EditorElement {
|
|||
snapshot: &EditorSnapshot,
|
||||
hitbox: &Hitbox,
|
||||
text_hitbox: &Hitbox,
|
||||
editor_width: Pixels,
|
||||
scroll_width: &mut Pixels,
|
||||
gutter_dimensions: &GutterDimensions,
|
||||
em_width: Pixels,
|
||||
|
@ -2457,6 +2465,7 @@ impl EditorElement {
|
|||
line_height,
|
||||
em_width,
|
||||
text_hitbox,
|
||||
editor_width,
|
||||
scroll_width,
|
||||
&mut resized_blocks,
|
||||
cx,
|
||||
|
@ -2500,6 +2509,7 @@ impl EditorElement {
|
|||
line_height,
|
||||
em_width,
|
||||
text_hitbox,
|
||||
editor_width,
|
||||
scroll_width,
|
||||
&mut resized_blocks,
|
||||
cx,
|
||||
|
@ -2544,6 +2554,7 @@ impl EditorElement {
|
|||
line_height,
|
||||
em_width,
|
||||
text_hitbox,
|
||||
editor_width,
|
||||
scroll_width,
|
||||
&mut resized_blocks,
|
||||
cx,
|
||||
|
@ -4353,6 +4364,7 @@ impl fmt::Debug for LineFragment {
|
|||
}
|
||||
|
||||
impl LineWithInvisibles {
|
||||
#[allow(clippy::too_many_arguments)]
|
||||
fn from_chunks<'a>(
|
||||
chunks: impl Iterator<Item = HighlightedChunk<'a>>,
|
||||
text_style: &TextStyle,
|
||||
|
@ -4360,6 +4372,7 @@ impl LineWithInvisibles {
|
|||
max_line_count: usize,
|
||||
line_number_layouts: &[Option<ShapedLine>],
|
||||
editor_mode: EditorMode,
|
||||
text_width: Pixels,
|
||||
cx: &mut WindowContext,
|
||||
) -> Vec<Self> {
|
||||
let mut layouts = Vec::with_capacity(max_line_count);
|
||||
|
@ -4414,7 +4427,10 @@ impl LineWithInvisibles {
|
|||
AvailableSpace::MinContent
|
||||
};
|
||||
|
||||
let mut element = (renderer.render)(cx);
|
||||
let mut element = (renderer.render)(&mut ChunkRendererContext {
|
||||
context: cx,
|
||||
max_width: text_width,
|
||||
});
|
||||
let line_height = text_style.line_height_in_pixels(cx.rem_size());
|
||||
let size = element.layout_as_root(
|
||||
size(available_width, AvailableSpace::Definite(line_height)),
|
||||
|
@ -4871,6 +4887,7 @@ impl Element for EditorElement {
|
|||
&[],
|
||||
&editor_snapshot,
|
||||
&style,
|
||||
px(f32::MAX),
|
||||
cx,
|
||||
)
|
||||
.pop()
|
||||
|
@ -4983,6 +5000,9 @@ impl Element for EditorElement {
|
|||
};
|
||||
let overscroll = size(em_width + right_margin, px(0.));
|
||||
|
||||
let editor_width =
|
||||
text_width - gutter_dimensions.margin - overscroll.width - em_width;
|
||||
|
||||
snapshot = self.editor.update(cx, |editor, cx| {
|
||||
editor.last_bounds = Some(bounds);
|
||||
editor.gutter_dimensions = gutter_dimensions;
|
||||
|
@ -4991,8 +5011,6 @@ impl Element for EditorElement {
|
|||
if matches!(editor.mode, EditorMode::AutoHeight { .. }) {
|
||||
snapshot
|
||||
} else {
|
||||
let editor_width =
|
||||
text_width - gutter_dimensions.margin - overscroll.width - em_width;
|
||||
let wrap_width = match editor.soft_wrap_mode(cx) {
|
||||
SoftWrap::None => None,
|
||||
SoftWrap::PreferLine => {
|
||||
|
@ -5162,6 +5180,7 @@ impl Element for EditorElement {
|
|||
&line_numbers,
|
||||
&snapshot,
|
||||
&self.style,
|
||||
editor_width,
|
||||
cx,
|
||||
);
|
||||
for line_with_invisibles in &line_layouts {
|
||||
|
@ -5171,7 +5190,8 @@ impl Element for EditorElement {
|
|||
}
|
||||
|
||||
let longest_line_width =
|
||||
layout_line(snapshot.longest_row(), &snapshot, &style, cx).width;
|
||||
layout_line(snapshot.longest_row(), &snapshot, &style, editor_width, cx)
|
||||
.width;
|
||||
let mut scroll_width =
|
||||
longest_line_width.max(max_visible_line_width) + overscroll.width;
|
||||
|
||||
|
@ -5181,6 +5201,7 @@ impl Element for EditorElement {
|
|||
&snapshot,
|
||||
&hitbox,
|
||||
&text_hitbox,
|
||||
editor_width,
|
||||
&mut scroll_width,
|
||||
&gutter_dimensions,
|
||||
em_width,
|
||||
|
@ -5952,12 +5973,22 @@ fn layout_line(
|
|||
row: DisplayRow,
|
||||
snapshot: &EditorSnapshot,
|
||||
style: &EditorStyle,
|
||||
text_width: Pixels,
|
||||
cx: &mut WindowContext,
|
||||
) -> LineWithInvisibles {
|
||||
let chunks = snapshot.highlighted_chunks(row..row + DisplayRow(1), true, style);
|
||||
LineWithInvisibles::from_chunks(chunks, &style.text, MAX_LINE_LEN, 1, &[], snapshot.mode, cx)
|
||||
.pop()
|
||||
.unwrap()
|
||||
LineWithInvisibles::from_chunks(
|
||||
chunks,
|
||||
&style.text,
|
||||
MAX_LINE_LEN,
|
||||
1,
|
||||
&[],
|
||||
snapshot.mode,
|
||||
text_width,
|
||||
cx,
|
||||
)
|
||||
.pop()
|
||||
.unwrap()
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue