From be5c791609657621a3597fdea34be05cba4db79e Mon Sep 17 00:00:00 2001 From: Antonio Scandurra Date: Tue, 29 Sep 2015 08:41:45 +0200 Subject: [PATCH 1/2] Fix deprecations --- lib/wrap-guide-element.coffee | 7 ++----- spec/wrap-guide-spec.coffee | 4 ++-- 2 files changed, 4 insertions(+), 7 deletions(-) diff --git a/lib/wrap-guide-element.coffee b/lib/wrap-guide-element.coffee index 81e78f9..bd6cdf3 100644 --- a/lib/wrap-guide-element.coffee +++ b/lib/wrap-guide-element.coffee @@ -23,9 +23,7 @@ class WrapGuideElement extends HTMLDivElement # setTimeout because we need to wait for the editor measurement to happen setTimeout(updateGuideCallback, 0) - # FIXME: remove conditional as soon as the tiled editor is released. - if @editorElement.hasTiledRendering - subscriptions.add @editor.onDidChangeScrollLeft(updateGuideCallback) + subscriptions.add @editorElement.onDidChangeScrollLeft(updateGuideCallback) subscriptions.add @editor.onDidChangePath(updateGuideCallback) subscriptions.add @editor.onDidChangeGrammar => @@ -82,8 +80,7 @@ class WrapGuideElement extends HTMLDivElement column = @getGuideColumn(@editor.getPath(), @editor.getGrammar().scopeName) if column > 0 and @isEnabled() columnWidth = @editorElement.getDefaultCharacterWidth() * column - # FIXME: remove conditional as soon as the tiled editor is released. - columnWidth -= @editor.getScrollLeft() if @editorElement.hasTiledRendering + columnWidth -= @editorElement.getScrollLeft() @style.left = "#{columnWidth}px" @style.display = 'block' else diff --git a/spec/wrap-guide-spec.coffee b/spec/wrap-guide-spec.coffee index eb174ca..4eb61b8 100644 --- a/spec/wrap-guide-spec.coffee +++ b/spec/wrap-guide-spec.coffee @@ -85,12 +85,12 @@ describe "WrapGuide", -> return unless editorElement.hasTiledRendering editor.setText("a long line which causes the editor to scroll") - editor.setWidth(100) + editorElement.setWidth(100) initial = getLeftPosition(wrapGuide) expect(initial).toBeGreaterThan(0) - editor.setScrollLeft(10) + editorElement.setScrollLeft(10) expect(getLeftPosition(wrapGuide)).toBe(initial - 10) expect(wrapGuide).toBeVisible() From 1a57a996b03526d0d380ae13b2580c7011d4dac4 Mon Sep 17 00:00:00 2001 From: Antonio Scandurra Date: Wed, 30 Sep 2015 10:12:20 +0200 Subject: [PATCH 2/2] Make package work with both versions of the display buffer --- lib/wrap-guide-element.coffee | 12 ++++++++++-- spec/wrap-guide-spec.coffee | 15 ++++++++++----- 2 files changed, 20 insertions(+), 7 deletions(-) diff --git a/lib/wrap-guide-element.coffee b/lib/wrap-guide-element.coffee index bd6cdf3..8b95ec0 100644 --- a/lib/wrap-guide-element.coffee +++ b/lib/wrap-guide-element.coffee @@ -1,5 +1,7 @@ {CompositeDisposable} = require 'atom' +# TODO: remove references to logical display buffer when it is released. + class WrapGuideElement extends HTMLDivElement initialize: (@editor, @editorElement) -> @classList.add('wrap-guide') @@ -23,7 +25,10 @@ class WrapGuideElement extends HTMLDivElement # setTimeout because we need to wait for the editor measurement to happen setTimeout(updateGuideCallback, 0) - subscriptions.add @editorElement.onDidChangeScrollLeft(updateGuideCallback) + if @editorElement.logicalDisplayBuffer + subscriptions.add @editorElement.onDidChangeScrollLeft(updateGuideCallback) + else + subscriptions.add @editor.onDidChangeScrollLeft(updateGuideCallback) subscriptions.add @editor.onDidChangePath(updateGuideCallback) subscriptions.add @editor.onDidChangeGrammar => @@ -80,7 +85,10 @@ class WrapGuideElement extends HTMLDivElement column = @getGuideColumn(@editor.getPath(), @editor.getGrammar().scopeName) if column > 0 and @isEnabled() columnWidth = @editorElement.getDefaultCharacterWidth() * column - columnWidth -= @editorElement.getScrollLeft() + if @editorElement.logicalDisplayBuffer + columnWidth -= @editorElement.getScrollLeft() + else + columnWidth -= @editor.getScrollLeft() @style.left = "#{columnWidth}px" @style.display = 'block' else diff --git a/spec/wrap-guide-spec.coffee b/spec/wrap-guide-spec.coffee index 4eb61b8..2d07d4b 100644 --- a/spec/wrap-guide-spec.coffee +++ b/spec/wrap-guide-spec.coffee @@ -1,5 +1,7 @@ Grim = require 'grim' +# TODO: remove references to logical display buffer when it is released. + describe "WrapGuide", -> [editor, editorElement, wrapGuide, workspaceElement] = [] @@ -81,16 +83,19 @@ describe "WrapGuide", -> describe "when the editor's scroll left changes", -> it "updates the wrap guide position to a relative position on screen", -> - # FIXME: remove conditional as soon as the tiled editor is released. - return unless editorElement.hasTiledRendering - editor.setText("a long line which causes the editor to scroll") - editorElement.setWidth(100) + if editorElement.logicalDisplayBuffer + editorElement.setWidth(100) + else + editor.setWidth(100) initial = getLeftPosition(wrapGuide) expect(initial).toBeGreaterThan(0) - editorElement.setScrollLeft(10) + if editorElement.logicalDisplayBuffer + editorElement.setScrollLeft(10) + else + editor.setScrollLeft(10) expect(getLeftPosition(wrapGuide)).toBe(initial - 10) expect(wrapGuide).toBeVisible()