comparison src/main.ts @ 41:aa9bc7754c5d

Fix typos in debug log messages
author Ludovic Chabant <ludovic@chabant.com>
date Wed, 20 Sep 2023 17:19:11 -0700
parents 96e86650043b
children 7e981d54a055
comparison
equal deleted inserted replaced
40:96e86650043b 41:aa9bc7754c5d
153 const filePath = (leaf.view as MarkdownView).file.path; 153 const filePath = (leaf.view as MarkdownView).file.path;
154 const viewId = this.getUniqueViewId(leaf.view as ViewWithID); 154 const viewId = this.getUniqueViewId(leaf.view as ViewWithID);
155 if (viewId != undefined) { 155 if (viewId != undefined) {
156 var uninstaller = this._viewUninstallers[viewId]; 156 var uninstaller = this._viewUninstallers[viewId];
157 if (uninstaller) { 157 if (uninstaller) {
158 console.debug(`RememberedFileState: uninstalling hooks for view ${viewId}`, filePath); 158 console.debug(`RememberFileState: uninstalling hooks for view ${viewId}`, filePath);
159 uninstaller(leaf.view); 159 uninstaller(leaf.view);
160 ++numViews; 160 ++numViews;
161 } else { 161 } else {
162 console.debug("RememberedFileState: found markdown view without an uninstaller!", filePath); 162 console.debug("RememberFileState: found markdown view without an uninstaller!", filePath);
163 } 163 }
164 // Clear the ID so we don't get confused if the plugin 164 // Clear the ID so we don't get confused if the plugin
165 // is re-enabled later. 165 // is re-enabled later.
166 this.clearUniqueViewId(leaf.view as ViewWithID); 166 this.clearUniqueViewId(leaf.view as ViewWithID);
167 } else { 167 } else {
168 console.debug("RememberedFileState: found markdown view without an ID!", filePath); 168 console.debug("RememberFileState: found markdown view without an ID!", filePath);
169 } 169 }
170 }); 170 });
171 console.debug(`RememberedFileState: unregistered ${numViews} view callbacks`); 171 console.debug(`RememberFileState: unregistered ${numViews} view callbacks`);
172 this._viewUninstallers = {}; 172 this._viewUninstallers = {};
173 this._lastOpenFiles = {}; 173 this._lastOpenFiles = {};
174 174
175 // Run global unhooks. 175 // Run global unhooks.
176 this._globalUninstallers.forEach((cb) => cb()); 176 this._globalUninstallers.forEach((cb) => cb());
189 var viewId = this.getUniqueViewId(view as unknown as ViewWithID, true); 189 var viewId = this.getUniqueViewId(view as unknown as ViewWithID, true);
190 if (viewId in this._viewUninstallers) { 190 if (viewId in this._viewUninstallers) {
191 return; 191 return;
192 } 192 }
193 193
194 console.debug(`RememberedFileState: registering callback on view ${viewId}`, filePath); 194 console.debug(`RememberFileState: registering callback on view ${viewId}`, filePath);
195 const _this = this; 195 const _this = this;
196 var uninstall = around(view, { 196 var uninstall = around(view, {
197 onUnloadFile: function(next) { 197 onUnloadFile: function(next) {
198 return async function (unloaded: TFile) { 198 return async function (unloaded: TFile) {
199 _this.rememberFileState(unloaded, this); 199 _this.rememberFileState(unloaded, this);
208 // will outlive it if it gets deactivated. So let's find it, and 208 // will outlive it if it gets deactivated. So let's find it, and
209 // do nothing if we don't find it. 209 // do nothing if we don't find it.
210 // @ts-ignore 210 // @ts-ignore
211 var plugin: RememberFileStatePlugin = app.plugins.getPlugin("obsidian-remember-file-state"); 211 var plugin: RememberFileStatePlugin = app.plugins.getPlugin("obsidian-remember-file-state");
212 if (plugin) { 212 if (plugin) {
213 console.debug(`RememberedFileState: unregistering view ${viewId} callback`, filePath); 213 console.debug(`RememberFileState: unregistering view ${viewId} callback`, filePath);
214 delete plugin._viewUninstallers[viewId]; 214 delete plugin._viewUninstallers[viewId];
215 delete plugin._lastOpenFiles[viewId]; 215 delete plugin._lastOpenFiles[viewId];
216 uninstall(); 216 uninstall();
217 } else { 217 } else {
218 console.debug( 218 console.debug(
219 "RememberedFileState: plugin was unloaded, ignoring unregister"); 219 "RememberFileState: plugin was unloaded, ignoring unregister");
220 } 220 }
221 }); 221 });
222 } 222 }
223 223
224 private readonly onFileOpen = async ( 224 private readonly onFileOpen = async (
298 298
299 // If we need to keep the number of remembered files under a maximum, 299 // If we need to keep the number of remembered files under a maximum,
300 // do it now. 300 // do it now.
301 this.forgetExcessFiles(); 301 this.forgetExcessFiles();
302 } 302 }
303 console.debug("RememberedFileState: remembered state for:", file.path, stateData); 303 console.debug("RememberFileState: remembered state for:", file.path, stateData);
304 } 304 }
305 305
306 private readonly getState = function(view: MarkdownView) { 306 private readonly getState = function(view: MarkdownView) {
307 // Save scrolling position (Obsidian API only gives vertical position). 307 // Save scrolling position (Obsidian API only gives vertical position).
308 const scrollInfo = {top: view.currentMode.getScroll(), left: 0}; 308 const scrollInfo = {top: view.currentMode.getScroll(), left: 0};