Skip to content

Commit

Permalink
merged in realTimeDiagnostics support.
Browse files Browse the repository at this point in the history
Signed-off-by: Akos Kitta <[email protected]>
  • Loading branch information
Akos Kitta committed Jul 18, 2022
1 parent 824e55c commit 676b255
Showing 1 changed file with 14 additions and 9 deletions.
23 changes: 14 additions & 9 deletions arduino-ide-extension/src/browser/contributions/ino-language.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,14 @@ export class InoLanguage extends SketchContribution {
private languageServerStartMutex = new Mutex();

override onReady(): void {
const start = ({ selectedBoard }: BoardsConfig.Config) => {
const start = (
{ selectedBoard }: BoardsConfig.Config,
forceStart = false
) => {
if (selectedBoard) {
const { name, fqbn } = selectedBoard;
if (fqbn) {
this.startLanguageServer(fqbn, name);
this.startLanguageServer(fqbn, name, forceStart);
}
}
};
Expand All @@ -49,11 +52,12 @@ export class InoLanguage extends SketchContribution {
);
this.preferences.onPreferenceChanged(
({ preferenceName, oldValue, newValue }) => {
if (
preferenceName === 'arduino.language.log' &&
newValue !== oldValue
) {
start(this.boardsServiceProvider.boardsConfig);
if (oldValue !== newValue) {
switch (preferenceName) {
case 'arduino.language.log':
case 'arduino.language.realTimeDiagnostics':
start(this.boardsServiceProvider.boardsConfig, true);
}
}
}
);
Expand All @@ -62,7 +66,8 @@ export class InoLanguage extends SketchContribution {

private async startLanguageServer(
fqbn: string,
name: string | undefined
name: string | undefined,
forceStart = false
): Promise<void> {
const port = await this.daemon.tryGetPort();
if (!port) {
Expand Down Expand Up @@ -96,7 +101,7 @@ export class InoLanguage extends SketchContribution {
}
return;
}
if (fqbn === this.languageServerFqbn) {
if (!forceStart && fqbn === this.languageServerFqbn) {
// NOOP
return;
}
Expand Down

0 comments on commit 676b255

Please sign in to comment.