mirror of
https://github.com/atom/atom.git
synced 2026-04-06 03:02:13 -04:00
Add ‘position’ option to overlay decorations
By default overlays are positioned at the head of the given marker. This option allows them to be positioned at the tail instead by passing `position: ’tail’` when creating the decoration, which is useful for autocomplete.
This commit is contained in:
@@ -7,9 +7,12 @@ class OverlayManager
|
||||
{editor, overlayDecorations, lineHeightInPixels} = props
|
||||
|
||||
existingDecorations = null
|
||||
for markerId, {isMarkerReversed, headPixelPosition, decorations} of overlayDecorations
|
||||
for markerId, {headPixelPosition, tailPixelPosition, decorations} of overlayDecorations
|
||||
for decoration in decorations
|
||||
@renderOverlay(editor, decoration, headPixelPosition, lineHeightInPixels)
|
||||
pixelPosition =
|
||||
if decoration.position is 'tail' then tailPixelPosition else headPixelPosition
|
||||
|
||||
@renderOverlay(editor, decoration, pixelPosition, lineHeightInPixels)
|
||||
|
||||
existingDecorations ?= {}
|
||||
existingDecorations[decoration.id] = true
|
||||
|
||||
@@ -364,6 +364,7 @@ TextEditorComponent = React.createClass
|
||||
for markerId, decorations of decorationsByMarkerId
|
||||
marker = editor.getMarker(markerId)
|
||||
headScreenPosition = marker.getHeadScreenPosition()
|
||||
tailScreenPosition = marker.getTailScreenPosition()
|
||||
if marker.isValid()
|
||||
for decoration in decorations
|
||||
if decoration.isType('overlay')
|
||||
@@ -371,6 +372,7 @@ TextEditorComponent = React.createClass
|
||||
filteredDecorations[markerId] ?=
|
||||
id: markerId
|
||||
headPixelPosition: editor.pixelPositionForScreenPosition(headScreenPosition)
|
||||
tailPixelPosition: editor.pixelPositionForScreenPosition(tailScreenPosition)
|
||||
decorations: []
|
||||
filteredDecorations[markerId].decorations.push decorationParams
|
||||
filteredDecorations
|
||||
|
||||
Reference in New Issue
Block a user