Skip to content
This repository has been archived by the owner on Dec 15, 2022. It is now read-only.

Fix deprecations #44

Merged
merged 2 commits into from
Sep 30, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 9 additions & 4 deletions lib/wrap-guide-element.coffee
Original file line number Diff line number Diff line change
@@ -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')
Expand All @@ -23,8 +25,9 @@ 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
if @editorElement.logicalDisplayBuffer
subscriptions.add @editorElement.onDidChangeScrollLeft(updateGuideCallback)
else
subscriptions.add @editor.onDidChangeScrollLeft(updateGuideCallback)

subscriptions.add @editor.onDidChangePath(updateGuideCallback)
Expand Down Expand Up @@ -82,8 +85,10 @@ 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
if @editorElement.logicalDisplayBuffer
columnWidth -= @editorElement.getScrollLeft()
else
columnWidth -= @editor.getScrollLeft()
@style.left = "#{columnWidth}px"
@style.display = 'block'
else
Expand Down
15 changes: 10 additions & 5 deletions spec/wrap-guide-spec.coffee
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
Grim = require 'grim'

# TODO: remove references to logical display buffer when it is released.

describe "WrapGuide", ->
[editor, editorElement, wrapGuide, workspaceElement] = []

Expand Down Expand Up @@ -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")
editor.setWidth(100)
if editorElement.logicalDisplayBuffer
editorElement.setWidth(100)
else
editor.setWidth(100)

initial = getLeftPosition(wrapGuide)
expect(initial).toBeGreaterThan(0)

editor.setScrollLeft(10)
if editorElement.logicalDisplayBuffer
editorElement.setScrollLeft(10)
else
editor.setScrollLeft(10)

expect(getLeftPosition(wrapGuide)).toBe(initial - 10)
expect(wrapGuide).toBeVisible()
Expand Down