Skip to content

Commit

Permalink
Add support for Cancel a Work Done Progress (#1274)
Browse files Browse the repository at this point in the history
* Add support for Cancel WorkDoneProgress

* Fix up saving cancellation
  • Loading branch information
TheAngryByrd authored May 5, 2024
1 parent e393d35 commit b2827ed
Show file tree
Hide file tree
Showing 11 changed files with 266 additions and 104 deletions.
4 changes: 2 additions & 2 deletions Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
<NoWarn>$(NoWarn);3186,0042</NoWarn><!-- circumvent an error with the fake dependencymanager for
paket: https://github.com/dotnet/fsharp/issues/8678 -->
<NoWarn>$(NoWarn);NU1902</NoWarn><!-- NU1902 - package vulnerability detected -->
<WarnOn>$(WarnOn);1182</WarnOn> <!-- Unused
variables,https://learn.microsoft.com/en-us/dotnet/fsharp/language-reference/compiler-options#opt-in-warnings -->
<WarnOn>$(WarnOn);1182</WarnOn> <!-- Unused variables,https://learn.microsoft.com/en-us/dotnet/fsharp/language-reference/compiler-options#opt-in-warnings -->
<NoWarn>$(NoWarn);FS0044</NoWarn> <!-- Ignore deprecations -->
<WarnOn>$(WarnOn);3390</WarnOn><!-- Malformed XML doc comments -->
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
<ChangelogFile>$(MSBuildThisFileDirectory)CHANGELOG.md</ChangelogFile>
Expand Down
2 changes: 1 addition & 1 deletion paket.dependencies
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ nuget Expecto.Diff
nuget YoloDev.Expecto.TestSdk
nuget AltCover
nuget GitHubActionsTestLogger
nuget Ionide.LanguageServerProtocol >= 0.4.20
nuget Ionide.LanguageServerProtocol >= 0.4.23
nuget Microsoft.Extensions.Caching.Memory
nuget OpenTelemetry.Api >= 1.3.2
nuget OpenTelemetry.Exporter.OpenTelemetryProtocol >= 1.3.2 # 1.4 bumps to 7.0 versions of System.Diagnostics libs, so can't use it
Expand Down
2 changes: 1 addition & 1 deletion paket.lock
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ NUGET
System.Reflection.Metadata (>= 5.0)
Ionide.Analyzers (0.10)
Ionide.KeepAChangelog.Tasks (0.1.8) - copy_local: true
Ionide.LanguageServerProtocol (0.4.20)
Ionide.LanguageServerProtocol (0.4.23)
FSharp.Core (>= 6.0)
Newtonsoft.Json (>= 13.0.1)
StreamJsonRpc (>= 2.16.36)
Expand Down
14 changes: 8 additions & 6 deletions src/FsAutoComplete/LspServers/AdaptiveFSharpLspServer.fs
Original file line number Diff line number Diff line change
Expand Up @@ -575,8 +575,8 @@ type AdaptiveFSharpLspServer
// Otherwise we'll fail here and our retry logic will come into place
do!
match p.Context with
| Some({ triggerKind = CompletionTriggerKind.TriggerCharacter } as context) ->
volatileFile.Source.TryGetChar pos = context.triggerCharacter
| Some({ TriggerKind = CompletionTriggerKind.TriggerCharacter } as context) ->
volatileFile.Source.TryGetChar pos = context.TriggerCharacter
| _ -> true
|> Result.requireTrue $"TextDocumentCompletion was sent before TextDocumentDidChange"

Expand Down Expand Up @@ -2957,25 +2957,27 @@ type AdaptiveFSharpLspServer

override x.Dispose() = disposables.Dispose()

member this.WorkDoneProgressCancel(token: ProgressToken) : Async<unit> =
member this.WorkDoneProgressCancel(param: WorkDoneProgressCancelParams) : Async<unit> =
async {

let tags = [ "ProgressToken", box token ]
let tags = [ "WorkDoneProgressCancelParams", box param ]
use trace = fsacActivitySource.StartActivityForType(thisType, tags = tags)

try
logger.info (
Log.setMessage "WorkDoneProgressCancel Request: {params}"
>> Log.addContextDestructured "params" token
>> Log.addContextDestructured "params" param.token
)

state.CancelServerProgress param.token

with e ->
trace |> Tracing.recordException e

logException
e
(Log.setMessage "WorkDoneProgressCancel Request Errored {p}"
>> Log.addContextDestructured "token" token)
>> Log.addContextDestructured "token" param.token)

return ()
}
Expand Down
Loading

0 comments on commit b2827ed

Please sign in to comment.