| 169 | const startOfDocument = new vs.Range(new vs.Position(0, 0), new vs.Position(0, 0)); |
| 170 | |
| 171 | export function currentEditor(): vs.TextEditor { |
| 172 | let editor = vs.window.activeTextEditor; |
| 173 | if (editor?.document.uri.scheme !== "file") { |
| 174 | const firstEditor = vs.window.visibleTextEditors.find((e) => e.document.uri.scheme === "file"); |
| 175 | if (firstEditor) |
| 176 | logger.info(`Current active editor is not a file (${editor ? editor.document.uri : "none"}) so using first visible editor (${firstEditor.document.uri})`); |
| 177 | editor = firstEditor; |
| 178 | } |
| 179 | |
| 180 | if (!editor) |
| 181 | throw new Error("There is no active or visible editor"); |
| 182 | |
| 183 | return editor; |
| 184 | } |
| 185 | export function currentDoc(): vs.TextDocument { |
| 186 | return currentEditor().document; |
| 187 | } |