mirror of
https://github.com/pulsar-edit/pulsar.git
synced 2025-01-03 20:33:33 +03:00
Fix bug when positioning cursors after the fold-marker
This commit is contained in:
parent
ce4b2fa810
commit
57442781ec
@ -54,7 +54,7 @@
|
||||
"service-hub": "^0.7.0",
|
||||
"source-map-support": "^0.3.2",
|
||||
"temp": "0.8.1",
|
||||
"text-buffer": "9.0.0-beta5",
|
||||
"text-buffer": "9.0.0-beta6",
|
||||
"typescript-simple": "1.0.0",
|
||||
"underscore-plus": "^1.6.6",
|
||||
"yargs": "^3.23.0"
|
||||
|
@ -1249,6 +1249,17 @@ describe('TextEditorComponent', function () {
|
||||
expect(cursorRect.width).toBeCloseTo(rangeRect.width, 0)
|
||||
})
|
||||
|
||||
it('positions cursors after the fold-marker when a fold ends the line', async function () {
|
||||
editor.foldBufferRow(0)
|
||||
await nextViewUpdatePromise()
|
||||
editor.setCursorScreenPosition([0, 30])
|
||||
await nextViewUpdatePromise()
|
||||
|
||||
let cursorRect = componentNode.querySelector('.cursor').getBoundingClientRect()
|
||||
let foldMarkerRect = componentNode.querySelector('.fold-marker').getBoundingClientRect()
|
||||
expect(cursorRect.left).toBeCloseTo(foldMarkerRect.right, 0)
|
||||
})
|
||||
|
||||
it('positions cursors correctly after character widths are changed via a stylesheet change', async function () {
|
||||
atom.config.set('editor.fontFamily', 'sans-serif')
|
||||
editor.setCursorScreenPosition([0, 16])
|
||||
|
@ -4,6 +4,7 @@ HighlightsComponent = require './highlights-component'
|
||||
AcceptFilter = {acceptNode: -> NodeFilter.FILTER_ACCEPT}
|
||||
TokenTextEscapeRegex = /[&"'<>]/g
|
||||
MaxTokenLength = 20000
|
||||
ZERO_WIDTH_NBSP = '\ufeff'
|
||||
|
||||
cloneObject = (object) ->
|
||||
clone = {}
|
||||
@ -225,6 +226,15 @@ class LinesTileComponent
|
||||
lineNode.appendChild(textNode)
|
||||
textNodes.push(textNode)
|
||||
|
||||
if lineText.endsWith(@presenter.displayLayer.foldCharacter)
|
||||
# Insert a zero-width non-breaking whitespace, so that
|
||||
# LinesYardstick can take the fold-marker::after pseudo-element
|
||||
# into account during measurements when such marker is the last
|
||||
# character on the line.
|
||||
textNode = @domElementPool.buildText(ZERO_WIDTH_NBSP)
|
||||
lineNode.appendChild(textNode)
|
||||
textNodes.push(textNode)
|
||||
|
||||
@textNodesByLineId[id] = textNodes
|
||||
lineNode
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user