MCPcopy Create free account
hub / github.com/REditorSupport/vscode-R / reuseOrCreateEditor

Function reuseOrCreateEditor

src/rstudioapi.ts:451–476  ·  view source on GitHub ↗
(targetDocument: TextDocument)

Source from the content-addressed store, hash-verified

449}
450
451async function reuseOrCreateEditor(targetDocument: TextDocument) {
452 // if there's a known text editor for a Uri, use it. if not, open a new one
453 // 'beside' the current one. We know about the last active, and all visible.
454 // Sometimes the last active is not visible in the case it was overtaken by a
455 // WebViewPanel.
456
457 const KnownEditors: TextEditor[] = [];
458
459 KnownEditors.push(lastActiveTextEditor);
460 KnownEditors.push(...window.visibleTextEditors);
461
462
463 const matchingTextEditors = KnownEditors.filter((editor) =>
464 editor.document.uri.toString() === targetDocument.uri.toString());
465
466 if (matchingTextEditors.length === 0) {
467 const newEditor = await window.showTextDocument(
468 targetDocument,
469 ViewColumn.Beside
470 );
471 return (newEditor);
472 }
473 else {
474 return (matchingTextEditors[0]);
475 }
476}

Callers 1

setSelectionsFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected