Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

findDocument API (work in progress) #80689

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions src/vs/vscode.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8050,6 +8050,14 @@ declare module 'vscode' {
*/
export const textDocuments: TextDocument[];

/**
* Find a text document known to the system and return it or undefined if there's no such
* a document.
*
* @param uri Identifies the resource to open.
*/
export function findDocument(uri: Uri): TextDocument | undefined;

/**
* Opens a document. Will return early if this document is already open. Otherwise
* the document is loaded and the [didOpen](#workspace.onDidOpenTextDocument)-event fires.
Expand Down
4 changes: 4 additions & 0 deletions src/vs/workbench/api/common/extHost.api.impl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -617,6 +617,10 @@ export function createApiFactoryAndRegisterActors(accessor: ServicesAccessor): I
set textDocuments(value) {
throw errors.readonly();
},
findDocument(uri: vscode.Uri): vscode.TextDocument | undefined {
const documentData = extHostDocuments.getDocumentData(uri);
return documentData ? documentData.document : undefined;
},
openTextDocument(uriOrFileNameOrOptions?: vscode.Uri | string | { language?: string; content?: string; }) {
let uriPromise: Thenable<URI>;

Expand Down
2 changes: 1 addition & 1 deletion src/vs/workbench/test/common/editor/untitledEditor.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -308,4 +308,4 @@ suite('Workbench untitled editors', () => {
input.dispose();
assert.equal(counter, 1);
});
});
});