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 4be31b5 commit 85fd5be
Show file tree
Hide file tree
Showing 3 changed files with 16 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,9 @@ public EditorContext ConvertClientEditorContext(
clientContext.CurrentFileLanguage);
}

public async Task NewFileAsync(string content = "")
public async Task NewFileAsync() => await NewFileAsync(string.Empty).ConfigureAwait(false);

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

0 comments on commit 85fd5be

Please sign in to comment.