comparison src/main.ts @ 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 a50ef39473b6
comparison
equal deleted inserted replaced
12:42396b88c64d 13:7da0dec2dc8d
181 } 181 }
182 } 182 }
183 183
184 private readonly rememberFileState = async (file: TFile, view: View): Promise<void> => { 184 private readonly rememberFileState = async (file: TFile, view: View): Promise<void> => {
185 const scrollInfo = view.editor.getScrollInfo(); 185 const scrollInfo = view.editor.getScrollInfo();
186 const stateSelectionJSON = view.editor.cm.state.selection.toJSON(); 186 const stateSelection = view.editor.cm.state.selection;
187 if (stateSelection == undefined) {
188 // Legacy editor is in use, let's ignore
189 return;
190 }
191 const stateSelectionJSON = stateSelection.toJSON();
187 const stateData = {'scrollInfo': scrollInfo, 'selection': stateSelectionJSON}; 192 const stateData = {'scrollInfo': scrollInfo, 'selection': stateSelectionJSON};
188 193
189 var existingFile = this.data.rememberedFiles[file.path]; 194 var existingFile = this.data.rememberedFiles[file.path];
190 if (existingFile) { 195 if (existingFile) {
191 existingFile.lastSavedTime = Date.now(); 196 existingFile.lastSavedTime = Date.now();