diff --git a/release/package.json b/release/package.json index 36b1a27f..79a1e2e5 100644 --- a/release/package.json +++ b/release/package.json @@ -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": { @@ -1231,6 +1236,10 @@ { "command": "fsharp.showDocumentation", "when": "false" + }, + { + "command": "fsharp.restartLanguageService", + "when": "editorLangId == \u0027fsharp\u0027" } ], "editor/context": [ diff --git a/src/fsharp.fs b/src/fsharp.fs index f0117aef..1d01d7e0 100644 --- a/src/fsharp.fs +++ b/src/fsharp.fs @@ -20,6 +20,19 @@ type Api = GetProjectLauncher: OutputChannel -> DTO.Project -> (string list -> JS.Promise) option DebugProject: DTO.Project -> string[] -> JS.Promise } + +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 = let solutionExplorer = "FSharp.enableTreeView" |> Configuration.get true @@ -93,6 +106,7 @@ let activate (context: ExtensionContext) : JS.Promise = tryActivate "pipelinehints" PipelineHints.Instance.activate context tryActivate "testExplorer" TestExplorer.activate context tryActivate "inlayhints" InlayHints.activate context + tryActivate "languageservice" activateLanguageServiceRestart context let buildProject project = promise {