Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ The library also reads from console.error and reports any errors printed out whi

## History

The library maintains the list of commands run in the upper read only code editor. It also maintains a buffer of previous commands that can be accessed in the code input section by using `super+arrow up/down`. This history is stored in local storage so that you can access it between test runs. You can clear this history by using the `Clear History` button.
The library maintains the list of commands run in the upper read only code editor. It also maintains a buffer of previous commands that can be accessed in the code input section by using `ctrl+arrow up/down` (`alt+arrow up/down` on Mac). This history is stored in local storage so that you can access it between test runs. You can clear this history by using the `Clear History` button.

## Restarting Tests

Expand Down Expand Up @@ -144,3 +144,12 @@ registerCommands({
```

You can pass an object to `registerCommands` where each key is the name of the command, and the value is the function it will run when invoked.

## Shortcuts

| Key | Shortcut|
|---|---|
| Ctrl + Arrow Up/Down (Mac: Alt + Arrow Up/Down) | Navigate history |
| Ctrl + Enter (Mac: Cmd + Enter) | Submit command |
| Esc then Tab | Tab out of the command editor. Without hitting escape first, tab acts to indent |

6 changes: 5 additions & 1 deletion test-runner/src/App.css
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
height: 100vh;
display: flex;
flex-direction: column;
width: 450px;
width: 500px;
justify-content: space-between;
}

Expand Down Expand Up @@ -49,3 +49,7 @@ button:focus {
min-height: 0;
overflow: auto;
}

.tab-instruction {
font-size: 10pt;
}
4 changes: 4 additions & 0 deletions test-runner/src/CommandInput.js
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,10 @@ function CommandInput({ setInnerHTML, availableCommands }) {
</button>
<button onClick={() => axios.post("/stop")}>Stop Test</button>
</div>
<p className="tab-instruction">
Note the tab key is used to indent inside the editor. Hit esc then tab
to escape.
</p>
</>
);
}
Expand Down
17 changes: 8 additions & 9 deletions test-runner/src/Editor.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { useEffect, useCallback, useRef, useMemo } from "react";

import {
keymap,
highlightSpecialChars,
Expand All @@ -19,7 +18,7 @@ import {
gutter,
GutterMarker,
} from "@codemirror/gutter";
import { defaultKeymap } from "@codemirror/commands";
import { defaultKeymap, indentWithTab } from "@codemirror/commands";
import { bracketMatching } from "@codemirror/matchbrackets";
import { closeBrackets, closeBracketsKeymap } from "@codemirror/closebrackets";
import { searchKeymap, highlightSelectionMatches } from "@codemirror/search";
Expand Down Expand Up @@ -432,23 +431,22 @@ export default function Editor({

const previousCommandsKeyMap = [
{
key: "Ctrl-ArrowUp",
mac: "Cmd-ArrowUp",
key: "Mod-ArrowUp",
mac: "Alt-ArrowUp",
run: ctrlCursorArrowUp,
preventDefault: true,
},
{
key: "Ctrl-ArrowDown",
mac: "Cmd-ArrowDown",
key: "Mod-ArrowDown",
mac: "Alt-ArrowDown",
run: ctrlCursorArrowDown,
preventDefault: true,
},
];

const sendCommandKeyMap = [
{
key: "Ctrl-Enter",
mac: "Cmd-Enter",
key: "Mod-Enter",
run: ({ state }) => {
state.field(submitFunctionState).submit();
},
Expand Down Expand Up @@ -486,6 +484,7 @@ export default function Editor({
...completionKeymap,
...lintKeymap,
...previousCommandsKeyMap,
indentWithTab,
]),
javascript(),
autocompletion({ override: [myCompletions] }),
Expand All @@ -499,7 +498,7 @@ export default function Editor({
cursorTooltipBaseTheme,
errorUnderlineTheme,
warningUnderlineTheme,
EditorView.editable.of(!readonly),
EditorState.readOnly.of(readonly),
],
});
if (
Expand Down