Conversation

andyleejordan

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.

@andyleejordanandyleejordan requested a review from a team August 17, 2023 02:11
@andyleejordanandyleejordan added Issue-EnhancementA feature request (enhancement).Area-API labels Aug 17, 2023
@andyleejordan

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

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)

@andyleejordanandyleejordan force-pushed the andyleejordan/extension-api branch from 0849ad9 to 0d30182 Compare August 22, 2023 20:07
@@ -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)

@andyleejordanandyleejordan force-pushed the andyleejordan/extension-api branch from 0d30182 to 6805767 Compare August 22, 2023 20:11
So as to now add a binary breaking change.

Co-authored-by: Patrick Meinecke <[email protected]>
@andyleejordanandyleejordan force-pushed the andyleejordan/extension-api branch from 6805767 to f6245f4 Compare August 22, 2023 20:14

Choose a reason for hiding this comment

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

LGTM! ❤️

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

Successfully merging this pull request may close these issues.