Skip to content

Commit

Permalink
Fixed and tested LDS integration via socket
Browse files Browse the repository at this point in the history
  • Loading branch information
a-sr committed Nov 11, 2022
1 parent b66edcf commit cc82455
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 2 deletions.
14 changes: 14 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,20 @@
"request": "launch",
"type": "extensionHost"
},
{
"env": {
"LF_LS_PORT": "7670"
},
"args": [
"--extensionDevelopmentPath=${workspaceFolder}"
],
"name": "Launch Extension (Socket)",
"outFiles": [
"${workspaceFolder}/out/**/*.js"
],
"request": "launch",
"type": "extensionHost"
},
{
"args": [
"--extensionDevelopmentPath=${workspaceFolder}",
Expand Down
13 changes: 11 additions & 2 deletions src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,15 @@ import * as fs from 'fs';

import { Trace } from 'vscode-jsonrpc';
import * as vscode from 'vscode';
import { LanguageClient, LanguageClientOptions, ServerOptions } from 'vscode-languageclient';
import { connect, NetConnectOpts, Socket } from 'net';
import { LanguageClient, LanguageClientOptions, ServerOptions, StreamInfo } from 'vscode-languageclient';
import { legend, semanticTokensProvider } from './highlight';
import * as config from './config';
import { registerBuildCommands } from './build_commands';
import * as checkDependencies from './check_dependencies';

let client: LanguageClient;
let socket: Socket

export async function activate(context: vscode.ExtensionContext) {

Expand Down Expand Up @@ -108,5 +110,12 @@ export function deactivate(): Thenable<void> | undefined {
if (!client) {
return undefined;
}
return client.stop();
if (socket) {
// Don't call client.stop when we are connected via socket for development.
// That call will end the LS server, leading to a bad dev experience.
socket.end();
return;
} else {
return client.stop();
}
}

0 comments on commit cc82455

Please sign in to comment.