Skip to content

[ATL-960] Disable editor quick suggestion #221

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
merged 1 commit into from
Mar 17, 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
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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?');
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion arduino-ide-extension/src/browser/output-service-impl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
36 changes: 34 additions & 2 deletions arduino-ide-extension/src/browser/settings.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -84,6 +85,7 @@ export class SettingsService {
editorFontSize,
themeId,
autoSave,
quickSuggestions,
autoScaleInterface,
interfaceScale,
// checkForUpdates,
Expand All @@ -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),
Expand All @@ -113,6 +120,7 @@ export class SettingsService {
editorFontSize,
themeId,
autoSave,
quickSuggestions,
autoScaleInterface,
interfaceScale,
// checkForUpdates,
Expand Down Expand Up @@ -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) {
Expand All @@ -175,6 +183,7 @@ export class SettingsService {
editorFontSize,
themeId,
autoSave,
quickSuggestions,
autoScaleInterface,
interfaceScale,
// checkForUpdates,
Expand All @@ -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),
Expand Down Expand Up @@ -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'
Expand Down Expand Up @@ -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];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

.arduino-settings-dialog .content {
padding: 5px;
height: 270px;
height: 300px;
}

.arduino-settings-dialog .flex-line {
Expand Down
Original file line number Diff line number Diff line change
@@ -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 {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ SOFTWARE.
*/

import { Event } from '@theia/core/lib/common/event';
import { BrowserWindow } from "electron";
import { BrowserWindow } from 'electron';

/**
* When splashscreen was shown.
Expand Down Expand Up @@ -126,11 +126,11 @@ export const initSplashScreen = (config: Config, onCloseRequested?: Event<void>)
const window = new BrowserWindow(xConfig.windowOpts);
splashScreen = new BrowserWindow(xConfig.splashScreenOpts);
splashScreen.loadURL(`file://${xConfig.templateUrl}`);
xConfig.closeWindow && splashScreen.on("close", () => {
xConfig.closeWindow && splashScreen.on('close', () => {
done || window.close();
});
// Splashscreen is fully loaded and ready to view.
splashScreen.webContents.on("did-finish-load", () => {
splashScreen.webContents.on('did-finish-load', () => {
splashScreenReady = true;
showSplash();
});
Expand Down
2 changes: 1 addition & 1 deletion arduino-ide-extension/src/node/core-client-provider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ export class CoreClientProvider extends GrpcClientProvider<CoreClientProvider.Cl

const instance = initResp.getInstance();
if (!instance) {
throw new Error(`Could not retrieve instance from the initialize response.`);
throw new Error('Could not retrieve instance from the initialize response.');
}

// No `await`. The index update event comes later. This way we do not block app startup with index update when invalid proxy is given.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -122,9 +122,9 @@ export class MonitorServiceImpl implements MonitorService {
if (!this.connection && reason && reason.code === MonitorError.ErrorCodes.CLIENT_CANCEL) {
return Status.OK;
}
this.logger.info(`>>> Disposing monitor connection...`);
this.logger.info('>>> Disposing monitor connection...');
if (!this.connection) {
this.logger.warn(`<<< Not connected. Nothing to dispose.`);
this.logger.warn('<<< Not connected. Nothing to dispose.');
return Status.NOT_CONNECTED;
}
const { duplex, config } = this.connection;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ export class NotificationServiceServerImpl implements NotificationServiceServer
disposeClient(client: NotificationServiceClient): void {
const index = this.clients.indexOf(client);
if (index === -1) {
console.warn(`Could not dispose notification service client. It was not registered.`);
console.warn('Could not dispose notification service client. It was not registered.');
return;
}
this.clients.splice(index, 1);
Expand Down
3 changes: 2 additions & 1 deletion arduino-ide-extension/tslint.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
"check-else",
"check-whitespace"
],
"quotemark": [true, "single", "jsx-single", "avoid-escape", "avoid-template"],
"radix": true,
"trailing-comma": [false],
"triple-equals": [true, "allow-null-check"],
Expand All @@ -34,4 +35,4 @@
"check-type"
]
}
}
}
7 changes: 6 additions & 1 deletion browser-app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,12 @@
"editor.autoSave": "on",
"editor.minimap.enabled": false,
"editor.tabSize": 2,
"editor.scrollBeyondLastLine": false
"editor.scrollBeyondLastLine": false,
"editor.quickSuggestions": {
"other": false,
"comments": false,
"strings": false
}
}
}
},
Expand Down
7 changes: 6 additions & 1 deletion electron-app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,12 @@
"editor.autoSave": "on",
"editor.minimap.enabled": false,
"editor.tabSize": 2,
"editor.scrollBeyondLastLine": false
"editor.scrollBeyondLastLine": false,
"editor.quickSuggestions": {
"other": false,
"comments": false,
"strings": false
}
}
}
},
Expand Down