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

Provide encoding-related APIs for editor extensions (#824) #240804

Merged
merged 11 commits into from
Feb 20, 2025

Conversation

bpasero
Copy link
Member

@bpasero bpasero commented Feb 14, 2025

for #824

export namespace workspace {
	export function openTextDocument(uri: Uri, options?: { encoding?: string }): Thenable<TextDocument>;
	export function openTextDocument(path: string, options?: { encoding?: string }): Thenable<TextDocument>;
	export function openTextDocument(options?: { language?: string; content?: string; encoding?: string; }): Thenable<TextDocument>;
}

@bpasero bpasero self-assigned this Feb 14, 2025
@bpasero bpasero added this to the On Deck milestone Feb 14, 2025
@bpasero bpasero requested a review from Copilot February 19, 2025 19:51
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PR Overview

This pull request introduces encoding-related APIs for editor extensions to address issue #824. The updates propagate encoding options through API interfaces and internal document handling, with new tests verifying encoding behavior, and modifications to the underlying implementations in extHost and mainThread modules.

  • Update TextDocument and workspace API interfaces to include an optional encoding parameter.
  • Add new tests for encoding-related behaviors and error scenarios.
  • Propagate encoding options in extHostDocuments, extHost.api.impl, mainThreadDocuments, and extHost.protocol.

Changes

File Description
extensions/vscode-api-tests/src/singlefolder-tests/workspace.test.ts Adds new tests and updates test names to validate encoding behavior in text document APIs
src/vs/workbench/api/common/extHostDocuments.ts Updates document retrieval and creation functions to accept and handle encoding options
src/vs/workbench/api/common/extHost.api.impl.ts Modifies openTextDocument to propagate encoding options when creating or opening documents
src/vs/workbench/api/browser/mainThreadDocuments.ts Refactors resource handling and untitled document creation to incorporate encoding support
src/vs/workbench/api/common/extHost.protocol.ts Updates protocol definitions to include the encoding parameter

Copilot reviewed 6 out of 6 changed files in this pull request and generated 1 comment.

Comments suppressed due to low confidence (1)

src/vs/workbench/api/common/extHost.api.impl.ts:1030

  • [nitpick] Consider using a distinct variable name (e.g. documentOptions) when merging uriOrFileNameOrOptions with options to improve clarity between the URI and options object.
options = (options ?? uriOrFileNameOrOptions) as ({ language?: string; content?: string; encoding?: string } | undefined);

Tip: If you use Visual Studio Code, you can request a review from Copilot before you push from the "Source Control" tab. Learn more

@bpasero bpasero modified the milestones: On Deck, February 2025 Feb 20, 2025
@bpasero bpasero marked this pull request as ready for review February 20, 2025 10:05
@bpasero bpasero enabled auto-merge (squash) February 20, 2025 10:05
@bpasero bpasero merged commit 89fef84 into main Feb 20, 2025
8 checks passed
@bpasero bpasero deleted the ben/encode-decode-api branch February 20, 2025 11:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants