Identifies the resource to open.
Optional
options: { encoding?: string }Optional
Readonly
encoding?: stringThe encoding of the document to use for decoding the underlying buffer to text. If omitted, the encoding will be guessed based on the file content and/or the editor settings unless the document is already opened.
Opening a text document that was already opened with a different encoding has the potential of changing the text contents of the text document. Specifically, when the encoding results in a different set of characters than the previous encoding. As such, an error is thrown for dirty documents when the specified encoding is different from the encoding of the document.
See TextDocument.encoding for more information about valid values for encoding. Using an unsupported encoding will fallback to the default encoding for the document.
Note that if you open a document with an encoding that does not support decoding the underlying bytes, content may be replaced with substitution characters as appropriate.
A promise that resolves to a document.
A short-hand for openTextDocument(Uri.file(path))
.
A path of a file on disk.
Optional
options: { encoding?: string }Optional
Readonly
encoding?: stringThe encoding of the document to use for decoding the underlying buffer to text. If omitted, the encoding will be guessed based on the file content and/or the editor settings unless the document is already opened.
Opening a text document that was already opened with a different encoding has the potential of changing the text contents of the text document. Specifically, when the encoding results in a different set of characters than the previous encoding. As such, an error is thrown for dirty documents when the specified encoding is different from the encoding of the document.
See TextDocument.encoding for more information about valid values for encoding. Using an unsupported encoding will fallback to the default encoding for the document.
Note that if you open a document with an encoding that does not support decoding the underlying bytes, content may be replaced with substitution characters as appropriate.
A promise that resolves to a document.
Opens an untitled text document. The editor will prompt the user for a file
path when the document is to be saved. The options
parameter allows to
specify the language and/or the content of the document.
Optional
options: { content?: string; encoding?: string; language?: string }Options to control how the document will be created.
Optional
content?: stringThe initial contents of the document.
Optional
Readonly
encoding?: stringThe encoding of the document.
See TextDocument.encoding for more information about valid values for encoding. Using an unsupported encoding will fallback to the default encoding for the document.
Optional
language?: stringThe language of the document.
A promise that resolves to a document.
Opens a document. Will return early if this document is already open. Otherwise the document is loaded and the didOpen-event fires.
The document is denoted by an Uri. Depending on the scheme the following rules apply:
file
-scheme: Open a file on disk (openTextDocument(Uri.file(path))
). Will be rejected if the file does not exist or cannot be loaded.untitled
-scheme: Open a blank untitled file with associated path (openTextDocument(Uri.file(path).with({ scheme: 'untitled' }))
). The language will be derived from the file name.Note that the lifecycle of the returned document is owned by the editor and not by the extension. That means an
onDidClose
-event can occur at any time after opening it.