Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add command to restart language service #1942

Merged
merged 2 commits into from
Oct 6, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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