- I have checked the troubleshooting
Bug report
Is it intended behavior that the editor gets unloaded when there are no matching notes during a search?
When the editor is unloaded, any event listeners or settings applied to the editor via inkdrop.getActiveEditor()
or inkdrop.onEditorLoad((editor) => ...)
are cleared.
To work around this, it seems necessary to reinitialize in onEditorUnload
like the example below:
onEditorLoad((editor) => {
editor.cm.setOption("cursorBlinkRate", 0);
}, true);
const onEditorLoad = (func, isReAttach) => {
const editor = inkdrop.activeEditor;
if (editor != null) {
func(editor);
} else {
inkdrop.onEditorLoad((editor) => func(editor));
}
if (isReAttach) {
inkdrop.onEditorUnload(() => reAttach(func));
}
};
const reAttach = (func) => {
const editor = inkdrop.getActiveEditor();
if (editor == null) {
setTimeout(() => reAttach(func), 1000);
return;
}
func(editor);
};
In my case, the table-editor
plugin was affected, but I was able to fix it with the following modification:
diff --git a/src/index.js b/src/index.js
index 0376a5f..862e55d 100644
--- a/src/index.js
+++ b/src/index.js
@@ -39,11 +39,22 @@ export function activate() {
subscriptions.add(
inkdrop.onEditorUnload(() => {
- editor.dispose();
+ reAttach();
}),
);
}
+function reAttach() {
+ const activeEditor = inkdrop.getActiveEditor();
+ if (activeEditor == null) {
+ console.log('reattache ...');
+ setTimeout(() => reAttach(), 1000);
+ return;
+ }
+ console.log('reattache ... done');
+ editor = new Editor(activeEditor.cm);
+}
+
export function deactivate() {
subscriptions.dispose();
editor.dispose();
Environment
- Platform:
- Platform version: Sonoma 14.7.1
- App Version: 5.11.4
How to reproduce
- Search using a word that yields no results.