mirror of
https://github.com/atom/atom.git
synced 2026-04-06 03:02:13 -04:00
When the cursor is positioned before a character, we always make it the width of that character. But at the end of a line, there is no character to use to set the width, so we just use the defaultCharWidth. This makes the block cursor visible on empty lines in vim-mode.
17 lines
547 B
CoffeeScript
17 lines
547 B
CoffeeScript
React = require 'react-atom-fork'
|
|
{div} = require 'reactionary-atom-fork'
|
|
|
|
module.exports =
|
|
CursorComponent = React.createClass
|
|
displayName: 'CursorComponent'
|
|
|
|
render: ->
|
|
{editor, screenRange, scrollTop, scrollLeft, defaultCharWidth} = @props
|
|
{top, left, height, width} = editor.pixelRectForScreenRange(screenRange)
|
|
top -= scrollTop
|
|
left -= scrollLeft
|
|
width = defaultCharWidth if width is 0
|
|
WebkitTransform = "translate3d(#{left}px, #{top}px, 0px)"
|
|
|
|
div className: 'cursor', style: {height, width, WebkitTransform}
|