changeset 13:7da0dec2dc8d

Simple bail out when legacy editors are enabled
author Ludovic Chabant <ludovic@chabant.com>
date Mon, 28 Feb 2022 22:13:09 -0800
parents 42396b88c64d
children 67468d40c903
files src/main.ts
diffstat 1 files changed, 6 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/src/main.ts	Mon Feb 28 22:11:17 2022 -0800
+++ b/src/main.ts	Mon Feb 28 22:13:09 2022 -0800
@@ -183,7 +183,12 @@
 
 	private readonly rememberFileState = async (file: TFile, view: View): Promise<void> => {
 		const scrollInfo = view.editor.getScrollInfo();
-		const stateSelectionJSON = view.editor.cm.state.selection.toJSON();
+		const stateSelection = view.editor.cm.state.selection;
+		if (stateSelection == undefined) {
+			// Legacy editor is in use, let's ignore
+			return;
+		}
+		const stateSelectionJSON = stateSelection.toJSON();
 		const stateData = {'scrollInfo': scrollInfo, 'selection': stateSelectionJSON};
 
 		var existingFile = this.data.rememberedFiles[file.path];