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

Function currentEditor

src/test/helpers.ts:171–184  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

169const startOfDocument = new vs.Range(new vs.Position(0, 0), new vs.Position(0, 0));
170
171export 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}
185export function currentDoc(): vs.TextDocument {
186 return currentEditor().document;
187}

Callers 15

dart_test.test.tsFile · 0.90
dart_cli.test.tsFile · 0.90
formatDocumentFunction · 0.90
formatOnTypeFunction · 0.90
testCommandFunction · 0.90
currentDocFunction · 0.85
setTestContentFunction · 0.85
selectFunction · 0.85

Calls 1

infoMethod · 0.65

Tested by 3

formatDocumentFunction · 0.72
formatOnTypeFunction · 0.72
testCommandFunction · 0.72