Skip to content

Commit 90f2ac5

Browse files
committed
fix: check only if the file exists when checking
1 parent 5546682 commit 90f2ac5

File tree

1 file changed

+13
-7
lines changed

1 file changed

+13
-7
lines changed

src/main.ts

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -325,18 +325,24 @@ export default class LinterPlugin extends Plugin {
325325
saveCommandDefinition.checkCallback = (checking: boolean) => {
326326
this.originalSaveCallback(checking);
327327

328-
if (this.settings.lintOnSave && this.isEnabled) {
329-
const editor = this.getEditor();
330-
if (editor) {
331-
const file = this.app.workspace.getActiveFile();
332-
if (!this.shouldIgnoreFile(file) && this.isMarkdownFile(file) && editor.cm) {
333-
if (!checking) {
328+
const editor = this.getEditor();
329+
const file = this.app.workspace.getActiveFile();
330+
331+
if (checking) {
332+
if (editor && file) {
333+
return true;
334+
}
335+
} else {
336+
if (this.settings.lintOnSave && this.isEnabled) {
337+
if (editor) {
338+
if (!this.shouldIgnoreFile(file) && this.isMarkdownFile(file) && editor.cm) {
334339
void this.runLinterEditor(editor);
335340
}
336-
return true;
337341
}
338342
}
339343
}
344+
345+
340346
};
341347
}
342348

0 commit comments

Comments
 (0)