From e5ab835357ace03e63c51b4ea060f2aa424866bb Mon Sep 17 00:00:00 2001 From: Mike J Innes Date: Fri, 27 May 2016 00:05:12 +0100 Subject: [PATCH] add `stable` option --- src/text-editor-presenter.coffee | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/src/text-editor-presenter.coffee b/src/text-editor-presenter.coffee index cc988bbea..07499c822 100644 --- a/src/text-editor-presenter.coffee +++ b/src/text-editor-presenter.coffee @@ -451,7 +451,7 @@ class TextEditorPresenter for decoration in @model.getOverlayDecorations() continue unless decoration.getMarker().isValid() - {item, position, class: klass} = decoration.getProperties() + {item, position, class: klass, stable} = decoration.getProperties() if position is 'tail' screenPosition = decoration.getMarker().getTailScreenPosition() else @@ -466,15 +466,17 @@ class TextEditorPresenter if overlayDimensions = @overlayDimensions[decoration.id] {itemWidth, itemHeight, contentMargin} = overlayDimensions - rightDiff = left + itemWidth + contentMargin - @windowWidth - left -= rightDiff if rightDiff > 0 + if !stable - leftDiff = left + contentMargin - left -= leftDiff if leftDiff < 0 + rightDiff = left + itemWidth + contentMargin - @windowWidth + left -= rightDiff if rightDiff > 0 - if top + itemHeight > @windowHeight and - top - (itemHeight + @lineHeight) >= 0 - top -= itemHeight + @lineHeight + leftDiff = left + contentMargin + left -= leftDiff if leftDiff < 0 + + if top + itemHeight > @windowHeight and + top - (itemHeight + @lineHeight) >= 0 + top -= itemHeight + @lineHeight pixelPosition.top = top pixelPosition.left = left