Skip to content

Commit

Permalink
Use separate overload instead of optional argument
Browse files Browse the repository at this point in the history
So as to now add a binary breaking change.

Co-authored-by: Patrick Meinecke <[email protected]>
  • Loading branch information
andyleejordan and SeeminglyScience committed Aug 22, 2023
1 parent 3f2e142 commit 6805767
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 3 deletions.
7 changes: 6 additions & 1 deletion src/PowerShellEditorServices/Extensions/EditorWorkspace.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,16 @@ public sealed class EditorWorkspace
#region Public Methods
// TODO: Consider returning bool instead of void to indicate success?

/// <summary>
/// Creates a new file in the editor.
/// </summary>
public void NewFile() => editorOperations.NewFileAsync(string.Empty).Wait();

/// <summary>
/// Creates a new file in the editor.
/// </summary>
/// <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();

/// <summary>
/// Opens a file in the workspace. If the file is already open
Expand Down
8 changes: 7 additions & 1 deletion src/PowerShellEditorServices/Extensions/IEditorOperations.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,18 @@ internal interface IEditorOperations
/// <returns>The resolved file path.</returns>
string GetWorkspaceRelativePath(ScriptFile scriptFile);

/// <summary>
/// Causes a new untitled file to be created in the editor.
/// </summary>
/// <returns>A task that can be awaited for completion.</returns>
Task NewFileAsync();

/// <summary>
/// Causes a new untitled file to be created in the editor.
/// </summary>
/// <param name="content">The content to insert into the new file.</param>
/// <returns>A task that can be awaited for completion.</returns>
Task NewFileAsync(string content = "");
Task NewFileAsync(string content);

/// <summary>
/// Causes a file to be opened in the editor. If the file is
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,12 @@ public EditorContext ConvertClientEditorContext(
clientContext.CurrentFileLanguage);
}

public async Task NewFileAsync(string content = "")
public async Task NewFileAsync()

Check failure on line 124 in src/PowerShellEditorServices/Services/Extension/EditorOperationsService.cs

View workflow job for this annotation

GitHub Actions / Test via LanguageClient-neovim

Use expression body for method (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/style-rules/ide0022)

Check failure on line 124 in src/PowerShellEditorServices/Services/Extension/EditorOperationsService.cs

View workflow job for this annotation

GitHub Actions / Test via Eglot

Use expression body for method (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/style-rules/ide0022)
{
return NewFileAsync("");

Check failure on line 126 in src/PowerShellEditorServices/Services/Extension/EditorOperationsService.cs

View workflow job for this annotation

GitHub Actions / Test via LanguageClient-neovim

Since 'EditorOperationsService.NewFileAsync()' is an async method that returns 'Task', a return keyword must not be followed by an object expression

Check failure on line 126 in src/PowerShellEditorServices/Services/Extension/EditorOperationsService.cs

View workflow job for this annotation

GitHub Actions / Test via Eglot

Since 'EditorOperationsService.NewFileAsync()' is an async method that returns 'Task', a return keyword must not be followed by an object expression
}

public async Task NewFileAsync(string content)
{
if (!TestHasLanguageServer())
{
Expand Down

0 comments on commit 6805767

Please sign in to comment.