editor.quicksSuggestions.other defaults off

This commit is contained in:
Francesco Stasi
2021-03-15 09:23:20 +01:00
committed by Francesco Stasi
parent 067cc8766a
commit 6dadd1775a
13 changed files with 65 additions and 22 deletions

View File

@@ -87,7 +87,7 @@ export class BoardsServiceProvider implements FrontendApplicationContribution {
if (!AttachedBoardsChangeEvent.isEmpty(event)) {
this.logger.info('Attached boards and available ports changed:');
this.logger.info(AttachedBoardsChangeEvent.toString(event));
this.logger.info(`------------------------------------------`);
this.logger.info('------------------------------------------');
}
this._attachedBoards = event.newState.boards;
this._availablePorts = event.newState.ports;

View File

@@ -82,7 +82,7 @@ export class AddZipLibrary extends SketchContribution {
if (name) {
throw new AlreadyInstalledError(`A library folder named ${name} already exists. Do you want to overwrite it?`, name);
} else {
throw new AlreadyInstalledError(`A library already exists. Do you want to overwrite it?`);
throw new AlreadyInstalledError('A library already exists. Do you want to overwrite it?');
}
}
}

View File

@@ -14,7 +14,7 @@ export class OutputServiceImpl implements OutputService {
append(message: OutputMessage): void {
const { chunk } = message;
const channel = this.outputChannelManager.getChannel(`Arduino`);
const channel = this.outputChannelManager.getChannel('Arduino');
channel.show({ preserveFocus: true });
channel.append(chunk);
}

View File

@@ -24,6 +24,7 @@ export interface Settings extends Index {
editorFontSize: number; // `editor.fontSize`
themeId: string; // `workbench.colorTheme`
autoSave: 'on' | 'off'; // `editor.autoSave`
quickSuggestions: Record<'other'|'comments'|'strings', boolean>; // `editor.quickSuggestions`
autoScaleInterface: boolean; // `arduino.window.autoScale`
interfaceScale: number; // `arduino.window.zoomLevel` https://github.com/eclipse-theia/theia/issues/8751
@@ -84,6 +85,7 @@ export class SettingsService {
editorFontSize,
themeId,
autoSave,
quickSuggestions,
autoScaleInterface,
interfaceScale,
// checkForUpdates,
@@ -97,6 +99,11 @@ export class SettingsService {
this.preferenceService.get<number>('editor.fontSize', 12),
this.preferenceService.get<string>('workbench.colorTheme', 'arduino-theme'),
this.preferenceService.get<'on' | 'off'>('editor.autoSave', 'on'),
this.preferenceService.get<object>('editor.quickSuggestion', {
'other': false,
'comments': false,
'strings': false
}),
this.preferenceService.get<boolean>('arduino.window.autoScale', true),
this.preferenceService.get<number>('arduino.window.zoomLevel', 0),
// this.preferenceService.get<string>('arduino.ide.autoUpdate', true),
@@ -113,6 +120,7 @@ export class SettingsService {
editorFontSize,
themeId,
autoSave,
quickSuggestions,
autoScaleInterface,
interfaceScale,
// checkForUpdates,
@@ -155,10 +163,10 @@ export class SettingsService {
return `Invalid sketchbook location: ${sketchbookPath}`;
}
if (editorFontSize <= 0) {
return `Invalid editor font size. It must be a positive integer.`;
return 'Invalid editor font size. It must be a positive integer.';
}
if (!ThemeService.get().getThemes().find(({ id }) => id === themeId)) {
return `Invalid theme.`;
return 'Invalid theme.';
}
return true;
} catch (err) {
@@ -175,6 +183,7 @@ export class SettingsService {
editorFontSize,
themeId,
autoSave,
quickSuggestions,
autoScaleInterface,
interfaceScale,
// checkForUpdates,
@@ -199,6 +208,7 @@ export class SettingsService {
this.preferenceService.set('editor.fontSize', editorFontSize, PreferenceScope.User),
this.preferenceService.set('workbench.colorTheme', themeId, PreferenceScope.User),
this.preferenceService.set('editor.autoSave', autoSave, PreferenceScope.User),
this.preferenceService.set('editor.quickSuggestions', quickSuggestions, PreferenceScope.User),
this.preferenceService.set('arduino.window.autoScale', autoScaleInterface, PreferenceScope.User),
this.preferenceService.set('arduino.window.zoomLevel', interfaceScale, PreferenceScope.User),
// this.preferenceService.set('arduino.ide.autoUpdate', checkForUpdates, PreferenceScope.User),
@@ -360,6 +370,13 @@ export class SettingsComponent extends React.Component<SettingsComponent.Props,
onChange={this.autoSaveDidChange} />
Auto save
</label>
<label className='flex-line'>
<input
type='checkbox'
checked={this.state.quickSuggestions.other === true}
onChange={this.quickSuggestionsOtherDidChange} />
Editor Quick Suggestions
</label>
<label className='flex-line'>
<input
type='checkbox'
@@ -551,6 +568,21 @@ export class SettingsComponent extends React.Component<SettingsComponent.Props,
this.setState({ autoSave: event.target.checked ? 'on' : 'off' });
};
protected quickSuggestionsOtherDidChange = (event: React.ChangeEvent<HTMLInputElement>) => {
// need to persist react events through lifecycle https://reactjs.org/docs/events.html#event-pooling
const newVal = event.target.checked ? true : false
this.setState(prevState => {
return {
quickSuggestions: {
...prevState.quickSuggestions,
other: newVal
}
}
});
};
protected themeDidChange = (event: React.ChangeEvent<HTMLSelectElement>) => {
const { selectedIndex } = event.target.options;
const theme = ThemeService.get().getThemes()[selectedIndex];

View File

@@ -4,7 +4,7 @@
.arduino-settings-dialog .content {
padding: 5px;
height: 270px;
height: 300px;
}
.arduino-settings-dialog .flex-line {

View File

@@ -1,9 +1,9 @@
import { FrontendApplicationContribution, FrontendApplication, Widget, Message } from "@theia/core/lib/browser";
import { injectable, inject } from "inversify";
import { ArduinoToolbar } from "./arduino-toolbar";
import { TabBarToolbarRegistry } from "@theia/core/lib/browser/shell/tab-bar-toolbar";
import { CommandRegistry } from "@theia/core";
import { LabelParser } from "@theia/core/lib/browser/label-parser";
import { FrontendApplicationContribution, FrontendApplication, Widget, Message } from '@theia/core/lib/browser';
import { injectable, inject } from 'inversify';
import { ArduinoToolbar } from './arduino-toolbar';
import { TabBarToolbarRegistry } from '@theia/core/lib/browser/shell/tab-bar-toolbar';
import { CommandRegistry } from '@theia/core';
import { LabelParser } from '@theia/core/lib/browser/label-parser';
export class ArduinoToolbarContainer extends Widget {