Introduce DisplayRow, MultiBufferRow newtypes and BufferRow type alias (#11656)
Part of https://github.com/zed-industries/zed/issues/8081 To avoid confusion and bugs when converting between various row `u32`'s, use different types for each. Further PRs should split `Point` into buffer and multi buffer variants and make the code more readable. Release Notes: - N/A --------- Co-authored-by: Piotr <piotr@zed.dev>
This commit is contained in:
parent
38f110852f
commit
df41435d1a
46 changed files with 1726 additions and 1220 deletions
|
@ -25,6 +25,7 @@ use editor::Bias;
|
|||
use gpui::{actions, ViewContext, WindowContext};
|
||||
use language::{Point, SelectionGoal};
|
||||
use log::error;
|
||||
use multi_buffer::MultiBufferRow;
|
||||
use workspace::Workspace;
|
||||
|
||||
use self::{
|
||||
|
@ -314,7 +315,7 @@ fn insert_line_above(_: &mut Workspace, _: &InsertLineAbove, cx: &mut ViewContex
|
|||
.collect();
|
||||
let edits = selection_start_rows.into_iter().map(|row| {
|
||||
let indent = snapshot
|
||||
.indent_size_for_line(row)
|
||||
.indent_size_for_line(MultiBufferRow(row))
|
||||
.chars()
|
||||
.collect::<String>();
|
||||
let start_of_line = Point::new(row, 0);
|
||||
|
@ -349,10 +350,10 @@ fn insert_line_below(_: &mut Workspace, _: &InsertLineBelow, cx: &mut ViewContex
|
|||
.collect();
|
||||
let edits = selection_end_rows.into_iter().map(|row| {
|
||||
let indent = snapshot
|
||||
.indent_size_for_line(row)
|
||||
.indent_size_for_line(MultiBufferRow(row))
|
||||
.chars()
|
||||
.collect::<String>();
|
||||
let end_of_line = Point::new(row, snapshot.line_len(row));
|
||||
let end_of_line = Point::new(row, snapshot.line_len(MultiBufferRow(row)));
|
||||
(end_of_line..end_of_line, "\n".to_string() + &indent)
|
||||
});
|
||||
editor.change_selections(Some(Autoscroll::fit()), cx, |s| {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue