Skip to content
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

monaco: improve responsiveness of quick-input menus #12095

Merged
merged 1 commit into from
Jan 26, 2023
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
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: window.innerHeight };
}

private getOptions(): IQuickInputOptions {
Expand Down
14 changes: 3 additions & 11 deletions packages/monaco/src/browser/style/index.css
Original file line number Diff line number Diff line change
Expand Up @@ -99,8 +99,6 @@

/* 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;
}
Expand All @@ -121,6 +119,7 @@
.monaco-icon-label-container
> .monaco-icon-name-container {
display: flex !important;
overflow: hidden;
}

.quick-input-list .monaco-list-row.focused {
Expand Down Expand Up @@ -170,15 +169,6 @@
line-height: 22px;
}

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

.quick-input-list-rows
.quick-input-list-row
.monaco-icon-label
Expand All @@ -198,6 +188,8 @@
font-family: var(--theia-ui-font-family);
font-size: var(--theia-ui-font-size1) !important;
color: var(--theia-foreground) !important;
overflow: hidden;
text-overflow: ellipsis;
}

.quick-input-list .monaco-icon-label::before {
Expand Down