Merge pull request #973 from zed-industries/selections-refactor
Pull selections out of editor into selections collection
This commit is contained in:
commit
2f7eb6dbc5
22 changed files with 1998 additions and 1722 deletions
|
@ -310,7 +310,7 @@ fn open_config_file(
|
|||
mod tests {
|
||||
use super::*;
|
||||
use assets::Assets;
|
||||
use editor::{DisplayPoint, Editor};
|
||||
use editor::{Autoscroll, DisplayPoint, Editor};
|
||||
use gpui::{AssetSource, MutableAppContext, TestAppContext, ViewHandle};
|
||||
use project::{Fs, ProjectPath};
|
||||
use serde_json::json;
|
||||
|
@ -963,7 +963,9 @@ mod tests {
|
|||
.downcast::<Editor>()
|
||||
.unwrap();
|
||||
editor1.update(cx, |editor, cx| {
|
||||
editor.select_display_ranges(&[DisplayPoint::new(10, 0)..DisplayPoint::new(10, 0)], cx);
|
||||
editor.change_selections(Some(Autoscroll::Fit), cx, |s| {
|
||||
s.select_display_ranges([DisplayPoint::new(10, 0)..DisplayPoint::new(10, 0)])
|
||||
});
|
||||
});
|
||||
let editor2 = workspace
|
||||
.update(cx, |w, cx| w.open_path(file2.clone(), true, cx))
|
||||
|
@ -980,10 +982,9 @@ mod tests {
|
|||
|
||||
editor3
|
||||
.update(cx, |editor, cx| {
|
||||
editor.select_display_ranges(
|
||||
&[DisplayPoint::new(12, 0)..DisplayPoint::new(12, 0)],
|
||||
cx,
|
||||
);
|
||||
editor.change_selections(Some(Autoscroll::Fit), cx, |s| {
|
||||
s.select_display_ranges([DisplayPoint::new(12, 0)..DisplayPoint::new(12, 0)])
|
||||
});
|
||||
editor.newline(&Default::default(), cx);
|
||||
editor.newline(&Default::default(), cx);
|
||||
editor.move_down(&Default::default(), cx);
|
||||
|
@ -1124,34 +1125,37 @@ mod tests {
|
|||
// Modify file to collapse multiple nav history entries into the same location.
|
||||
// Ensure we don't visit the same location twice when navigating.
|
||||
editor1.update(cx, |editor, cx| {
|
||||
editor.select_display_ranges(&[DisplayPoint::new(15, 0)..DisplayPoint::new(15, 0)], cx)
|
||||
editor.change_selections(None, cx, |s| {
|
||||
s.select_display_ranges([DisplayPoint::new(15, 0)..DisplayPoint::new(15, 0)])
|
||||
})
|
||||
});
|
||||
|
||||
for _ in 0..5 {
|
||||
editor1.update(cx, |editor, cx| {
|
||||
editor
|
||||
.select_display_ranges(&[DisplayPoint::new(3, 0)..DisplayPoint::new(3, 0)], cx);
|
||||
editor.change_selections(None, cx, |s| {
|
||||
s.select_display_ranges([DisplayPoint::new(3, 0)..DisplayPoint::new(3, 0)])
|
||||
});
|
||||
});
|
||||
editor1.update(cx, |editor, cx| {
|
||||
editor.select_display_ranges(
|
||||
&[DisplayPoint::new(13, 0)..DisplayPoint::new(13, 0)],
|
||||
cx,
|
||||
)
|
||||
editor.change_selections(None, cx, |s| {
|
||||
s.select_display_ranges([DisplayPoint::new(13, 0)..DisplayPoint::new(13, 0)])
|
||||
})
|
||||
});
|
||||
}
|
||||
|
||||
editor1.update(cx, |editor, cx| {
|
||||
editor.transact(cx, |editor, cx| {
|
||||
editor.select_display_ranges(
|
||||
&[DisplayPoint::new(2, 0)..DisplayPoint::new(14, 0)],
|
||||
cx,
|
||||
);
|
||||
editor.change_selections(None, cx, |s| {
|
||||
s.select_display_ranges([DisplayPoint::new(2, 0)..DisplayPoint::new(14, 0)])
|
||||
});
|
||||
editor.insert("", cx);
|
||||
})
|
||||
});
|
||||
|
||||
editor1.update(cx, |editor, cx| {
|
||||
editor.select_display_ranges(&[DisplayPoint::new(1, 0)..DisplayPoint::new(1, 0)], cx)
|
||||
editor.change_selections(None, cx, |s| {
|
||||
s.select_display_ranges([DisplayPoint::new(1, 0)..DisplayPoint::new(1, 0)])
|
||||
})
|
||||
});
|
||||
workspace
|
||||
.update(cx, |w, cx| Pane::go_back(w, None, cx))
|
||||
|
@ -1177,7 +1181,7 @@ mod tests {
|
|||
let editor = item.downcast::<Editor>().unwrap();
|
||||
let (selections, scroll_position) = editor.update(cx, |editor, cx| {
|
||||
(
|
||||
editor.selected_display_ranges(cx),
|
||||
editor.selections.display_ranges(cx),
|
||||
editor.scroll_position(cx),
|
||||
)
|
||||
});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue