Skip to content

Commit

Permalink
Merge branch 'master' into issues/12905
Browse files Browse the repository at this point in the history
  • Loading branch information
rschnekenbu authored Sep 26, 2023
2 parents 8f60558 + fcde5ea commit 8788785
Show file tree
Hide file tree
Showing 41 changed files with 421 additions and 590 deletions.
6 changes: 3 additions & 3 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@

- [Previous Changelogs](https://github.com/eclipse-theia/theia/tree/master/doc/changelogs/)

## v1.42.0 - 09/28/2023
## v1.42.0

- [core] fixed logger level propagation when log config file changes at runtime [#12566](https://github.com/eclipse-theia/theia/pull/12566) - Contributed on behalf of STMicroelectronics
- [dialogs] allow multiple selection on Open... [#12923](https://github.com/eclipse-theia/theia/pull/12923) - Contributed on behalf of STMicroelectronics.

<a name="breaking_changes_1.42.0">[Breaking Changes:](#breaking_changes_1.42.0)</a>
- [vsx-registry] added a hint to extension fetching ENOTFOUND errors [#12858](https://github.com/eclipse-theia/theia/pull/12858) - Contributed by STMicroelectronics

## v1.41.0 - 08/31/2023

Expand Down
9 changes: 4 additions & 5 deletions packages/console/src/browser/console-contribution.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ import { injectable, inject } from '@theia/core/shared/inversify';
import { Command, CommandContribution, CommandRegistry, MenuContribution, MenuModelRegistry, CommandHandler } from '@theia/core';
import { FrontendApplicationContribution, KeybindingContribution, KeybindingRegistry, CommonCommands } from '@theia/core/lib/browser';
import { ConsoleManager } from './console-manager';
import { ConsoleKeybindingContexts } from './console-keybinding-contexts';
import { ConsoleWidget } from './console-widget';
import { ConsoleContentWidget } from './console-content-widget';
import { nls } from '@theia/core/lib/common/nls';
Expand Down Expand Up @@ -70,22 +69,22 @@ export class ConsoleContribution implements FrontendApplicationContribution, Com
keybindings.registerKeybinding({
command: ConsoleCommands.SELECT_ALL.id,
keybinding: 'ctrlcmd+a',
context: ConsoleKeybindingContexts.consoleContentFocus
when: 'consoleContentFocus'
});
keybindings.registerKeybinding({
command: ConsoleCommands.EXECUTE.id,
keybinding: 'enter',
context: ConsoleKeybindingContexts.consoleInputFocus
when: 'consoleInputFocus'
});
keybindings.registerKeybinding({
command: ConsoleCommands.NAVIGATE_BACK.id,
keybinding: 'up',
context: ConsoleKeybindingContexts.consoleNavigationBackEnabled
when: 'consoleInputFocus && consoleNavigationBackEnabled'
});
keybindings.registerKeybinding({
command: ConsoleCommands.NAVIGATE_FORWARD.id,
keybinding: 'down',
context: ConsoleKeybindingContexts.consoleNavigationForwardEnabled
when: 'consoleInputFocus && consoleNavigationForwardEnabled'
});
}

Expand Down
7 changes: 1 addition & 6 deletions packages/console/src/browser/console-frontend-module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,19 +16,14 @@

import { ContainerModule } from '@theia/core/shared/inversify';
import { CommandContribution, MenuContribution } from '@theia/core';
import { FrontendApplicationContribution, KeybindingContext, KeybindingContribution } from '@theia/core/lib/browser';
import { FrontendApplicationContribution, KeybindingContribution } from '@theia/core/lib/browser';
import { ConsoleContribution } from './console-contribution';
import { ConsoleManager } from './console-manager';
import { ConsoleInputFocusContext, ConsoleNavigationBackEnabled, ConsoleNavigationForwardEnabled, ConsoleContentFocusContext } from './console-keybinding-contexts';

import '../../src/browser/style/index.css';

export default new ContainerModule(bind => {
bind(ConsoleManager).toSelf().inSingletonScope();
bind(KeybindingContext).to(ConsoleInputFocusContext).inSingletonScope();
bind(KeybindingContext).to(ConsoleContentFocusContext).inSingletonScope();
bind(KeybindingContext).to(ConsoleNavigationBackEnabled).inSingletonScope();
bind(KeybindingContext).to(ConsoleNavigationForwardEnabled).inSingletonScope();
bind(ConsoleContribution).toSelf().inSingletonScope();
bind(FrontendApplicationContribution).toService(ConsoleContribution);
bind(CommandContribution).toService(ConsoleContribution);
Expand Down
107 changes: 0 additions & 107 deletions packages/console/src/browser/console-keybinding-contexts.ts

This file was deleted.

24 changes: 23 additions & 1 deletion packages/console/src/browser/console-widget.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
import { ElementExt } from '@theia/core/shared/@phosphor/domutils';
import { injectable, inject, postConstruct, interfaces, Container } from '@theia/core/shared/inversify';
import { TreeSourceNode } from '@theia/core/lib/browser/source-tree';
import { ContextKey } from '@theia/core/lib/browser/context-key-service';
import { ContextKeyService, ContextKey } from '@theia/core/lib/browser/context-key-service';
import { BaseWidget, PanelLayout, Widget, Message, MessageLoop, StatefulWidget, CompositeTreeNode } from '@theia/core/lib/browser';
import { MonacoEditor } from '@theia/monaco/lib/browser/monaco-editor';
import URI from '@theia/core/lib/common/uri';
Expand Down Expand Up @@ -75,7 +75,11 @@ export class ConsoleWidget extends BaseWidget implements StatefulWidget {
@inject(MonacoEditorProvider)
protected readonly editorProvider: MonacoEditorProvider;

@inject(ContextKeyService)
protected readonly contextKeyService: ContextKeyService;

protected _input: MonacoEditor;
protected _inputFocusContextKey: ContextKey<boolean>;

constructor() {
super();
Expand Down Expand Up @@ -129,7 +133,13 @@ export class ConsoleWidget extends BaseWidget implements StatefulWidget {
this.updateFont();
if (inputFocusContextKey) {
this.toDispose.push(input.onFocusChanged(() => inputFocusContextKey.set(this.hasInputFocus())));
this.toDispose.push(input.onCursorPositionChanged(() => input.getControl().createContextKey('consoleNavigationBackEnabled', this.consoleNavigationBackEnabled)));
this.toDispose.push(input.onCursorPositionChanged(() => input.getControl().createContextKey('consoleNavigationForwardEnabled', this.consoleNavigationForwardEnabled)));
}
input.getControl().createContextKey('consoleInputFocus', true);
const contentContext = this.contextKeyService.createScoped(this.content.node);
contentContext.setContext('consoleContentFocus', true);
this.toDispose.push(contentContext);
}

protected createInput(node: HTMLElement): Promise<MonacoEditor> {
Expand Down Expand Up @@ -159,6 +169,18 @@ export class ConsoleWidget extends BaseWidget implements StatefulWidget {
return this._input;
}

get consoleNavigationBackEnabled(): boolean {
const editor = this.input.getControl();
return !!editor.getPosition()!.equals({ lineNumber: 1, column: 1 });
}

get consoleNavigationForwardEnabled(): boolean {
const editor = this.input.getControl();
const lineNumber = editor.getModel()!.getLineCount();
const column = editor.getModel()!.getLineMaxColumn(lineNumber);
return !!editor.getPosition()!.equals({ lineNumber, column });
}

selectAll(): void {
const selection = document.getSelection();
if (selection) {
Expand Down
11 changes: 11 additions & 0 deletions packages/core/src/browser/shell/application-shell.ts
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,9 @@ export class ApplicationShell extends Widget {
protected readonly onDidChangeCurrentWidgetEmitter = new Emitter<FocusTracker.IChangedArgs<Widget>>();
readonly onDidChangeCurrentWidget = this.onDidChangeCurrentWidgetEmitter.event;

protected readonly onDidDoubleClickMainAreaEmitter = new Emitter<void>();
readonly onDidDoubleClickMainArea = this.onDidDoubleClickMainAreaEmitter.event;

@inject(TheiaDockPanel.Factory)
protected readonly dockPanelFactory: TheiaDockPanel.Factory;

Expand Down Expand Up @@ -578,6 +581,14 @@ export class ApplicationShell extends Widget {
}
}
});

dockPanel.node.addEventListener('dblclick', event => {
const el = event.target as Element;
if (el.id === MAIN_AREA_ID || el.classList.contains('p-TabBar-content')) {
this.onDidDoubleClickMainAreaEmitter.fire();
}
});

const handler = (e: DragEvent) => {
if (e.dataTransfer) {
e.dataTransfer.dropEffect = 'link';
Expand Down
7 changes: 4 additions & 3 deletions packages/core/src/common/keys.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
// *****************************************************************************

import { nls } from './nls';
import { isOSX } from './os';
import { isObject } from './types';

Expand Down Expand Up @@ -252,7 +253,7 @@ export class KeyCode {
}
/* If duplicates i.e ctrl+ctrl+a or alt+alt+b or b+alt+b it is invalid */
if (keys.length !== new Set(keys).size) {
throw new Error(`Can't parse keybinding ${keybinding} Duplicate modifiers`);
throw new Error(nls.localize('theia/core/keybinding/duplicateModifierError', "Can't parse keybinding {0} Duplicate modifiers", keybinding));
}

for (let keyString of keys) {
Expand All @@ -266,7 +267,7 @@ export class KeyCode {
if (isOSX) {
schema.meta = true;
} else {
throw new Error(`Can't parse keybinding ${keybinding} meta is for OSX only`);
throw new Error(nls.localize('theia/core/keybinding/metaError', "Can't parse keybinding {0} meta is for OSX only", keybinding));
}
/* ctrlcmd for M1 keybindings that work on both macOS and other platforms */
} else if (keyString === SpecialCases.CTRLCMD) {
Expand All @@ -288,7 +289,7 @@ export class KeyCode {
schema.key = key;
}
} else {
throw new Error(`Unrecognized key '${keyString}' in '${keybinding}'`);
throw new Error(nls.localize('theia/core/keybinding/unrecognizedKeyError', 'Unrecognized key {0} in {1}', keyString, keybinding));
}
}

Expand Down
4 changes: 4 additions & 0 deletions packages/core/src/common/logger-protocol.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ export interface ILogLevelChangedEvent {

export interface ILoggerClient {
onLogLevelChanged(event: ILogLevelChangedEvent): void;
onLogConfigChanged(): void;
}

@injectable()
Expand All @@ -49,6 +50,9 @@ export class DispatchingLoggerClient implements ILoggerClient {
this.clients.forEach(client => client.onLogLevelChanged(event));
}

onLogConfigChanged(): void {
this.clients.forEach(client => client.onLogConfigChanged());
}
}

export const rootLoggerName = 'root';
Expand Down
19 changes: 12 additions & 7 deletions packages/core/src/common/logger-watcher.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,22 +22,27 @@ import { ILoggerClient, ILogLevelChangedEvent } from './logger-protocol';
export class LoggerWatcher {

getLoggerClient(): ILoggerClient {
const emitter = this.onLogLevelChangedEmitter;
const logLevelEmitter = this.onLogLevelChangedEmitter;
const logConfigEmitter = this.onLogConfigChangedEmitter;
return {
onLogLevelChanged(event: ILogLevelChangedEvent): void {
emitter.fire(event);
}
logLevelEmitter.fire(event);
},
onLogConfigChanged(): void {
logConfigEmitter.fire();
},
};
}

private onLogLevelChangedEmitter = new Emitter<ILogLevelChangedEvent>();
protected onLogLevelChangedEmitter = new Emitter<ILogLevelChangedEvent>();

get onLogLevelChanged(): Event<ILogLevelChangedEvent> {
return this.onLogLevelChangedEmitter.event;
}

// FIXME: get rid of it, backend services should as well set a client on the server
fireLogLevelChanged(event: ILogLevelChangedEvent): void {
this.onLogLevelChangedEmitter.fire(event);
protected onLogConfigChangedEmitter = new Emitter<void>();

get onLogConfigChanged(): Event<void> {
return this.onLogConfigChangedEmitter.event;
}
}
5 changes: 5 additions & 0 deletions packages/core/src/common/logger.ts
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,11 @@ export class Logger implements ILogger {
}
});
});

/* Refetch log level if overall config in backend changed. */
this.loggerWatcher.onLogConfigChanged(() => {
this._logLevel = this.created.then(_ => this.server.getLogLevel(this.name));
});
}

setLogLevel(logLevel: number): Promise<void> {
Expand Down
7 changes: 5 additions & 2 deletions packages/core/src/node/console-logger-server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
import { inject, injectable, postConstruct } from 'inversify';
import { LoggerWatcher } from '../common/logger-watcher';
import { LogLevelCliContribution } from './logger-cli-contribution';
import { ILoggerServer, ILoggerClient, ConsoleLogger } from '../common/logger-protocol';
import { ILoggerServer, ILoggerClient, ConsoleLogger, rootLoggerName } from '../common/logger-protocol';

@injectable()
export class ConsoleLoggerServer implements ILoggerServer {
Expand All @@ -32,9 +32,13 @@ export class ConsoleLoggerServer implements ILoggerServer {

@postConstruct()
protected init(): void {
this.setLogLevel(rootLoggerName, this.cli.defaultLogLevel);
for (const name of Object.keys(this.cli.logLevels)) {
this.setLogLevel(name, this.cli.logLevels[name]);
}
this.cli.onLogConfigChanged(() => {
this.client?.onLogConfigChanged();
});
}

async setLogLevel(name: string, newLogLevel: number): Promise<void> {
Expand All @@ -45,7 +49,6 @@ export class ConsoleLoggerServer implements ILoggerServer {
if (this.client !== undefined) {
this.client.onLogLevelChanged(event);
}
this.watcher.fireLogLevelChanged(event);
}

async getLogLevel(name: string): Promise<number> {
Expand Down
Loading

0 comments on commit 8788785

Please sign in to comment.