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

Commit 337d22e

Browse files
Akos Kittakittaakos
Akos Kitta
authored andcommitted
Dropped compile.optimizeForDebug preference.
Closes #1212. Restored the `Optimize for Debugging` before: abca14a02be77160a86d9f4fb6eca8c18d47312d2d4be37c50de50430bbbcd07 Signed-off-by: Akos Kitta <a.kitta@arduino.cc>
1 parent 5ff9ce0 commit 337d22e

File tree

5 files changed

+52
-50
lines changed

5 files changed

+52
-50
lines changed

‎arduino-ide-extension/src/browser/arduino-preferences.ts‎

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -92,14 +92,6 @@ export const ArduinoConfigSchema: PreferenceSchema = {
9292
),
9393
default: 'None',
9494
},
95-
'arduino.compile.optimizeForDebug': {
96-
type: 'boolean',
97-
description: nls.localize(
98-
'arduino/preferences/compile.optimizeForDebug',
99-
"Optimize compile output for debug, not for release. It's 'false' by default."
100-
),
101-
default: false,
102-
},
10395
'arduino.upload.verbose': {
10496
type: 'boolean',
10597
description: nls.localize(
@@ -259,7 +251,6 @@ export interface ArduinoConfiguration {
259251
'arduino.compile.experimental': boolean;
260252
'arduino.compile.revealRange': ErrorRevealStrategy;
261253
'arduino.compile.warnings': CompilerWarnings;
262-
'arduino.compile.optimizeForDebug': boolean;
263254
'arduino.upload.verbose': boolean;
264255
'arduino.upload.verify': boolean;
265256
'arduino.window.autoScale': boolean;

‎arduino-ide-extension/src/browser/contributions/debug.ts‎

Lines changed: 26 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,10 @@ import {
1414
import { MaybePromise, MenuModelRegistry, nls } from '@theia/core/lib/common';
1515
import { CurrentSketch } from '../../common/protocol/sketches-service-client-impl';
1616
import { ArduinoMenus } from '../menu/arduino-menus';
17-
import {
18-
PreferenceScope,
19-
PreferenceService,
20-
} from '@theia/core/lib/browser/preferences/preference-service';
2117

18+
import { MainMenuManager } from '../../common/main-menu-manager';
19+
20+
const COMPILE_FOR_DEBUG_KEY = 'arduino-compile-for-debug';
2221
@injectable()
2322
export class Debug extends SketchContribution {
2423
@inject(HostedPluginSupport)
@@ -36,8 +35,8 @@ export class Debug extends SketchContribution {
3635
@inject(BoardsServiceProvider)
3736
private readonly boardsServiceProvider: BoardsServiceProvider;
3837

39-
@inject(PreferenceService)
40-
private readonly preferenceService: PreferenceService;
38+
@inject(MainMenuManager)
39+
private readonly mainMenuManager: MainMenuManager;
4140

4241
/**
4342
* If `undefined`, debugging is enabled. Otherwise, the reason why it's disabled.
@@ -105,16 +104,19 @@ export class Debug extends SketchContribution {
105104
ArduinoToolbar.is(widget) && widget.side === 'left',
106105
isEnabled: () => !this.disabledMessage,
107106
});
108-
registry.registerCommand(Debug.Commands.OPTIMIZE_FOR_DEBUG, {
109-
execute: () => this.toggleOptimizeForDebug(),
110-
isToggled: () => this.isOptimizeForDebug(),
107+
registry.registerCommand(Debug.Commands.TOGGLE_OPTIMIZE_FOR_DEBUG, {
108+
execute: () => this.toggleCompileForDebug(),
109+
isToggled: () => this.compileForDebug,
110+
});
111+
registry.registerCommand(Debug.Commands.IS_OPTIMIZE_FOR_DEBUG, {
112+
execute: () => this.compileForDebug,
111113
});
112114
}
113115

114116
override registerMenus(registry: MenuModelRegistry): void {
115117
registry.registerMenuAction(ArduinoMenus.SKETCH__MAIN_GROUP, {
116-
commandId: Debug.Commands.OPTIMIZE_FOR_DEBUG.id,
117-
label: Debug.Commands.OPTIMIZE_FOR_DEBUG.label,
118+
commandId: Debug.Commands.TOGGLE_OPTIMIZE_FOR_DEBUG.id,
119+
label: Debug.Commands.TOGGLE_OPTIMIZE_FOR_DEBUG.label,
118120
order: '5',
119121
});
120122
}
@@ -199,16 +201,16 @@ export class Debug extends SketchContribution {
199201
return this.commandService.executeCommand('arduino.debug.start', config);
200202
}
201203

202-
private isOptimizeForDebug(): boolean {
203-
return this.preferences.get('arduino.compile.optimizeForDebug');
204+
get compileForDebug(): boolean {
205+
const value = window.localStorage.getItem(COMPILE_FOR_DEBUG_KEY);
206+
return value === 'true';
204207
}
205208

206-
private async toggleOptimizeForDebug(): Promise<void> {
207-
return this.preferenceService.set(
208-
'arduino.compile.optimizeForDebug',
209-
!this.isOptimizeForDebug(),
210-
PreferenceScope.User
211-
);
209+
async toggleCompileForDebug(): Promise<void> {
210+
const oldState = this.compileForDebug;
211+
const newState = !oldState;
212+
window.localStorage.setItem(COMPILE_FOR_DEBUG_KEY, String(newState));
213+
this.mainMenuManager.update();
212214
}
213215
}
214216
export namespace Debug {
@@ -221,13 +223,16 @@ export namespace Debug {
221223
},
222224
'vscode/debug.contribution/startDebuggingHelp'
223225
);
224-
export const OPTIMIZE_FOR_DEBUG = Command.toLocalizedCommand(
226+
export const TOGGLE_OPTIMIZE_FOR_DEBUG = Command.toLocalizedCommand(
225227
{
226-
id: 'arduino-optimize-for-debug',
228+
id: 'arduino-toggle-optimize-for-debug',
227229
label: 'Optimize for Debugging',
228230
category: 'Arduino',
229231
},
230232
'arduino/debug/optimizeForDebugging'
231233
);
234+
export const IS_OPTIMIZE_FOR_DEBUG: Command = {
235+
id: 'arduino-is-optimize-for-debug',
236+
};
232237
}
233238
}

‎arduino-ide-extension/src/browser/contributions/upload-sketch.ts‎

Lines changed: 21 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -210,26 +210,32 @@ export class UploadSketch extends CoreServiceContribution {
210210
this.coreErrorHandler.reset();
211211
this.onDidChangeEmitter.fire();
212212
const { boardsConfig } = this.boardsServiceClientImpl;
213-
const [fqbn, { selectedProgrammer }, verify, verbose, sourceOverride] =
214-
await Promise.all([
215-
this.boardsDataStore.appendConfigToFqbn(
216-
boardsConfig.selectedBoard?.fqbn
217-
),
218-
this.boardsDataStore.getData(boardsConfig.selectedBoard?.fqbn),
219-
this.preferences.get('arduino.upload.verify'),
220-
this.preferences.get('arduino.upload.verbose'),
221-
this.sourceOverride(),
222-
]);
213+
const [
214+
fqbn,
215+
{ selectedProgrammer },
216+
verify,
217+
verbose,
218+
sourceOverride,
219+
optimizeForDebug,
220+
] = await Promise.all([
221+
this.boardsDataStore.appendConfigToFqbn(
222+
boardsConfig.selectedBoard?.fqbn
223+
),
224+
this.boardsDataStore.getData(boardsConfig.selectedBoard?.fqbn),
225+
this.preferences.get('arduino.upload.verify'),
226+
this.preferences.get('arduino.upload.verbose'),
227+
this.sourceOverride(),
228+
this.commandService.executeCommand<boolean>(
229+
'arduino-is-optimize-for-debug'
230+
),
231+
]);
223232

224233
const board = {
225234
...boardsConfig.selectedBoard,
226235
name: boardsConfig.selectedBoard?.name || '',
227236
fqbn,
228237
};
229238
let options: CoreService.Upload.Options | undefined = undefined;
230-
const optimizeForDebug = this.preferences.get(
231-
'arduino.compile.optimizeForDebug'
232-
);
233239
const { selectedPort } = boardsConfig;
234240
const port = selectedPort;
235241
const userFields =
@@ -249,7 +255,7 @@ export class UploadSketch extends CoreServiceContribution {
249255
options = {
250256
sketch,
251257
board,
252-
optimizeForDebug,
258+
optimizeForDebug: Boolean(optimizeForDebug),
253259
programmer,
254260
port,
255261
verbose,
@@ -261,7 +267,7 @@ export class UploadSketch extends CoreServiceContribution {
261267
options = {
262268
sketch,
263269
board,
264-
optimizeForDebug,
270+
optimizeForDebug: Boolean(optimizeForDebug),
265271
port,
266272
verbose,
267273
verify,

‎arduino-ide-extension/src/browser/contributions/verify-sketch.ts‎

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -114,14 +114,15 @@ export class VerifySketch extends CoreServiceContribution {
114114
};
115115
const verbose = this.preferences.get('arduino.compile.verbose');
116116
const compilerWarnings = this.preferences.get('arduino.compile.warnings');
117-
const optimizeForDebug = this.preferences.get(
118-
'arduino.compile.optimizeForDebug'
119-
);
117+
const optimizeForDebug =
118+
await this.commandService.executeCommand<boolean>(
119+
'arduino-is-optimize-for-debug'
120+
);
120121
this.outputChannelManager.getChannel('Arduino').clear();
121122
await this.coreService.compile({
122123
sketch,
123124
board,
124-
optimizeForDebug,
125+
optimizeForDebug: Boolean(optimizeForDebug),
125126
verbose,
126127
exportBinaries,
127128
sourceOverride,

‎i18n/en.json‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -257,7 +257,6 @@
257257
"cloud.sketchSyncEndpoint": "The endpoint used to push and pull sketches from a backend. By default it points to Arduino Cloud API.",
258258
"compile": "compile",
259259
"compile.experimental": "True if the IDE should handle multiple compiler errors. False by default",
260-
"compile.optimizeForDebug": "Optimize compile output for debug, not for release. It's 'false' by default.",
261260
"compile.revealRange": "Adjusts how compiler errors are revealed in the editor after a failed verify/upload. Possible values: 'auto': Scroll vertically as necessary and reveal a line. 'center': Scroll vertically as necessary and reveal a line centered vertically. 'top': Scroll vertically as necessary and reveal a line close to the top of the viewport, optimized for viewing a code definition. 'centerIfOutsideViewport': Scroll vertically as necessary and reveal a line centered vertically only if it lies outside the viewport. The default value is '{0}'.",
262261
"compile.verbose": "True for verbose compile output. False by default",
263262
"compile.warnings": "Tells gcc which warning level to use. It's 'None' by default",

0 commit comments

Comments
(0)

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