Skip to content

Commit

Permalink
style: quick input widget size fix
Browse files Browse the repository at this point in the history
This commit implements quick-input-widget size change with respect to app size, as well as handling text overflow resulting from this.

Signed-off-by: FernandoAscencio <[email protected]>
  • Loading branch information
FernandoAscencio committed Jan 24, 2023
1 parent bf600d7 commit f8a53d2
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 21 deletions.
13 changes: 12 additions & 1 deletion packages/monaco/src/browser/monaco-quick-input-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ export class MonacoQuickInputImplementation implements IQuickInputService {
this.themeService.initialized.then(() => this.controller.applyStyles(this.getStyles()));
// Hook into the theming service of Monaco to ensure that the updates are ready.
StandaloneServices.get(IStandaloneThemeService).onDidColorThemeChange(() => this.controller.applyStyles(this.getStyles()));
window.addEventListener('resize',() => this.updateLayout());
}

setContextKey(key: string | undefined): void {
Expand Down Expand Up @@ -176,7 +177,17 @@ export class MonacoQuickInputImplementation implements IQuickInputService {

private initController(): void {
this.controller = new QuickInputController(this.getOptions());
this.controller.layout({ width: 600, height: 1200 }, 0);
this.updateLayout();
}

private updateLayout(): void {
// Initialize the layout using screen dimensions as monaco computes the actual sizing.
// https://github.com/microsoft/vscode/blob/6261075646f055b99068d3688932416f2346dd3b/src/vs/base/parts/quickinput/browser/quickInput.ts#L1799
this.controller.layout(this.getClientDimension(),0);
}

private getClientDimension():monaco.editor.IDimension {
return {width: window.innerWidth, height: innerHeight}
}

private getOptions(): IQuickInputOptions {
Expand Down
20 changes: 0 additions & 20 deletions packages/monaco/src/browser/style/index.css
Original file line number Diff line number Diff line change
Expand Up @@ -99,30 +99,10 @@

/* Monaco Quick Input */
.quick-input-widget {
width: 600px !important;
margin-left: -300px !important;
background-color: var(--theia-quickInput-background) !important;
color: var(--theia-foreground) !important;
}

.quick-input-list
.quick-input-list-rows
> .quick-input-list-row
.monaco-icon-label,
.quick-input-list
.quick-input-list-rows
> .quick-input-list-row
.monaco-icon-label
.monaco-icon-label-container,
.quick-input-list
.quick-input-list-rows
> .quick-input-list-row
.monaco-icon-label
.monaco-icon-label-container
> .monaco-icon-name-container {
display: flex !important;
}

.quick-input-list .monaco-list-row.focused {
background-color: var(--theia-quickInputList-focusBackground) !important;
}
Expand Down

0 comments on commit f8a53d2

Please sign in to comment.