Dynamically adjust the width of autocomplete popup.

This commit is contained in:
Shane Kilkelly 2017-08-01 13:40:30 +01:00
parent 9a85e42ddb
commit 3ffef7fe56
2 changed files with 12 additions and 5 deletions

View file

@ -282,7 +282,18 @@ define [
editor.completer.autoSelect = true
editor.completer.showPopup(editor)
editor.completer.cancelContextMenu()
$(editor.completer.popup?.container).css({'font-size': @$scope.fontSize + 'px'})
container = $(editor.completer.popup?.container)
container.css({'font-size': @$scope.fontSize + 'px'})
# Dynamically set width of autocomplete popup
if filtered = editor?.completer?.completions?.filtered
longestCaption = _.max(filtered.map( (c) -> c.caption.length ))
longestMeta = _.max(filtered.map( (c) -> c.meta.length ))
charScale = @$scope.fontSize * 0.7
width = Math.min(
Math.round(longestCaption*charScale + longestMeta*charScale + 25),
700
)
container.css({width: "#{width}px"})
if editor.completer?.completions?.filtered?.length == 0
editor.completer.detach()
bindKey: "Ctrl-Space|Ctrl-Shift-Space|Alt-Space"

View file

@ -505,7 +505,3 @@
border-bottom: 1px solid @modal-header-border-color;
}
// Widen autocomplete popup
.ace_autocomplete {
width: 380px !important;
}