-
Notifications
You must be signed in to change notification settings - Fork 280
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
* Add paste command + effect handler * Wire up clipboard API * Formatting * Add API for setting clipboard in tests * Add Clipboard tests * Fix multi-line test * formatting * Add an 'insertMode' to the when clause for keybindings * Add when condition for insertMode * Fix formatting
- Loading branch information
Showing
12 changed files
with
253 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
open Oni_Model; | ||
open Oni_IntegrationTestLib; | ||
|
||
runTest( | ||
~name="InsertMode test - effects batched to runEffects", | ||
(dispatch, wait, runEffects) => { | ||
wait(~name="Initial mode is normal", (state: State.t) => | ||
state.mode == Vim.Types.Normal | ||
); | ||
|
||
dispatch(KeyboardInput("i")); | ||
|
||
wait(~name="Mode switches to insert", (state: State.t) => | ||
state.mode == Vim.Types.Insert | ||
); | ||
|
||
setClipboard(None); | ||
|
||
/* Simulate multiple events getting dispatched before running effects */ | ||
dispatch(KeyboardInput("A")); | ||
dispatch(Command("editor.action.clipboardPasteAction")); | ||
dispatch(KeyboardInput("B")); | ||
|
||
runEffects(); | ||
|
||
wait(~name="Buffer shows AB", (state: State.t) => | ||
switch (Selectors.getActiveBuffer(state)) { | ||
| None => false | ||
| Some(buf) => | ||
let line = Buffer.getLine(buf, 0); | ||
Log.info("Current line is: |" ++ line ++ "|"); | ||
String.equal(line, "AB"); | ||
} | ||
); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
open Oni_Model; | ||
open Oni_IntegrationTestLib; | ||
|
||
runTest( | ||
~name="InsertMode test - effects batched to runEffects", | ||
(dispatch, wait, runEffects) => { | ||
wait(~name="Initial mode is normal", (state: State.t) => | ||
state.mode == Vim.Types.Normal | ||
); | ||
|
||
dispatch(KeyboardInput("i")); | ||
|
||
wait(~name="Mode switches to insert", (state: State.t) => | ||
state.mode == Vim.Types.Insert | ||
); | ||
|
||
setClipboard(Some("def\nghi")); | ||
|
||
dispatch(KeyboardInput("A")); | ||
dispatch(Command("editor.action.clipboardPasteAction")); | ||
dispatch(KeyboardInput("B")); | ||
|
||
runEffects(); | ||
|
||
wait(~name="Buffer is correct", (state: State.t) => | ||
switch (Selectors.getActiveBuffer(state)) { | ||
| None => false | ||
| Some(buf) => | ||
let line1 = Buffer.getLine(buf, 0); | ||
let line2 = Buffer.getLine(buf, 1); | ||
Log.info("Line1 is: " ++ line1 ++ "|"); | ||
Log.info("Line2 is: " ++ line2 ++ "|"); | ||
String.equal(line1, "Adef") && String.equal(line2, "ghiB"); | ||
} | ||
); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
open Oni_Model; | ||
open Oni_IntegrationTestLib; | ||
|
||
runTest( | ||
~name="InsertMode test - effects batched to runEffects", | ||
(dispatch, wait, runEffects) => { | ||
wait(~name="Initial mode is normal", (state: State.t) => | ||
state.mode == Vim.Types.Normal | ||
); | ||
|
||
dispatch(KeyboardInput("i")); | ||
|
||
wait(~name="Mode switches to insert", (state: State.t) => | ||
state.mode == Vim.Types.Insert | ||
); | ||
|
||
setClipboard(Some("def")); | ||
|
||
/* Simulate multiple events getting dispatched before running effects */ | ||
dispatch(KeyboardInput("A")); | ||
dispatch(Command("editor.action.clipboardPasteAction")); | ||
dispatch(KeyboardInput("B")); | ||
|
||
runEffects(); | ||
|
||
wait(~name="Buffer shows AdefB", (state: State.t) => | ||
switch (Selectors.getActiveBuffer(state)) { | ||
| None => false | ||
| Some(buf) => | ||
let line = Buffer.getLine(buf, 0); | ||
Log.info("Current line is: |" ++ line ++ "|"); | ||
String.equal(line, "AdefB"); | ||
} | ||
); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
open Oni_Model; | ||
open Oni_IntegrationTestLib; | ||
|
||
runTest(~name="RegressionVspEmpty", (_, wait, _) => { | ||
wait(~name="Wait for split to be created 1", (state: State.t) => { | ||
let splitCount = | ||
state.windowManager.windowTree |> WindowTree.getSplits |> List.length; | ||
splitCount == 1; | ||
}); | ||
|
||
Vim.command("e test.txt"); | ||
|
||
/* :vsp with no arguments should create a second split w/ same buffer */ | ||
Vim.command("vsp"); | ||
|
||
wait(~name="Wait for split to be created", (state: State.t) => { | ||
let splitCount = | ||
state.windowManager.windowTree |> WindowTree.getSplits |> List.length; | ||
|
||
splitCount == 2; | ||
}); | ||
|
||
/* Validate the editors all have same buffer id */ | ||
wait(~name="Wait for split to be created", (state: State.t) => { | ||
let splits = WindowTree.getSplits(state.windowManager.windowTree); | ||
|
||
let firstSplit = List.nth(splits, 0); | ||
let secondSplit = List.nth(splits, 1); | ||
|
||
let firstActiveEditor = | ||
Selectors.getEditorGroupById(state, firstSplit.editorGroupId) | ||
|> Selectors.getActiveEditor; | ||
|
||
let secondActiveEditor = | ||
Selectors.getEditorGroupById(state, secondSplit.editorGroupId) | ||
|> Selectors.getActiveEditor; | ||
|
||
switch (firstActiveEditor, secondActiveEditor) { | ||
| (Some(e1), Some(e2)) => | ||
print_endline("e1 buffer id: " ++ string_of_int(e1.bufferId)); | ||
print_endline("e2 buffer id: " ++ string_of_int(e2.bufferId)); | ||
e1.bufferId == e2.bufferId; | ||
| _ => false | ||
}; | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters