* Report an ex-command error as a non-blocking, in-editor notification — the * same red bottom-of-editor message codemirror-vim uses for its own errors * (e.g. an unknown `:command`). The previous native `window.alert` blurred * CodeMirror, leaving Vim users unable to type until the editor was re
(message: string)
| 300 | * unavailable. (#173) |
| 301 | */ |
| 302 | function alertEditorError(message: string): void { |
| 303 | const view = useStore.getState().editorViewRef |
| 304 | const cm = view ? getCM(view) : null |
| 305 | const openNotification = ( |
| 306 | cm as unknown as { |
| 307 | openNotification?: (node: Node, opts: { bottom?: boolean; duration?: number }) => void |
| 308 | } | null |
| 309 | )?.openNotification |
| 310 | if (cm && typeof openNotification === 'function') { |
| 311 | const el = document.createElement('div') |
| 312 | el.className = 'cm-vim-message' |
| 313 | el.style.color = 'red' |
| 314 | el.style.whiteSpace = 'pre' |
| 315 | el.textContent = message |
| 316 | openNotification.call(cm, el, { bottom: true, duration: 4000 }) |
| 317 | return |
| 318 | } |
| 319 | window.alert(message) |
| 320 | focusEditorNormalMode() |
| 321 | } |
| 322 | |
| 323 | // Minimal shape of the CodeMirror-Vim adapter + state the display-line motion |
| 324 | // touches (the package's own types don't surface these helpers). |
no test coverage detected