diff --git a/spec/text-editor-presenter-spec.coffee b/spec/text-editor-presenter-spec.coffee index a63579c56..2fd213cd2 100644 --- a/spec/text-editor-presenter-spec.coffee +++ b/spec/text-editor-presenter-spec.coffee @@ -514,3 +514,8 @@ describe "TextEditorPresenter", -> destroyedCursor = editor.getCursors()[2] destroyedCursor.destroy() expect(presenter.state.content.cursors[destroyedCursor.id]).toBeUndefined() + + it "makes cursors as wide as the ::baseCharacterWidth if they're at the end of a line", -> + editor.setCursorBufferPosition([1, Infinity]) + presenter = new TextEditorPresenter(model: editor, clientHeight: 20, scrollTop: 0, lineHeight: 10, lineOverdrawMargin: 0, baseCharacterWidth: 10) + expect(stateForCursor(presenter, 0).width).toBe 10 diff --git a/src/cursor-component.coffee b/src/cursor-component.coffee index f69c89b3b..69237f016 100644 --- a/src/cursor-component.coffee +++ b/src/cursor-component.coffee @@ -7,9 +7,8 @@ CursorComponent = React.createClass displayName: 'CursorComponent' render: -> - {pixelRect, defaultCharWidth} = @props + {pixelRect} = @props {top, left, height, width} = pixelRect - width = defaultCharWidth if width is 0 WebkitTransform = "translate(#{left}px, #{top}px)" div className: 'cursor', style: {height, width, WebkitTransform} diff --git a/src/cursors-component.coffee b/src/cursors-component.coffee index 57d32b616..f5dada022 100644 --- a/src/cursors-component.coffee +++ b/src/cursors-component.coffee @@ -21,7 +21,7 @@ CursorsComponent = React.createClass div {className}, if presenter? for key, pixelRect of presenter.state.content.cursors - CursorComponent({key, pixelRect, defaultCharWidth}) + CursorComponent({key, pixelRect}) getInitialState: -> blinkOff: false diff --git a/src/lines-component.coffee b/src/lines-component.coffee index 341aeab30..eefd950ca 100644 --- a/src/lines-component.coffee +++ b/src/lines-component.coffee @@ -36,9 +36,7 @@ LinesComponent = React.createClass div {className: 'lines', style}, div className: 'placeholder-text', placeholderText if placeholderText? - CursorsComponent { - presenter, cursorBlinkPeriod, cursorBlinkResumeDelay, defaultCharWidth - } + CursorsComponent {presenter, cursorBlinkPeriod, cursorBlinkResumeDelay} HighlightsComponent { editor, highlightDecorations, lineHeightInPixels, defaultCharWidth, diff --git a/src/text-editor-presenter.coffee b/src/text-editor-presenter.coffee index 78f8a0b3a..e4a680b26 100644 --- a/src/text-editor-presenter.coffee +++ b/src/text-editor-presenter.coffee @@ -99,7 +99,9 @@ class TextEditorPresenter for cursor in @model.getCursors() if cursor.isVisible() and startRow <= cursor.getScreenRow() < endRow - @state.content.cursors[cursor.id] = @pixelRectForScreenRange(cursor.getScreenRange()) + pixelRect = @pixelRectForScreenRange(cursor.getScreenRange()) + pixelRect.width = @getBaseCharacterWidth() if pixelRect.width is 0 + @state.content.cursors[cursor.id] = pixelRect visibleCursors[cursor.id] = true for id of @state.content.cursors