mirror of
https://github.com/atom/atom.git
synced 2026-01-25 06:48:28 -05:00
Give cursors at the end of lines the width of an 'x' character
This commit is contained in:
committed by
Antonio Scandurra
parent
87eb16f5ed
commit
f83ad6bb7c
@@ -320,6 +320,13 @@ describe('TextEditorComponent', () => {
|
||||
expect(getComputedStyle(cursor2).opacity).toBe('1')
|
||||
})
|
||||
|
||||
it('gives cursors at the end of lines the width of an "x" character', async () => {
|
||||
const {component, element, editor} = buildComponent()
|
||||
editor.setCursorScreenPosition([0, Infinity])
|
||||
await component.getNextUpdatePromise()
|
||||
expect(element.querySelector('.cursor').offsetWidth).toBe(Math.round(component.getBaseCharacterWidth()))
|
||||
})
|
||||
|
||||
it('places the hidden input element at the location of the last cursor if it is visible', async () => {
|
||||
const {component, element, editor} = buildComponent({height: 60, width: 120, rowsPerTile: 2})
|
||||
const {hiddenInput} = component.refs
|
||||
|
||||
@@ -1086,10 +1086,12 @@ class TextEditorComponent {
|
||||
|
||||
const pixelTop = this.pixelPositionAfterBlocksForRow(row)
|
||||
const pixelLeft = this.pixelLeftForRowAndColumn(row, column)
|
||||
const pixelRight = (cursor.columnWidth === 0)
|
||||
? pixelLeft
|
||||
: this.pixelLeftForRowAndColumn(row, column + 1)
|
||||
const pixelWidth = pixelRight - pixelLeft
|
||||
let pixelWidth
|
||||
if (cursor.columnWidth === 0) {
|
||||
pixelWidth = this.getBaseCharacterWidth()
|
||||
} else {
|
||||
pixelWidth = this.pixelLeftForRowAndColumn(row, column + 1) - pixelLeft
|
||||
}
|
||||
|
||||
const cursorPosition = {pixelTop, pixelLeft, pixelWidth}
|
||||
this.decorationsToRender.cursors[i] = cursorPosition
|
||||
|
||||
Reference in New Issue
Block a user