Skip to content

Commit

Permalink
Add command to restart language service (#1942)
Browse files Browse the repository at this point in the history
* Add command to restart language service

* Init workspace when language service restarts
  • Loading branch information
sheridanchris committed Oct 6, 2023
1 parent 944c5e7 commit 94dc2c0
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 0 deletions.
9 changes: 9 additions & 0 deletions release/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -408,6 +408,11 @@
"light": "./images/lock-open-solid-light.svg"
},
"title": "Unlock Info Panel"
},
{
"category": "F#",
"command": "fsharp.restartLanguageService",
"title": "Restart Language Service"
}
],
"configuration": {
Expand Down Expand Up @@ -1231,6 +1236,10 @@
{
"command": "fsharp.showDocumentation",
"when": "false"
},
{
"command": "fsharp.restartLanguageService",
"when": "editorLangId == \u0027fsharp\u0027"
}
],
"editor/context": [
Expand Down
14 changes: 14 additions & 0 deletions src/fsharp.fs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,19 @@ type Api =
GetProjectLauncher: OutputChannel -> DTO.Project -> (string list -> JS.Promise<ChildProcess>) option
DebugProject: DTO.Project -> string[] -> JS.Promise<unit> }


let private activateLanguageServiceRestart (context: ExtensionContext) =
let restart () =
promise {
logger.Debug("Restarting F# language service")
do! LanguageService.stop ()
do! LanguageService.start context
do! Project.initWorkspace ()
}

commands.registerCommand ("fsharp.restartLanguageService", restart |> objfy2)
|> context.Subscribe

let activate (context: ExtensionContext) : JS.Promise<Api> =
let solutionExplorer = "FSharp.enableTreeView" |> Configuration.get true

Expand Down Expand Up @@ -93,6 +106,7 @@ let activate (context: ExtensionContext) : JS.Promise<Api> =
tryActivate "pipelinehints" PipelineHints.Instance.activate context
tryActivate "testExplorer" TestExplorer.activate context
tryActivate "inlayhints" InlayHints.activate context
tryActivate "languageservice" activateLanguageServiceRestart context

let buildProject project =
promise {
Expand Down

0 comments on commit 94dc2c0

Please sign in to comment.