Skip to content

Commit 869ede2

Browse files
authored
Merge pull request #3477 from obsidian-tasks-group/fix-3475-auto-suggest-traceback
fix: Suppress Tasks Auto-Suggest in Task-Board plugin modal (#3475)
2 parents b7e0cf4 + 4a5b941 commit 869ede2

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

src/Suggestor/EditorSuggestorPopup.ts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,14 @@ export class EditorSuggestor extends EditorSuggest<SuggestInfoWithContext> {
4545

4646
onTrigger(cursor: EditorPosition, editor: Editor, _file: TFile): EditorSuggestTriggerInfo | null {
4747
if (!this.settings.autoSuggestInEditor) return null;
48+
49+
if (_file === undefined) {
50+
// We won't be able to save any changes, so tell Obsidian that we cannot make suggestions.
51+
// This allows other plugins, such as Natural Language Dates, to have the opportunity
52+
// to make suggestions.
53+
return null;
54+
}
55+
4856
const line = editor.getLine(cursor.line);
4957
if (canSuggestForLine(line, cursor, editor)) {
5058
return {
@@ -60,6 +68,13 @@ export class EditorSuggestor extends EditorSuggest<SuggestInfoWithContext> {
6068
}
6169

6270
getSuggestions(context: EditorSuggestContext): SuggestInfoWithContext[] {
71+
if (context.file === undefined) {
72+
// If the editor isn't a real file, we won't be able to locate
73+
// the task line where the cursor is, so won't be able to make any
74+
// suggestions:
75+
return [] as SuggestInfoWithContext[];
76+
}
77+
6378
const line = context.query;
6479
const currentCursor = context.editor.getCursor();
6580
const allTasks = this.plugin.getTasks();

0 commit comments

Comments
 (0)