Fixed highlighting of non-unicode chars in Output

Closes #1210

Signed-off-by: Akos Kitta <a.kitta@arduino.cc>
This commit is contained in:
Akos Kitta 2022-08-26 11:26:44 +02:00 committed by Akos Kitta
parent 5cb9166c83
commit 204d71b2dd
3 changed files with 34 additions and 18 deletions

View File

@ -141,8 +141,6 @@ import { WorkspaceDeleteHandler } from './theia/workspace/workspace-delete-handl
import { TabBarToolbar } from './theia/core/tab-bar-toolbar'; import { TabBarToolbar } from './theia/core/tab-bar-toolbar';
import { EditorWidgetFactory as TheiaEditorWidgetFactory } from '@theia/editor/lib/browser/editor-widget-factory'; import { EditorWidgetFactory as TheiaEditorWidgetFactory } from '@theia/editor/lib/browser/editor-widget-factory';
import { EditorWidgetFactory } from './theia/editor/editor-widget-factory'; import { EditorWidgetFactory } from './theia/editor/editor-widget-factory';
import { OutputWidget as TheiaOutputWidget } from '@theia/output/lib/browser/output-widget';
import { OutputWidget } from './theia/output/output-widget';
import { BurnBootloader } from './contributions/burn-bootloader'; import { BurnBootloader } from './contributions/burn-bootloader';
import { import {
ExamplesServicePath, ExamplesServicePath,
@ -215,7 +213,10 @@ import { SearchInWorkspaceFactory } from './theia/search-in-workspace/search-in-
import { SearchInWorkspaceResultTreeWidget as TheiaSearchInWorkspaceResultTreeWidget } from '@theia/search-in-workspace/lib/browser/search-in-workspace-result-tree-widget'; import { SearchInWorkspaceResultTreeWidget as TheiaSearchInWorkspaceResultTreeWidget } from '@theia/search-in-workspace/lib/browser/search-in-workspace-result-tree-widget';
import { SearchInWorkspaceResultTreeWidget } from './theia/search-in-workspace/search-in-workspace-result-tree-widget'; import { SearchInWorkspaceResultTreeWidget } from './theia/search-in-workspace/search-in-workspace-result-tree-widget';
import { MonacoEditorProvider } from './theia/monaco/monaco-editor-provider'; import { MonacoEditorProvider } from './theia/monaco/monaco-editor-provider';
import { MonacoEditorProvider as TheiaMonacoEditorProvider } from '@theia/monaco/lib/browser/monaco-editor-provider'; import {
MonacoEditorFactory,
MonacoEditorProvider as TheiaMonacoEditorProvider,
} from '@theia/monaco/lib/browser/monaco-editor-provider';
import { StorageWrapper } from './storage-wrapper'; import { StorageWrapper } from './storage-wrapper';
import { NotificationManager } from './theia/messages/notifications-manager'; import { NotificationManager } from './theia/messages/notifications-manager';
import { NotificationManager as TheiaNotificationManager } from '@theia/messages/lib/browser/notifications-manager'; import { NotificationManager as TheiaNotificationManager } from '@theia/messages/lib/browser/notifications-manager';
@ -332,6 +333,7 @@ import {
LibraryFilterRenderer, LibraryFilterRenderer,
} from './widgets/component-list/filter-renderer'; } from './widgets/component-list/filter-renderer';
import { CheckForUpdates } from './contributions/check-for-updates'; import { CheckForUpdates } from './contributions/check-for-updates';
import { OutputEditorFactory } from './theia/output/output-editor-factory';
const registerArduinoThemes = () => { const registerArduinoThemes = () => {
const themes: MonacoThemeJson[] = [ const themes: MonacoThemeJson[] = [
@ -587,8 +589,6 @@ export default new ContainerModule((bind, unbind, isBound, rebind) => {
return container.get(TabBarToolbar); return container.get(TabBarToolbar);
} }
); );
bind(OutputWidget).toSelf().inSingletonScope();
rebind(TheiaOutputWidget).toService(OutputWidget);
bind(OutputChannelManager).toSelf().inSingletonScope(); bind(OutputChannelManager).toSelf().inSingletonScope();
rebind(TheiaOutputChannelManager).toService(OutputChannelManager); rebind(TheiaOutputChannelManager).toService(OutputChannelManager);
bind(OutputChannelRegistryMainImpl).toSelf().inTransientScope(); bind(OutputChannelRegistryMainImpl).toSelf().inTransientScope();
@ -657,6 +657,11 @@ export default new ContainerModule((bind, unbind, isBound, rebind) => {
bind(EditorMenuContribution).toSelf().inSingletonScope(); bind(EditorMenuContribution).toSelf().inSingletonScope();
rebind(TheiaEditorMenuContribution).toService(EditorMenuContribution); rebind(TheiaEditorMenuContribution).toService(EditorMenuContribution);
// To disable the highlighting of non-unicode characters in the _Output_ view
bind(OutputEditorFactory).toSelf().inSingletonScope();
// Rebind to `TheiaOutputEditorFactory` when https://github.com/eclipse-theia/theia/pull/11615 is available.
rebind(MonacoEditorFactory).toService(OutputEditorFactory);
bind(ArduinoDaemon) bind(ArduinoDaemon)
.toDynamicValue((context) => .toDynamicValue((context) =>
WebSocketConnectionProvider.createProxy( WebSocketConnectionProvider.createProxy(

View File

@ -0,0 +1,24 @@
import { injectable } from '@theia/core/shared/inversify';
import { MonacoEditor } from '@theia/monaco/lib/browser/monaco-editor';
import { MonacoEditorModel } from '@theia/monaco/lib/browser/monaco-editor-model';
import { OutputEditorFactory as TheiaOutputEditorFactory } from '@theia/output/lib/browser/output-editor-factory';
@injectable()
export class OutputEditorFactory extends TheiaOutputEditorFactory {
protected override createOptions(
model: MonacoEditorModel,
defaultOptions: MonacoEditor.IOptions
): MonacoEditor.IOptions {
const options = super.createOptions(model, defaultOptions);
return {
...options,
// Taken from https://github.com/microsoft/vscode/blob/35b971c92d210face8c446a1c6f1e470ad2bcb54/src/vs/workbench/contrib/output/browser/outputView.ts#L211-L214
// To fix https://github.com/arduino/arduino-ide/issues/1210
unicodeHighlight: {
nonBasicASCII: false,
invisibleCharacters: false,
ambiguousCharacters: false,
},
};
}
}

View File

@ -1,13 +0,0 @@
import { injectable } from '@theia/core/shared/inversify';
import { Message, Widget } from '@theia/core/lib/browser';
import { OutputWidget as TheiaOutputWidget } from '@theia/output/lib/browser/output-widget';
// Patched after https://github.com/eclipse-theia/theia/issues/8361
// Remove this module after ATL-222 and the Theia update.
@injectable()
export class OutputWidget extends TheiaOutputWidget {
protected override onAfterShow(msg: Message): void {
super.onAfterShow(msg);
this.onResize(Widget.ResizeMessage.UnknownSize);
}
}