Skip to content

Commit

Permalink
test
Browse files Browse the repository at this point in the history
  • Loading branch information
nightwing committed Jun 15, 2024
1 parent 79ca967 commit a1be1db
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 5 deletions.
2 changes: 0 additions & 2 deletions dev/test.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@
<meta charset=utf8>
<title>CodeMirror view tests</title>

<link rel=stylesheet href="mocha/mocha.css">

<h1>CodeMirror view tests</h1>

<div id="workspace" style="opacity: 0; position: fixed; top: 0; left: 0; width: 20em;"></div>
Expand Down
2 changes: 1 addition & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ const emacsStyle = EditorView.theme({
})

const emacsPlugin = ViewPlugin.fromClass(class implements PluginValue {
public view: EditorView;
public view: EditorView;
public status = ""
public em: EmacsHandler
blockCursor: BlockCursorPlugin
Expand Down
9 changes: 7 additions & 2 deletions test/webtest-emacs.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { emacs } from "../src/index"
import { EditorState, EditorSelection } from "@codemirror/state";
import {indentWithTab} from "@codemirror/commands";

console.log("-----------------------------")

describe("Emacs keybinding", () => {
/**@type {HTMLDivElement}*/
Expand Down Expand Up @@ -86,6 +87,10 @@ describe("Emacs keybinding", () => {
// without calling refresh cursor movement commands of codemirror 6 do not work
view.measure()
view.contentDOM.focus()

var plugins = view.plugins.filter(x=>x.value.em)
if (plugins.length != 1) throw new Error("Couldn't find emacs")
view.em = plugins[0].value.em;
}
function getSelectedText() {
var state = editor.state
Expand Down Expand Up @@ -126,8 +131,8 @@ describe("Emacs keybinding", () => {

test("exchangePointAndMark with mark set", function() {
initEditor('foo');
editor.pushEmacsMark({row: 0, column: 1});
editor.pushEmacsMark({row: 0, column: 2});
editor.em.pushEmacsMark({row: 0, column: 1});
editor.em.pushEmacsMark({row: 0, column: 2});
typeKey('Ctrl-x', 'Ctrl-x');
typeKey('Ctrl-x', 'Ctrl-x');
typeKey('Ctrl-x', 'Ctrl-x');
Expand Down

0 comments on commit a1be1db

Please sign in to comment.