Skip to content

Commit

Permalink
Add command to restart language server
Browse files Browse the repository at this point in the history
  • Loading branch information
kralicky committed Jul 12, 2023
1 parent 682ca5e commit c5b43a5
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 4 deletions.
6 changes: 6 additions & 0 deletions editors/vscode/client/src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,12 @@ export function activate(context: ExtensionContext) {
workspace.registerTextDocumentContentProvider('proto', client);
// Start the client. This will also launch the server
client.start();

context.subscriptions.push(
vscode.commands.registerCommand('protols.restart', async () => {
await client.restart();
}
));
}

export function deactivate(): Thenable<void> | undefined {
Expand Down
6 changes: 6 additions & 0 deletions editors/vscode/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,12 @@
"path": "./syntaxes/protobuf.tmLanguage.json"
}
],
"commands": [
{
"command": "protols.restart",
"title": "Protols: Restart Language Server"
}
],
"configuration": {
"type": "object",
"title": "Example configuration",
Expand Down
6 changes: 3 additions & 3 deletions protols/resolver.go
Original file line number Diff line number Diff line change
Expand Up @@ -194,9 +194,9 @@ func (r *Resolver) checkWellKnownImportPath(path string) (protocompile.SearchRes
}

func (r *Resolver) checkFS(path string) (protocompile.SearchResult, error) {
uri, err := r.PathToURI(path)
if err != nil {
return protocompile.SearchResult{}, err
uri, ok := r.fileURIsByPath[path]
if !ok {
return protocompile.SearchResult{}, os.ErrNotExist
}
if fh, err := r.ReadFile(context.TODO(), uri); err == nil {
content, err := fh.Content()
Expand Down
2 changes: 1 addition & 1 deletion protols/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -668,7 +668,7 @@ func (*Server) SetTrace(context.Context, *protocol.SetTraceParams) error {

// Shutdown implements protocol.Server.
func (*Server) Shutdown(context.Context) error {
return jsonrpc2.ErrMethodNotFound
return nil
}

// SignatureHelp implements protocol.Server.
Expand Down

0 comments on commit c5b43a5

Please sign in to comment.