File tree Expand file tree Collapse file tree 1 file changed +15
-0
lines changed
Expand file tree Collapse file tree 1 file changed +15
-0
lines changed Original file line number Diff line number Diff 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 ( ) ;
You can’t perform that action at this time.
0 commit comments