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

Sign up
Appearance settings

Added stop/restart LS commands. #12

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

Merged
kittaakos merged 1 commit into master from added-stop-restart-commands
Feb 25, 2021
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
14 changes: 13 additions & 1 deletion package.json
View file Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,9 @@
"activationEvents": [
"onLanguage:ino",
"onCommand:arduino.debug.start",
"onCommand:arduino.languageserver.start"
"onCommand:arduino.languageserver.start",
"onCommand:arduino.languageserver.stop",
"onCommand:arduino.languageserver.restart"
],
"contributes": {
"languages": [
Expand Down Expand Up @@ -105,6 +107,16 @@
"title": "Start Language Server",
"category": "Arduino"
},
{
"command": "arduino.languageserver.stop",
"title": "Stop Language Server",
"category": "Arduino"
},
{
"command": "arduino.languageserver.restart",
"title": "Restart Language Server",
"category": "Arduino"
},
{
"command": "arduino.debug.start",
"title": "Start Debug",
Expand Down
24 changes: 23 additions & 1 deletion src/extension.ts
View file Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -66,10 +66,28 @@ export function activate(context: ExtensionContext) {
const started = await startLanguageServer(context, config);
languageServerIsRunning = started;
return languageServerIsRunning ? config.board.fqbn : undefined;
} catch (e) {
console.log(e);
languageServerIsRunning = false;
throw e;
} finally {
unlock();
}
}),
vscode.commands.registerCommand('arduino.languageserver.stop', async () => {
const unlock = await languageServerStartMutex.acquire();
try {
await stopLanguageServer(context);
languageServerIsRunning = false;
} finally {
unlock();
}
}),
vscode.commands.registerCommand('arduino.languageserver.restart', async () => {
if (latestConfig) {
return vscode.commands.executeCommand('arduino.languageserver.start', latestConfig);
}
}),
vscode.commands.registerCommand('arduino.debug.start', (config: DebugConfig) => startDebug(context, config))
);
}
Expand Down Expand Up @@ -141,7 +159,7 @@ async function startDebug(_: ExtensionContext, config: DebugConfig): Promise<boo
return vscode.debug.startDebugging(undefined, mergedDebugConfig);
}

async function startLanguageServer(context: ExtensionContext,config: LanguageServerConfig): Promise<boolean> {
async function stopLanguageServer(context: ExtensionContext): Promise<void> {
if (languageClient) {
if (languageClient.diagnostics) {
languageClient.diagnostics.clear();
Expand All @@ -151,6 +169,10 @@ async function startLanguageServer(context: ExtensionContext, config: LanguageSe
languageServerDisposable.dispose();
}
}
}

async function startLanguageServer(context: ExtensionContext, config: LanguageServerConfig): Promise<boolean> {
await stopLanguageServer(context);
if (!languageClient || !deepEqual(latestConfig, config)) {
latestConfig = config;
languageClient = await buildLanguageClient(config);
Expand Down

AltStyle によって変換されたページ (->オリジナル) /