MCPcopy Create free account
hub / github.com/continuedev/continue / readFile

Method readFile

extensions/vscode/src/util/ideUtils.ts:128–151  ·  view source on GitHub ↗

* Read the entire contents of a file from the given URI. * If there are unsaved changes in an open editor, returns those instead of the file on disk. * * @param uri - The URI of the file to read. * @param ignoreMissingProviders - Optional flag to ignore missing file system providers for

(
    uri: vscode.Uri,
    ignoreMissingProviders: boolean = true,
  )

Source from the content-addressed store, hash-verified

126 * @throws Will rethrow any error that is not related to missing providers or unsupported schemes.
127 */
128 async readFile(
129 uri: vscode.Uri,
130 ignoreMissingProviders: boolean = true,
131 ): Promise<Uint8Array | null> {
132 // First check if there's an open document with this URI that might have unsaved changes.
133 const openDocuments = vscode.workspace.textDocuments;
134 for (const document of openDocuments) {
135 if (document.uri.toString() === uri.toString()) {
136 // Found an open document with this URI.
137 // Return its current content (including any unsaved changes) as Uint8Array.
138 const docText = document.getText();
139 return Buffer.from(docText, "utf8");
140 }
141 }
142
143 // If no open document found or if it's not dirty, fall back to reading from disk.
144 return await this.fsOperation(
145 uri,
146 async (u) => {
147 return await vscode.workspace.fs.readFile(u);
148 },
149 ignoreMissingProviders,
150 );
151 }
152
153 /**
154 * Retrieve metadata about a file from the given URI.

Callers 1

readRangeInFileMethod · 0.95

Calls 4

fsOperationMethod · 0.95
getTextMethod · 0.80
fromMethod · 0.80
readFileMethod · 0.65

Tested by

no test coverage detected