Skip to content

Commit

Permalink
fix broken C-Space
Browse files Browse the repository at this point in the history
  • Loading branch information
nightwing committed Jun 15, 2024
1 parent 06c5870 commit 8b38a87
Showing 1 changed file with 9 additions and 10 deletions.
19 changes: 9 additions & 10 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { BlockCursorPlugin, hideNativeSelection } from "./block-cursor"
import { StateField, StateEffect, ChangeDesc, EditorSelection, Extension, MapMode } from "@codemirror/state"
import { showPanel, EditorView, ViewPlugin, PluginValue, ViewUpdate, keymap } from "@codemirror/view"
import * as commands from "@codemirror/commands"
import { startCompletion } from "@codemirror/autocomplete"
import { startCompletion, completionStatus } from "@codemirror/autocomplete"
import { openSearchPanel } from "@codemirror/search"

const emacsStyle = EditorView.theme({
Expand Down Expand Up @@ -65,19 +65,14 @@ const emacsPlugin = ViewPlugin.fromClass(class implements PluginValue {
}
}, {
eventHandlers: {
keydown: function (e: KeyboardEvent, view: EditorView) {
var result = this.em.handleKeyboard(e)
return !!result;
},
mousedown: function() {
this.em.$emacsMark = null
}
},
provide: plugin => {
return keymap.of([
{
any: function(view, e) {
return !!view.plugin(plugin)?.em.handleKeyboard(e)
}
}
])
}
})


Expand Down Expand Up @@ -197,6 +192,10 @@ class EmacsHandler {
handleKeyboard(e: KeyboardEvent) {
var keyData = EmacsHandler.getKey(e)
var result = this.findCommand(keyData)

if (/Up|Down/.test(keyData?.[0]) && completionStatus(this.view.state))
return;

if (result && result.command) {
var commandResult = EmacsHandler.execCommand(result.command, this, result.args, result.count)
if (commandResult === false)
Expand Down

0 comments on commit 8b38a87

Please sign in to comment.