From 85e31cfacb2b8228da1c66877dc39e60b0ab3d99 Mon Sep 17 00:00:00 2001 From: Ramya Achutha Rao Date: Fri, 2 Jun 2017 17:39:35 -0700 Subject: [PATCH] Set maxheight on docs dynamically #27954 --- .../contrib/suggest/browser/media/suggest.css | 1 - .../contrib/suggest/browser/suggestWidget.ts | 15 ++++++--------- 2 files changed, 6 insertions(+), 10 deletions(-) diff --git a/src/vs/editor/contrib/suggest/browser/media/suggest.css b/src/vs/editor/contrib/suggest/browser/media/suggest.css index 0fc6559fdf1..a154e7c1959 100644 --- a/src/vs/editor/contrib/suggest/browser/media/suggest.css +++ b/src/vs/editor/contrib/suggest/browser/media/suggest.css @@ -210,7 +210,6 @@ /** Styles for the docs of the completion item in focus **/ .monaco-editor .suggest-widget .details { - max-height: 216px; display: flex; flex-direction: column; cursor: default; diff --git a/src/vs/editor/contrib/suggest/browser/suggestWidget.ts b/src/vs/editor/contrib/suggest/browser/suggestWidget.ts index f12fe31c393..1c7a97e314b 100644 --- a/src/vs/editor/contrib/suggest/browser/suggestWidget.ts +++ b/src/vs/editor/contrib/suggest/browser/suggestWidget.ts @@ -34,6 +34,7 @@ import { IStorageService, StorageScope } from 'vs/platform/storage/common/storag const sticky = false; // for development purposes const expandSuggestionDocsByDefault = false; +const maxSuggestionsToShow = 12; interface ISuggestionTemplateData { root: HTMLElement; @@ -852,6 +853,7 @@ export class SuggestWidget implements IContentWidget, IDelegate show(this.details.element); this.renderDetails(); + this.details.element.style.maxHeight = this.maxWidgetHeight + 'px'; // Reset margin-top that was set as Fix for #26416 this.listElement.style.marginTop = '0px'; @@ -909,17 +911,12 @@ export class SuggestWidget implements IContentWidget, IDelegate private updateListHeight(): number { let height = 0; - let maxSuggestionsToShow = 11; if (this.state === State.Empty || this.state === State.Loading) { height = this.unfocusedHeight; } else { - const focus = this.list.getFocusedElements()[0]; - const focusHeight = focus ? this.getHeight(focus) : this.unfocusedHeight; - height = focusHeight; - - const suggestionCount = (this.list.contentHeight - focusHeight) / this.unfocusedHeight; - height += Math.min(suggestionCount, maxSuggestionsToShow) * this.unfocusedHeight; + const suggestionCount = this.list.contentHeight / this.unfocusedHeight; + height = Math.min(suggestionCount, maxSuggestionsToShow) * this.unfocusedHeight; } this.element.style.lineHeight = `${this.unfocusedHeight}px`; @@ -981,8 +978,8 @@ export class SuggestWidget implements IContentWidget, IDelegate // Heights - private get focusHeight(): number { - return this.unfocusedHeight * 2; + private get maxWidgetHeight(): number { + return this.unfocusedHeight * maxSuggestionsToShow; } private get unfocusedHeight(): number {