diff --git a/.gitignore b/.gitignore index fdf4f5a..82ad7c2 100644 --- a/.gitignore +++ b/.gitignore @@ -22,3 +22,4 @@ data.json # Exclude macOS Finder (System Explorer) View States .DS_Store +/.vs diff --git a/src/modules/WidgetExtension.ts b/src/modules/WidgetExtension.ts index 879ed9a..7a59222 100644 --- a/src/modules/WidgetExtension.ts +++ b/src/modules/WidgetExtension.ts @@ -389,8 +389,12 @@ class FloatingWidget extends WidgetType { return; } - // Grab the selected text from the stored selection info - const selectedText = this.selectionInfo?.text ?? ""; + // Grab the selected text from the stored selection info. + // If nothing was selected, use the entire document as context. + let selectedText = this.selectionInfo?.text ?? ""; + if (!selectedText && this.outerEditorView) { + selectedText = this.outerEditorView.state.doc.toString(); + } // Show loader this.toggleLoading(true);