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

Fix up extension API #2053

Merged
merged 4 commits into from
Aug 22, 2023
Merged

Fix up extension API #2053

merged 4 commits into from
Aug 22, 2023

Conversation

andyleejordan
Copy link
Member

Receive a EditorOperationResponse (not yet otherwise used). Delete dead code. Add optional content parameter to NewFile. Expose CloseFile and SaveFile. Fix an outdated warning message.

Part of PowerShell/vscode-powershell#4703 so I could test it.

@andyleejordan andyleejordan requested a review from a team August 17, 2023 02:11
@andyleejordan andyleejordan added Issue-Enhancement A feature request (enhancement). Area-API labels Aug 17, 2023
@andyleejordan
Copy link
Member Author

Tested that last commit with a temporary multi-root workspace:

> $pseditor.GetEditorContext().CurrentFile.WorkspacePath
mocks/BinaryModule/BinaryModuleTest.ps1
@andyjordane318 ...src/vscode-powershell/test/mocks andyleejordan/fix-newfile-casing ≡ +0 ~1 -0 !
> $pseditor.GetEditorContext().CurrentFile.WorkspacePath
features/CustomViews.test.ts
@andyjordane318 ...src/vscode-powershell/test/mocks andyleejordan/fix-newfile-casing ≡ +0 ~1 -0 !
> $pseditor.GetEditorContext().CurrentFile.WorkspacePath
untitled:Untitled-1

Copy link
Collaborator

@SeeminglyScience SeeminglyScience left a comment

Choose a reason for hiding this comment

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

Just a couple of changes so we don't introduce binary breaking changes, other than that LGTM

Receive a `EditorOperationResponse` (not yet otherwise used). Delete
dead code. Add optional `content` parameter to `NewFile`. Expose
`CloseFile` and `SaveFile`. Fix an outdated warning message.
Since `Path` now refers to initial working directory.
public void NewFile() => editorOperations.NewFileAsync().Wait();
/// <param name="content">The content to place in the new file.</param>
public void NewFile(string content) => editorOperations.NewFileAsync(content).Wait();
public void NewFile(string content = "") => editorOperations.NewFileAsync(content).Wait();
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
public void NewFile(string content = "") => editorOperations.NewFileAsync(content).Wait();

think the previous suggestion bugged out (or I did it wrong)

@@ -123,15 +121,15 @@ public async Task SetSelectionAsync(BufferRange selectionRange)
clientContext.CurrentFileLanguage);
}

public async Task NewFileAsync()
public async Task NewFileAsync(string content = "")
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
public async Task NewFileAsync(string content = "")
public async Task NewFileAsync() => NewFileAsync(string.Empty);
public async Task NewFileAsync(string content)

So as to now add a binary breaking change.

Co-authored-by: Patrick Meinecke <[email protected]>
Copy link
Collaborator

@SeeminglyScience SeeminglyScience left a comment

Choose a reason for hiding this comment

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

LGTM! ❤️

@andyleejordan andyleejordan added this pull request to the merge queue Aug 22, 2023
Merged via the queue into main with commit 85fd5be Aug 22, 2023
13 checks passed
@andyleejordan andyleejordan deleted the andyleejordan/extension-api branch August 22, 2023 20:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-API Issue-Enhancement A feature request (enhancement).
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

2 participants