feat: implement selection-first multi-target editing
This commit is contained in:
+51
-2
@@ -155,6 +155,55 @@ Vamp.command("healthy") { |editor, args| editor.replace "healthy #{args}" }
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn configured_selection_actions_edit_together_and_invoke_plugins_once() {
|
||||
let fixture = Fixture::new();
|
||||
fixture.file("buffer.txt", " alpha\nb\n gamma");
|
||||
fixture.file(
|
||||
"once.rb",
|
||||
r#"
|
||||
Vamp.plugin "once", requires: ["text"]
|
||||
Vamp.command("once") { |editor, _| editor.insert "!" }
|
||||
"#,
|
||||
);
|
||||
let mut session = fixture.open(
|
||||
r#"
|
||||
Vamp.configure do |config|
|
||||
config.plugin "once.rb"
|
||||
config.bind "r", config.core.select_lines, mode: config.modes.visual
|
||||
config.bind "z", config.core.clone_below
|
||||
config.bind "f", "once"
|
||||
end
|
||||
"#,
|
||||
);
|
||||
session.handle(Input::Char('v'));
|
||||
session.handle(Input::Char('j'));
|
||||
session.handle(Input::Char('j'));
|
||||
session.handle(Input::Char('r'));
|
||||
assert_eq!(session.editor().selection_count(), 3);
|
||||
session.handle(Input::Char('A'));
|
||||
session.handle(Input::Char('?'));
|
||||
session.handle(Input::Escape);
|
||||
assert_eq!(session.editor().lines(), &[" alpha?", "b?", " gamma?"]);
|
||||
session.handle(Input::Char('u'));
|
||||
assert_eq!(session.editor().lines(), &[" alpha", "b", " gamma"]);
|
||||
assert_eq!(session.editor().selection_count(), 3);
|
||||
session.handle(Input::Char('f'));
|
||||
assert_eq!(session.editor().selection_count(), 1);
|
||||
assert_eq!(
|
||||
session
|
||||
.editor()
|
||||
.lines()
|
||||
.iter()
|
||||
.map(|line| line.matches('!').count())
|
||||
.sum::<usize>(),
|
||||
1
|
||||
);
|
||||
session.handle(Input::Char('u'));
|
||||
assert_eq!(session.editor().lines(), &[" alpha", "b", " gamma"]);
|
||||
assert_eq!(session.editor().selection_count(), 3);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn startup_rejection_installs_no_commands_and_keeps_other_plugins_and_core() {
|
||||
let fixture = Fixture::new();
|
||||
@@ -468,7 +517,7 @@ end
|
||||
session.handle(Input::Ctrl('v'));
|
||||
assert_eq!(session.editor().mode(), crate::editor::Mode::Visual);
|
||||
session.handle(Input::Ctrl('f'));
|
||||
assert_eq!(session.editor().selection().unwrap().end.column, 3);
|
||||
assert_eq!(session.editor().selections()[0].end.column, 3);
|
||||
session.handle(Input::Ctrl('c'));
|
||||
assert_eq!(session.editor().mode(), crate::editor::Mode::Normal);
|
||||
assert!(!session.editor().dirty());
|
||||
@@ -491,7 +540,7 @@ end
|
||||
session.handle(Input::Ctrl('v'));
|
||||
session.handle(Input::Ctrl('g'));
|
||||
assert_eq!(session.editor().mode(), crate::editor::Mode::Normal);
|
||||
assert_eq!(session.editor().selection(), None);
|
||||
assert!(session.editor().selections().is_empty());
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
||||
Reference in New Issue
Block a user