MCPcopy Create free account
hub / github.com/Dart-Code/Dart-Code / getActiveRealFileEditor

Function getActiveRealFileEditor

src/shared/vscode/editors.ts:18–32  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

16/// Gets the "active" file:// TextEditor, excluding any output: panes that
17/// might be in the list.
18export function getActiveRealFileEditor(): vs.TextEditor | undefined {
19 let editor = vs.window.activeTextEditor;
20 // It's possible the "active editor" is actually an Output pane, so
21 // try falling back to a single visible (file-scheme) editor if there is one.
22 if (editor?.document.uri.scheme !== "file") {
23 const fileEditors = vs.window.visibleTextEditors.filter((e) => e.document.uri.scheme === "file");
24 if (fileEditors.length === 1) {
25 console.log(`Falling back from ${editor?.document.uri} to ${fileEditors[0].document.uri}`);
26 editor = fileEditors[0];
27 }
28 }
29 return editor?.document.uri.scheme === "file"
30 ? editor
31 : undefined;
32}
33
34export function findVisibleEditor(uri: URI) {
35 const uriKey = uriComparisonString(uri);

Calls 1

logMethod · 0.45

Tested by

no test coverage detected