Skip to content

Commit

Permalink
Revert "Revert "fix(input/#2883): Handle alternate input productions (#…
Browse files Browse the repository at this point in the history
…2902)""

This reverts commit a5889dd.
  • Loading branch information
bryphe committed Jan 1, 2021
1 parent a5889dd commit 425f2ac
Show file tree
Hide file tree
Showing 31 changed files with 937 additions and 616 deletions.
1 change: 1 addition & 0 deletions CHANGES_CURRENT.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
- #2895 - Completion: Fix crash on long (>1024 character) completion matches (fixes #2892)
- #2905 - CLI: HealthCheck - Re-enable output logging
- #2907 - Editor: Add configuration for document highlights and use proper theme color
- #2902 - Input: Fix remaps for characters w/o scancode (fixes #2883)

### Performance

Expand Down
9 changes: 4 additions & 5 deletions integration_test/ExCommandKeybindingNormTest.re
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,14 @@ runTest(
let input = key => {
let keyPress =
EditorInput.KeyPress.physicalKey(
~scancode=Sdl2.Scancode.ofName(key),
~keycode=Sdl2.Keycode.ofName(key),
~key,
~modifiers=EditorInput.Modifiers.none,
);
let time = Revery.Time.now();

dispatch(KeyDown(keyPress, time));
dispatch(KeyDown({key: keyPress, scancode: 1, time}));
//dispatch(TextInput(key));
dispatch(KeyUp(keyPress, time));
dispatch(KeyUp({key: keyPress, scancode: 1, time}));
};

let testFile = getAssetPath("some-test-file.txt");
Expand All @@ -49,7 +48,7 @@ runTest(
});

// Press k, which is re-bound to 'norm! j'
input("k");
input(EditorInput.Key.Character('k'));

// Verify cursor is at top of file
wait(~name="Verify cursor moved down a line", (state: State.t) => {
Expand Down
11 changes: 5 additions & 6 deletions integration_test/ExCommandKeybindingTest.re
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,14 @@ runTest(
let input = key => {
let keyPress =
EditorInput.KeyPress.physicalKey(
~scancode=Sdl2.Scancode.ofName(key),
~keycode=Sdl2.Keycode.ofName(key),
~key,
~modifiers=EditorInput.Modifiers.none,
);
let time = Revery.Time.now();

dispatch(KeyDown(keyPress, time));
dispatch(KeyDown({key: keyPress, scancode: 1, time}));
//dispatch(TextInput(key));
dispatch(KeyUp(keyPress, time));
dispatch(KeyUp({key: keyPress, scancode: 1, time}));
};

wait(~name="Initial sanity check", (state: State.t) => {
Expand All @@ -36,8 +35,8 @@ runTest(
splitCount == 1;
});

input("k");
input("k");
input(EditorInput.Key.Character('k'));
input(EditorInput.Key.Character('k'));

wait(~name="Wait for split to be created", (state: State.t) => {
let splitCount =
Expand Down
11 changes: 5 additions & 6 deletions integration_test/ExCommandKeybindingWithArgsTest.re
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,14 @@ runTest(
let input = key => {
let keyPress =
EditorInput.KeyPress.physicalKey(
~scancode=Sdl2.Scancode.ofName(key),
~keycode=Sdl2.Keycode.ofName(key),
~key=EditorInput.Key.Character(key),
~modifiers=EditorInput.Modifiers.none,
);
let time = Revery.Time.now();

dispatch(KeyDown(keyPress, time));
dispatch(KeyDown({key: keyPress, scancode: 1, time}));
//dispatch(TextInput(key));
dispatch(KeyUp(keyPress, time));
dispatch(KeyUp({key: keyPress, scancode: 1, time}));
};

let testFile = getAssetPath("some-test-file.txt");
Expand All @@ -48,8 +47,8 @@ runTest(
}
);

input("k");
input("k");
input('k');
input('k');

wait(~name="Wait for split to be created", (state: State.t) =>
switch (Selectors.getActiveBuffer(state)) {
Expand Down
21 changes: 11 additions & 10 deletions integration_test/KeySequenceJJTest.re
Original file line number Diff line number Diff line change
Expand Up @@ -17,28 +17,29 @@ runTest(
);

let input = key => {
let scancode = Sdl2.Scancode.ofName(key);
let keycode = Sdl2.Keycode.ofName(key);
let modifiers = EditorInput.Modifiers.none;

let keyPress: EditorInput.KeyPress.t =
EditorInput.KeyPress.physicalKey(~keycode, ~scancode, ~modifiers);
EditorInput.KeyPress.physicalKey(
~key=EditorInput.Key.Character(key),
~modifiers,
);
let time = Revery.Time.now();

dispatch(Model.Actions.KeyDown(keyPress, time));
dispatch(Model.Actions.KeyDown({key: keyPress, scancode: 1, time}));
//dispatch(Model.Actions.TextInput(key));
dispatch(Model.Actions.KeyUp(keyPress, time));
dispatch(Model.Actions.KeyUp({key: keyPress, scancode: 1, time}));
runEffects();
};

input("i");
input('i');
wait(~name="Mode is now insert", (state: State.t) =>
Selectors.mode(state) |> Vim.Mode.isInsert
);

input("a");
input("j");
input("j");
input('a');
input('j');
input('j');

wait(~name="Mode is back to normal", (state: State.t) =>
Selectors.mode(state) |> Vim.Mode.isNormal
Expand All @@ -64,7 +65,7 @@ runTest(

// #2601 - Make sure we're _actually_ in normal mode!
// Type another 'j' to see...
input("j");
input('j');

wait(
~name=
Expand Down
13 changes: 7 additions & 6 deletions integration_test/VimScriptLocalFunctionTest.re
Original file line number Diff line number Diff line change
Expand Up @@ -26,20 +26,21 @@ runTest(~name="VimScriptLocalFunctionTest", (dispatch, wait, runEffects) => {
runEffects();

let input = key => {
let scancode = Sdl2.Scancode.ofName(key);
let keycode = Sdl2.Keycode.ofName(key);
let modifiers = EditorInput.Modifiers.none;

let keyPress: EditorInput.KeyPress.t =
EditorInput.KeyPress.physicalKey(~scancode, ~keycode, ~modifiers);
EditorInput.KeyPress.physicalKey(
~key=EditorInput.Key.Character(key),
~modifiers,
);
let time = Revery.Time.now();

dispatch(Model.Actions.KeyDown(keyPress, time));
dispatch(Model.Actions.KeyUp(keyPress, time));
dispatch(Model.Actions.KeyDown({key: keyPress, scancode: 1, time}));
dispatch(Model.Actions.KeyUp({key: keyPress, scancode: 1, time}));
runEffects();
};

input("j");
input('j');

wait(~name="plugin notification shows up", (state: State.t) => {
let notifications = Feature_Notification.all(state.notifications);
Expand Down
21 changes: 11 additions & 10 deletions integration_test/VimSimpleRemapTest.re
Original file line number Diff line number Diff line change
Expand Up @@ -13,27 +13,28 @@ runTest(~name="VimSimpleRemapTest", (dispatch, wait, runEffects) => {
runEffects();

let input = key => {
let scancode = Sdl2.Scancode.ofName(key);
let keycode = Sdl2.Keycode.ofName(key);
let modifiers = EditorInput.Modifiers.none;

let keyPress: EditorInput.KeyPress.t =
EditorInput.KeyPress.physicalKey(~scancode, ~keycode, ~modifiers);
EditorInput.KeyPress.physicalKey(
~key=EditorInput.Key.Character(key),
~modifiers,
);
let time = Revery.Time.now();

dispatch(Model.Actions.KeyDown(keyPress, time));
dispatch(Model.Actions.KeyUp(keyPress, time));
dispatch(Model.Actions.KeyDown({key: keyPress, scancode: 1, time}));
dispatch(Model.Actions.KeyUp({key: keyPress, scancode: 1, time}));
runEffects();
};

input("i");
input('i');
wait(~name="Mode is now insert", (state: State.t) =>
Selectors.mode(state) |> Vim.Mode.isInsert
);

input("a");
input("j");
input("j");
input('a');
input('j');
input('j');

wait(~name="Mode is back to normal", (state: State.t) =>
Selectors.mode(state) |> Vim.Mode.isNormal
Expand All @@ -57,7 +58,7 @@ runTest(~name="VimSimpleRemapTest", (dispatch, wait, runEffects) => {

// #2601 - Make sure we're _actually_ in normal mode!
// Type another 'j' to see...
input("j");
input('j');

wait(
~name=
Expand Down
56 changes: 56 additions & 0 deletions integration_test/VimlRemapCmdlineTest.re
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
open Oni_Model;
open Oni_IntegrationTestLib;

runTest(~name="Viml Remap ; -> :", (dispatch, wait, runEffects) => {
wait(~name="Initial mode is normal", (state: State.t) =>
Selectors.mode(state) |> Vim.Mode.isNormal
);

dispatch(
VimExecuteCommand({allowAnimation: true, command: "nnoremap ; :"}),
);
runEffects();

let input = key => {
let modifiers = EditorInput.Modifiers.none;

let keyPress: EditorInput.KeyPress.t =
EditorInput.KeyPress.physicalKey(
~key=EditorInput.Key.Character(key),
~modifiers,
);
let time = Revery.Time.now();

dispatch(Model.Actions.KeyDown({key: keyPress, scancode: 1, time}));
dispatch(Model.Actions.KeyUp({key: keyPress, scancode: 1, time}));
runEffects();
};

// Because of our remap, the ';' semicolon
// is mapped to ':' - so sending it should open the command line.
input(';');

wait(~name="Mode switches to command line", (state: State.t) => {
Selectors.mode(state) == Vim.Mode.CommandLine
});

input('e');

wait(~name="'e' key is entered", (state: State.t) =>
switch (state.quickmenu) {
| Some(quickmenu) =>
quickmenu.inputText |> Component_InputText.value == "e"
| None => false
}
);

input('h');

wait(~name="'h' key is entered", (state: State.t) =>
switch (state.quickmenu) {
| Some(quickmenu) =>
quickmenu.inputText |> Component_InputText.value == "eh"
| None => false
}
);
});
13 changes: 7 additions & 6 deletions integration_test/dune
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@
SCMGitTest SyntaxHighlightTextMateTest SyntaxHighlightTreesitterTest
AddRemoveSplitTest TerminalSetPidTitleTest TerminalConfigurationTest
TypingBatchedTest TypingUnbatchedTest VimSimpleRemapTest
ClipboardChangeTest VimScriptLocalFunctionTest ZenModeSingleFileModeTest
ZenModeSplitTest)
VimlRemapCmdlineTest ClipboardChangeTest VimScriptLocalFunctionTest
ZenModeSingleFileModeTest ZenModeSplitTest)
(libraries Oni_CLI Oni_IntegrationTestLib reason-native-crash-utils.asan))

(install
Expand Down Expand Up @@ -54,7 +54,8 @@
SyntaxServerReadExceptionTest.exe TerminalSetPidTitleTest.exe
TerminalConfigurationTest.exe AddRemoveSplitTest.exe TypingBatchedTest.exe
TypingUnbatchedTest.exe VimScriptLocalFunctionTest.exe
VimSimpleRemapTest.exe ZenModeSingleFileModeTest.exe ZenModeSplitTest.exe
ClipboardChangeTest.exe large-c-file.c lsan.supp some-test-file.json
some-test-file.txt test.crlf test.lf utf8.txt utf8-test-file.htm
Inconsolata-Regular.ttf PlugScriptLocal.vim))
VimSimpleRemapTest.exe VimlRemapCmdlineTest.exe
ZenModeSingleFileModeTest.exe ZenModeSplitTest.exe ClipboardChangeTest.exe
large-c-file.c lsan.supp some-test-file.json some-test-file.txt test.crlf
test.lf utf8.txt utf8-test-file.htm Inconsolata-Regular.ttf
PlugScriptLocal.vim))
Loading

0 comments on commit 425f2ac

Please sign in to comment.