Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit ee21c56

Browse filesBrowse files
author
Akos Kitta
committed
Fixed the LS process termination.
Signed-off-by: Akos Kitta <kittaakos@typefox.io>
1 parent 5e056a2 commit ee21c56
Copy full SHA for ee21c56

File tree

Expand file treeCollapse file tree

4 files changed

+457
-28
lines changed
Filter options
Expand file treeCollapse file tree

4 files changed

+457
-28
lines changed

‎configs/webpack.config.js

Copy file name to clipboardExpand all lines: configs/webpack.config.js
+25-1Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,18 @@
11
// @ts-check
22

33
const path = require('path');
4+
const CopyPlugin = require('copy-webpack-plugin');
5+
const PermissionsOutputPlugin = require('webpack-permissions-plugin');
46

57
/**
68
* @type {import('webpack').Configuration}
79
*/
810
const config = {
911
target: 'node',
12+
node: {
13+
__dirname: false,
14+
__filename: false
15+
},
1016
entry: './lib/extension.js',
1117
output: {
1218
path: path.resolve(__dirname, '..', 'dist'),
@@ -21,6 +27,24 @@ const config = {
2127
},
2228
resolve: {
2329
extensions: ['.js']
24-
}
30+
},
31+
plugins: [
32+
new CopyPlugin({
33+
patterns: [
34+
{
35+
from: 'node_modules/vscode-languageclient/lib/utils/terminateProcess.sh',
36+
to: 'terminateProcess.sh'
37+
}
38+
]
39+
}),
40+
new PermissionsOutputPlugin({
41+
buildFiles: [
42+
{
43+
path: path.resolve(__dirname, '..', 'dist', 'terminateProcess.sh'),
44+
fileMode: '555'
45+
}
46+
]
47+
})
48+
]
2549
};
2650
module.exports = config;

‎package.json

Copy file name to clipboardExpand all lines: package.json
+11-3Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
},
1313
"scripts": {
1414
"prepare": "yarn clean && yarn compile && yarn webpack && yarn package",
15-
"clean": "rimraf ./lib && rimraf ./build-artifacts",
15+
"clean": "rimraf ./lib ./dist ./build-artifacts",
1616
"compile": "tsc -p ./",
1717
"watch": "tsc -w -p ./",
1818
"webpack": "webpack --config ./configs/webpack.config.js",
@@ -28,13 +28,15 @@
2828
"devDependencies": {
2929
"@types/node": "^10.14.9",
3030
"@types/vscode": "^1.41.0",
31+
"copy-webpack-plugin": "^6.1.0",
3132
"mkdirp": "^1.0.4",
3233
"rimraf": "^3.0.2",
3334
"typescript": "^3.8.3",
3435
"vsce": "^1.66.0",
3536
"vscode": "^1.1.33",
3637
"webpack": "^4.39.1",
37-
"webpack-cli": "^3.3.6"
38+
"webpack-cli": "^3.3.6",
39+
"webpack-permissions-plugin": "^1.0.7"
3840
},
3941
"dependencies": {
4042
"@types/deep-equal": "^1.0.1",
@@ -64,7 +66,8 @@
6466
"theme": "light"
6567
},
6668
"activationEvents": [
67-
"onCommand:arduino.languageserver.start"
69+
"onCommand:arduino.languageserver.start",
70+
"onCommand:arduino.languageserver.startWithDefault"
6871
],
6972
"contributes": {
7073
"languages": [
@@ -93,6 +96,11 @@
9396
"command": "arduino.languageserver.start",
9497
"title": "Arduino: Start/Restart Language Server",
9598
"description": "Start the language server or restart if there is a running instance"
99+
},
100+
{
101+
"command": "arduino.languageserver.startWithDefault",
102+
"title": "Arduino: Start/Restart Language Server with Defaults",
103+
"description": "Start the language server or restart if there is a running instance with default configs"
96104
}
97105
]
98106
}

‎src/extension.ts

Copy file name to clipboardExpand all lines: src/extension.ts
+8-11Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ interface LanguageServerConfig {
1717
* If `true` the LS will be restarted if it's running. Defaults to `false`.
1818
*/
1919
readonly force?: boolean;
20-
readonly outputEnabled?: boolean;
2120
}
2221

2322
let languageClient: LanguageClient | undefined;
@@ -43,7 +42,7 @@ async function startLanguageServer(context: ExtensionContext, config: LanguageSe
4342
languageServerDisposable.dispose();
4443
}
4544
}
46-
if (!languageClient || !deepEqual(latestConfig, config)) {
45+
if (!languageClient || !deepEqual(latestConfig, config) || config.force) {
4746
latestConfig = config;
4847
languageClient = buildLanguageClient(config);
4948
crashCount = 0;
@@ -54,15 +53,13 @@ async function startLanguageServer(context: ExtensionContext, config: LanguageSe
5453
}
5554

5655
function buildLanguageClient(config: LanguageServerConfig): LanguageClient {
57-
if (config.outputEnabled) {
58-
if (!serverOutputChannel) {
59-
serverOutputChannel = vscode.window.createOutputChannel('Arduino Language Server');
60-
}
61-
if (!serverTraceChannel) {
62-
serverTraceChannel = vscode.window.createOutputChannel('Arduino Language Server (trace)');
63-
}
56+
if (!serverOutputChannel) {
57+
serverOutputChannel = vscode.window.createOutputChannel('Arduino Language Server');
58+
}
59+
if (!serverTraceChannel) {
60+
serverTraceChannel = vscode.window.createOutputChannel('Arduino Language Server (trace)');
6461
}
65-
const { lsPath: command, clangdPath, cliPath, board, flags } = config;
62+
const { lsPath: command, clangdPath, cliPath, board, flags, env } = config;
6663
const args = ['-clangd', clangdPath, '-cli', cliPath, '-fqbn', board.fqbn];
6764
if (board.name) {
6865
args.push('-board-name', board.name);
@@ -76,7 +73,7 @@ function buildLanguageClient(config: LanguageServerConfig): LanguageClient {
7673
{
7774
command,
7875
args,
79-
options: { env: config.env },
76+
options: { env: env || {} },
8077
},
8178
{
8279
initializationOptions: {},

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.