mirror of
https://github.com/atom/atom.git
synced 2026-02-09 06:05:11 -05:00
Position autocomplete menu above cursor if there isn't room below
This commit is contained in:
@@ -100,12 +100,12 @@ class Autocomplete extends View
|
||||
@originalSelectionBufferRange = @editor.getSelection().getBufferRange()
|
||||
@allMatches = @findMatchesForCurrentSelection()
|
||||
|
||||
cursorScreenPosition = @editor.getCursorScreenPosition()
|
||||
{left, top} = @editor.pixelPositionForScreenPosition(cursorScreenPosition)
|
||||
@css {left: left, top: top + @editor.lineHeight}
|
||||
|
||||
originalCursorPosition = @editor.getCursorScreenPosition()
|
||||
@filterMatches()
|
||||
@editor.lines.append(this)
|
||||
@setPosition(originalCursorPosition)
|
||||
|
||||
@miniEditor.focus()
|
||||
|
||||
detach: ->
|
||||
@@ -114,6 +114,15 @@ class Autocomplete extends View
|
||||
super
|
||||
@miniEditor.buffer.setText('')
|
||||
|
||||
setPosition: (originalCursorPosition) ->
|
||||
{ left, top } = @editor.pixelPositionForScreenPosition(originalCursorPosition)
|
||||
potentialTop = top + @editor.lineHeight
|
||||
potentialBottom = potentialTop + @outerHeight()
|
||||
if potentialBottom > @editor.scroller.scrollBottom()
|
||||
@css(left: left, bottom: @editor.lines.height() - top, top: 'inherit')
|
||||
else
|
||||
@css(left: left, top: potentialTop, bottom: 'inherit')
|
||||
|
||||
selectPreviousMatch: ->
|
||||
previousIndex = @currentMatchIndex - 1
|
||||
previousIndex = @filteredMatches.length - 1 if previousIndex < 0
|
||||
|
||||
Reference in New Issue
Block a user