-
Notifications
You must be signed in to change notification settings - Fork 30.6k
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
Provide encoding-related APIs for editor extensions #239961
Closed
Closed
Changes from all commits
Commits
Show all changes
27 commits
Select commit
Hold shift + click to select a range
a97e187
changes from https://github.com/microsoft/vscode/pull/177434 with lat…
bpasero 0d8e63a
Merge branch 'main' into ben/editor-encoding-api-fork
bpasero eefb7c0
towards encoding in document
bpasero 155a06d
.
bpasero 2374bc9
more work
bpasero 8eab2c0
unwind
bpasero 932ae6a
easy
bpasero 76a794c
cleanup
bpasero 2f10286
more
bpasero aed67f2
simple
bpasero bd7d19e
.
bpasero 1e43f7c
cleanup
bpasero 64f3fb4
implement
bpasero 11eb2cf
fix tests
bpasero be80519
Merge branch 'main' into ben/editor-encoding-api-fork
bpasero a5d88db
support encoding for new untitled as well
bpasero 064f94c
what?
bpasero 5e9c851
some tests
bpasero fe29d6a
cleanup
bpasero 312fbe2
check proposed
bpasero c63debc
add propo
bpasero 3cf278e
.
bpasero 80fed79
more fixes
bpasero fca29c4
add tests
bpasero 0c0373a
cleanup
bpasero 156597a
fix tests
bpasero d6bb9a6
Merge branch 'main' into ben/editor-encoding-api-fork
bpasero File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -76,16 +76,16 @@ export class ExtHostDocuments implements ExtHostDocumentsShape { | |
return data.document; | ||
} | ||
|
||
public ensureDocumentData(uri: URI): Promise<ExtHostDocumentData> { | ||
public ensureDocumentData(uri: URI, options?: { encoding?: string }): Promise<ExtHostDocumentData> { | ||
|
||
const cached = this._documentsAndEditors.getDocument(uri); | ||
if (cached) { | ||
if (cached && (!options?.encoding || cached.document.encoding === options.encoding)) { | ||
return Promise.resolve(cached); | ||
} | ||
|
||
let promise = this._documentLoader.get(uri.toString()); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ✋ this needs to account for different encodings |
||
if (!promise) { | ||
promise = this._proxy.$tryOpenDocument(uri).then(uriData => { | ||
promise = this._proxy.$tryOpenDocument(uri, options).then(uriData => { | ||
this._documentLoader.delete(uri.toString()); | ||
const canonicalUri = URI.revive(uriData); | ||
return assertIsDefined(this._documentsAndEditors.getDocument(canonicalUri)); | ||
|
@@ -99,7 +99,7 @@ export class ExtHostDocuments implements ExtHostDocumentsShape { | |
return promise; | ||
} | ||
|
||
public createDocumentData(options?: { language?: string; content?: string }): Promise<URI> { | ||
public createDocumentData(options?: { language?: string; content?: string; encoding?: string }): Promise<URI> { | ||
return this._proxy.$tryCreateDocument(options).then(data => URI.revive(data)); | ||
} | ||
|
||
|
@@ -140,6 +140,20 @@ export class ExtHostDocuments implements ExtHostDocumentsShape { | |
}); | ||
} | ||
|
||
public $acceptEncodingChanged(uriComponents: UriComponents, encoding: string): void { | ||
const uri = URI.revive(uriComponents); | ||
const data = this._documentsAndEditors.getDocument(uri); | ||
if (!data) { | ||
throw new Error('unknown document'); | ||
} | ||
data._acceptEncoding(encoding); | ||
this._onDidChangeDocument.fire({ | ||
document: data.document, | ||
contentChanges: [], | ||
reason: undefined | ||
}); | ||
} | ||
|
||
public $acceptModelChanged(uriComponents: UriComponents, events: IModelChangedEvent, isDirty: boolean): void { | ||
const uri = URI.revive(uriComponents); | ||
const data = this._documentsAndEditors.getDocument(uri); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
✋ Missed proposed API checks