Add select.rs to the new helix directory
This commit is contained in:
parent
63771f1f1b
commit
5d4cd65c6b
3 changed files with 1 additions and 30 deletions
|
@ -1,4 +1,5 @@
|
||||||
mod object;
|
mod object;
|
||||||
|
mod select;
|
||||||
|
|
||||||
use editor::{DisplayPoint, Editor, movement};
|
use editor::{DisplayPoint, Editor, movement};
|
||||||
use gpui::{Action, actions};
|
use gpui::{Action, actions};
|
||||||
|
|
|
@ -7,7 +7,6 @@ mod paste;
|
||||||
pub(crate) mod repeat;
|
pub(crate) mod repeat;
|
||||||
mod scroll;
|
mod scroll;
|
||||||
pub(crate) mod search;
|
pub(crate) mod search;
|
||||||
mod select;
|
|
||||||
pub mod substitute;
|
pub mod substitute;
|
||||||
mod toggle_comments;
|
mod toggle_comments;
|
||||||
pub(crate) mod yank;
|
pub(crate) mod yank;
|
||||||
|
|
|
@ -1,29 +0,0 @@
|
||||||
use text::SelectionGoal;
|
|
||||||
use ui::{Context, Window};
|
|
||||||
|
|
||||||
use crate::{Vim, object::Object};
|
|
||||||
|
|
||||||
impl Vim {
|
|
||||||
/// Selects the text object each cursor is over.
|
|
||||||
pub fn select_object(
|
|
||||||
&mut self,
|
|
||||||
object: Object,
|
|
||||||
around: bool,
|
|
||||||
window: &mut Window,
|
|
||||||
cx: &mut Context<Self>,
|
|
||||||
) {
|
|
||||||
self.stop_recording(cx);
|
|
||||||
self.update_editor(window, cx, |_, editor, window, cx| {
|
|
||||||
editor.change_selections(Default::default(), window, cx, |s| {
|
|
||||||
s.move_with(|map, selection| {
|
|
||||||
let Some(range) = object.helix_range(map, selection.clone(), around) else {
|
|
||||||
return;
|
|
||||||
};
|
|
||||||
|
|
||||||
selection.set_head(range.end, SelectionGoal::None);
|
|
||||||
selection.start = range.start;
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
Loading…
Add table
Add a link
Reference in a new issue