Skip to content

Commit 0aaddda

Browse files
committed
Add an adjustable timeout to the .Window.SetStatusBarMessage API
1 parent 78b2c55 commit 0aaddda

File tree

5 files changed

+30
-8
lines changed

5 files changed

+30
-8
lines changed

src/PowerShellEditorServices.Protocol/LanguageServer/EditorCommands.cs

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -132,8 +132,15 @@ public static readonly
132132
public class SetStatusBarMessageRequest
133133
{
134134
public static readonly
135-
RequestType<string, EditorCommandResponse> Type =
136-
RequestType<string, EditorCommandResponse>.Create("editor/setStatusBarMessage");
135+
RequestType<StatusBarMessageDetails, EditorCommandResponse> Type =
136+
RequestType<StatusBarMessageDetails, EditorCommandResponse>.Create("editor/setStatusBarMessage");
137+
}
138+
139+
public class StatusBarMessageDetails
140+
{
141+
public string Message { get; set; }
142+
143+
public int? Timeout { get; set; }
137144
}
138145
}
139146

src/PowerShellEditorServices.Protocol/Server/LanguageServerEditorOperations.cs

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -138,13 +138,17 @@ public Task ShowWarningMessage(string message)
138138
true);
139139
}
140140

141-
public Task SetStatusBarMessage(string message)
141+
public Task SetStatusBarMessage(string message, int? timeout)
142142
{
143143
return
144144
this.messageSender.SendRequest(
145145
SetStatusBarMessageRequest.Type,
146-
message,
147-
true);
146+
new StatusBarMessageDetails
147+
{
148+
Message = message,
149+
Timeout = timeout
150+
},
151+
true);
148152
}
149153
}
150154
}

src/PowerShellEditorServices/Extensions/EditorWindow.cs

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,17 @@ public void ShowWarningMessage(string message)
6565
/// <param name="message">The message to be shown.</param>
6666
public void SetStatusBarMessage(string message)
6767
{
68-
this.editorOperations.SetStatusBarMessage(message).Wait();
68+
this.editorOperations.SetStatusBarMessage(message, null).Wait();
69+
}
70+
71+
/// <summary>
72+
/// Sets the status bar message in the editor UI (if applicable).
73+
/// </summary>
74+
/// <param name="message">The message to be shown.</param>
75+
/// <param name="timeout">A timeout in milliseconds for how long the message should remain visible.</param>
76+
public void SetStatusBarMessage(string message, int timeout)
77+
{
78+
this.editorOperations.SetStatusBarMessage(message, timeout).Wait();
6979
}
7080

7181
#endregion

src/PowerShellEditorServices/Extensions/IEditorOperations.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,8 +69,9 @@ public interface IEditorOperations
6969
/// Sets the status bar message in the editor UI (if applicable).
7070
/// </summary>
7171
/// <param name="message">The message to be shown.</param>
72+
/// <param name="timeout">If non-null, a timeout in milliseconds for how long the message should remain visible.</param>
7273
/// <returns>A Task that can be tracked for completion.</returns>
73-
Task SetStatusBarMessage(string message);
74+
Task SetStatusBarMessage(string message, int? timeout);
7475
}
7576
}
7677

test/PowerShellEditorServices.Test/Extensions/ExtensionServiceTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,7 @@ public Task ShowWarningMessage(string message)
203203
throw new NotImplementedException();
204204
}
205205

206-
public Task SetStatusBarMessage(string message)
206+
public Task SetStatusBarMessage(string message, int? timeout)
207207
{
208208
throw new NotImplementedException();
209209
}

0 commit comments

Comments
 (0)