8000 Clip cursor width when soft-wrap is on and cursor is at the end of a line by as-cii · Pull Request #16943 · atom/atom · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content
This repository was archived by the owner on Mar 3, 2023. It is now read-only.

Clip cursor width when soft-wrap is on and cursor is at the end of a line #16943

Merged
merged 1 commit into from
Mar 20, 2018
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
11 changes: 11 additions & 0 deletions spec/text-editor-component-spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -564,9 +564,20 @@ describe('TextEditorComponent', () => {

it('gives cursors at the end of lines the width of an "x" character', async () => {
const {component, element, editor} = buildComponent()
editor.setText('abcde')
await setEditorWidthInCharacters(component, 5.5)

editor.setCursorScreenPosition([0, Infinity])
await component.getNextUpdatePromise()
expect(element.querySelector('.cursor').offsetWidth).toBe(Math.round(component.getBaseCharacterWidth()))

// Clip cursor width when soft-wrap is on and the cursor is at the end of
// the line. This prevents the parent tile from disabling sub-pixel
// anti-aliasing. For some reason, adding overflow: hidden to the cursor
// container doesn't solve this issue so we're adding this workaround instead.
editor.setSoftWrapped(true)
await component.getNextUpdatePromise()
expect(element.querySelector('.cursor').offsetWidth).toBeLessThan(Math.round(component.getBaseCharacterWidth()))
})

it('positions and sizes cursors correctly when they are located next to a fold marker', async () => {
Expand Down
2 changes: 1 addition & 1 deletion src/text-editor-component.js
Original file line number
Diff line number Diff line change
Expand Up @@ -3522,7 +3522,7 @@ class CursorsAndInputComponent {

const cursorStyle = {
height: cursorHeight,
width: pixelWidth + 'px',
width: Math.min(pixelWidth, scrollWidth - pixelLeft) + 'px',
transform: `translate(${pixelLeft}px, ${pixelTop}px)`
}
if (extraCursorStyle) Object.assign(cursorStyle, extraCursorStyle)
Expand Down
0