mirror of
https://github.com/atom/atom.git
synced 2026-01-25 06:48:28 -05:00
When soft wrap is on, don't position hidden input beyond width of horizontal scroller.
This commit is contained in:
@@ -174,6 +174,15 @@ describe "Editor", ->
|
||||
it "moves the hidden input element to the position of the cursor to prevent scrolling misbehavior", ->
|
||||
expect(editor.hiddenInput.position()).toEqual(top: 2 * editor.lineHeight, left: 2 * editor.charWidth)
|
||||
|
||||
describe "if soft-wrap is enabled", ->
|
||||
beforeEach ->
|
||||
setEditorWidthInChars(editor, 20)
|
||||
editor.setSoftWrap(true)
|
||||
|
||||
it "doesn't move the hidden input beyond the right side of the horizontal scroller to prevent chrome from auto-scrolling", ->
|
||||
editor.setCursorScreenPosition([4, 20])
|
||||
expect(editor.hiddenInput.position()).toEqual(top: 4 * editor.lineHeight, left: editor.horizontalScroller.width() - editor.charWidth)
|
||||
|
||||
describe "when the arrow keys are pressed", ->
|
||||
it "moves the cursor by a single row/column", ->
|
||||
editor.trigger keydownEvent('right')
|
||||
@@ -569,7 +578,6 @@ describe "Editor", ->
|
||||
expect(editor.buffer.lineForRow(5)).toEqual(" }")
|
||||
expect(editor.getCursorBufferPosition().column).toBe 5
|
||||
|
||||
|
||||
describe "selection", ->
|
||||
selection = null
|
||||
|
||||
|
||||
@@ -120,7 +120,10 @@ class Editor extends View
|
||||
@insertText(e.originalEvent.data)
|
||||
|
||||
@on 'cursor:position-changed', =>
|
||||
@hiddenInput.css(@pixelPositionForScreenPosition(@cursor.getScreenPosition()))
|
||||
position = @pixelPositionForScreenPosition(@cursor.getScreenPosition())
|
||||
if @softWrap
|
||||
position.left = Math.min(position.left, @horizontalScroller.width() - @charWidth)
|
||||
@hiddenInput.css(position)
|
||||
|
||||
@one 'attach', =>
|
||||
@calculateDimensions()
|
||||
|
||||
Reference in New Issue
Block a user