@@ -9,8 +9,8 @@ use helix_core::{
9 object, pos_at_coords,
9 object, pos_at_coords,
10 regex::{self, Regex},
10 regex::{self, Regex},
11 register::Register,
11 register::Register,
12− search, selection, LineEnding, Position, Range, Rope, RopeGraphemes, RopeSlice, Selection,
12+ search, selection, surround, textobject, LineEnding, Position, Range, Rope, RopeGraphemes,
13− SmallVec, Tendril, Transaction,
13+ RopeSlice, Selection, SmallVec, Tendril, Transaction,
16use helix_view::{
16use helix_view::{
@@ -78,7 +78,9 @@ impl<'a> Context<'a> {
80 pub fn on_next_key_mode(&mut self, map: HashMap<KeyEvent, fn(&mut Context)>) {
80 pub fn on_next_key_mode(&mut self, map: HashMap<KeyEvent, fn(&mut Context)>) {
81+ let count = self.count;
81 self.on_next_key(move |cx, event| {
82 self.on_next_key(move |cx, event| {
82 cx.editor.autoinfo = None;
84 cx.editor.autoinfo = None;
83 if let Some(func) = map.get(&event) {
85 if let Some(func) = map.get(&event) {
@@ -3337,24 +3339,6 @@ fn jump_backward(cx: &mut Context) {
3340−fn window_mode(cx: &mut Context) {
3341− cx.on_next_key(move |cx, event| {
3343− code: KeyCode::Char(ch),
3348− 'w' => rotate_view(cx),
3358fn rotate_view(cx: &mut Context) {
3342fn rotate_view(cx: &mut Context) {
3359 cx.editor.focus_next()
3343 cx.editor.focus_next()
@@ -3443,62 +3427,12 @@ fn view_mode(cx: &mut Context) {
3446−fn left_bracket_mode(cx: &mut Context) {
3430+fn select_textobject_around(cx: &mut Context) {
3447− cx.on_next_key(move |cx, event| {
3431+ select_textobject(cx, textobject::TextObject::Around);
3449− code: KeyCode::Char(ch),
3454− 'd' => goto_prev_diag(cx),
3455− 'D' => goto_first_diag(cx),
3462−fn right_bracket_mode(cx: &mut Context) {
3463− cx.on_next_key(move |cx, event| {
3465− code: KeyCode::Char(ch),
3470− 'd' => goto_next_diag(cx),
3471− 'D' => goto_last_diag(cx),
3478−use helix_core::surround;
3479−use helix_core::textobject;
3481−fn match_mode(cx: &mut Context) {
3434+fn select_textobject_inner(cx: &mut Context) {
3482− let count = cx.count;
3483− cx.on_next_key(move |cx, event| {
3485− code: KeyCode::Char(ch),
3489− // FIXME: count gets reset because of cx.on_next_key()
3492− 'm' => match_brackets(cx),
3493− 's' => surround_add(cx),
3494− 'r' => surround_replace(cx),
3495− 'd' => surround_delete(cx),
3496− 'a' => select_textobject(cx, textobject::TextObject::Around),
3497− 'i' => select_textobject(cx, textobject::TextObject::Inside),
3435+ select_textobject(cx, textobject::TextObject::Inside);
3504fn select_textobject(cx: &mut Context, objtype: textobject::TextObject) {
3438fn select_textobject(cx: &mut Context, objtype: textobject::TextObject) {
@@ -3719,7 +3653,7 @@ mode_info! {
3721mode_info! {
3655mode_info! {
3722− /// goto mode
3656+ /// goto
3724 /// When specified with a count, it will go to that line without entering the mode.
3658 /// When specified with a count, it will go to that line without entering the mode.
3725 goto_mode, GOTO_MODE, goto_prehook,
3659 goto_mode, GOTO_MODE, goto_prehook,
@@ -3750,3 +3684,51 @@ mode_info! {
3750 /// last accessed file
3684 /// last accessed file
3751 "a" => goto_last_accessed_file,
3685 "a" => goto_last_accessed_file,
3690+ window_mode, WINDOW_MODE,
3692+ "w" => rotate_view,
3693+ /// horizontal split
3703+ match_mode, MATCH_MODE,
3704+ /// matching character
3705+ "m" => match_brackets,
3707+ "s" => surround_add,
3708+ /// surround replace
3709+ "r" => surround_replace,
3710+ /// surround delete
3711+ "d" => surround_delete,
3713+ "a" => select_textobject_around,
3715+ "i" => select_textobject_inner,
3719+ /// select to previous
3720+ left_bracket_mode, LEFT_BRACKET_MODE,
3721+ /// previous diagnostic
3722+ "d" => goto_prev_diag,
3723+ /// diagnostic (first)
3724+ "D" => goto_first_diag,
3729+ right_bracket_mode, RIGHT_BRACKET_MODE,
3731+ "d" => goto_next_diag,
3732+ /// diagnostic (last)
3733+ "D" => goto_last_diag,