Skip to content

Commit

Permalink
Fix how workspace/didChangeConfiguration handles DTO w/o FSharp prope…
Browse files Browse the repository at this point in the history
…rty (#1084)
  • Loading branch information
razzmatazz authored Mar 19, 2023
1 parent 35a8ca9 commit a84bfb0
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 11 deletions.
2 changes: 1 addition & 1 deletion src/FsAutoComplete/LspHelpers.fs
Original file line number Diff line number Diff line change
Expand Up @@ -663,7 +663,7 @@ type FSharpConfigDto =
Notifications: NotificationsDto option
Debug: DebugDto option }

type FSharpConfigRequest = { FSharp: FSharpConfigDto }
type FSharpConfigRequest = { FSharp: FSharpConfigDto option }

type CodeLensConfig =
{ Signature: {| Enabled: bool |}
Expand Down
9 changes: 6 additions & 3 deletions src/FsAutoComplete/LspServers/AdaptiveFSharpLspServer.fs
Original file line number Diff line number Diff line change
Expand Up @@ -3410,9 +3410,12 @@ type AdaptiveFSharpLspServer(workspaceLoader: IWorkspaceLoader, lspClient: FShar
)

let dto = p.Settings |> Server.deserialize<FSharpConfigRequest>
let c = config |> AVal.force
let c = c.AddDto dto.FSharp
updateConfig c

dto.FSharp
|> Option.iter (fun fsharpConfig ->
let c = config |> AVal.force
let c = c.AddDto fsharpConfig
updateConfig c)

with e ->
trace.SetStatusErrorSafe(e.Message).RecordExceptions(e) |> ignore
Expand Down
14 changes: 8 additions & 6 deletions src/FsAutoComplete/LspServers/FsAutoComplete.Lsp.fs
Original file line number Diff line number Diff line change
Expand Up @@ -2106,13 +2106,15 @@ type FSharpLspServer(state: State, lspClient: FSharpLspClient) =
>> Log.addContextDestructured "parms" dto
)

let c = config.AddDto dto.FSharp
updateConfig c
dto.FSharp
|> Option.iter (fun fsharpConfig ->
let c = config.AddDto fsharpConfig
updateConfig c

logger.info (
Log.setMessage "Workspace configuration changed"
>> Log.addContextDestructured "config" c
)
logger.info (
Log.setMessage "Workspace configuration changed"
>> Log.addContextDestructured "config" c
))

return ()
}
Expand Down
2 changes: 1 addition & 1 deletion test/FsAutoComplete.Tests.Lsp/ScriptTests.fs
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ let scriptEvictionTests state =

let configChange: DidChangeConfigurationParams =
let config: FSharpConfigRequest =
{ FSharp = { defaultConfigDto with FSIExtraParameters = Some [| "--nowarn:760" |] } }
{ FSharp = Some { defaultConfigDto with FSIExtraParameters = Some [| "--nowarn:760" |] } }

{ Settings = Server.serialize config }

Expand Down

0 comments on commit a84bfb0

Please sign in to comment.