mirror of
https://github.com/pulsar-edit/pulsar.git
synced 2024-11-10 10:17:11 +03:00
Merge pull request #2950 from lee-dohm/ld-bug-2274
🐛 Fix regression in indent-guide in React editor
This commit is contained in:
commit
b744997201
@ -344,11 +344,29 @@ describe "EditorComponent", ->
|
|||||||
expect(line13LeafNodes[1].textContent).toBe ' '
|
expect(line13LeafNodes[1].textContent).toBe ' '
|
||||||
expect(line13LeafNodes[1].classList.contains('indent-guide')).toBe true
|
expect(line13LeafNodes[1].classList.contains('indent-guide')).toBe true
|
||||||
|
|
||||||
getLeafNodes = (node) ->
|
describe "when indent guides are disabled", ->
|
||||||
if node.children.length > 0
|
beforeEach ->
|
||||||
flatten(toArray(node.children).map(getLeafNodes))
|
component.setShowIndentGuide(false)
|
||||||
else
|
runSetImmediateCallbacks()
|
||||||
[node]
|
|
||||||
|
it "does not render indent guides on lines containing only whitespace", ->
|
||||||
|
editor.getBuffer().insert([1, Infinity], '\n ')
|
||||||
|
runSetImmediateCallbacks()
|
||||||
|
|
||||||
|
line2LeafNodes = getLeafNodes(component.lineNodeForScreenRow(2))
|
||||||
|
expect(line2LeafNodes.length).toBe 3
|
||||||
|
expect(line2LeafNodes[0].textContent).toBe ' '
|
||||||
|
expect(line2LeafNodes[0].classList.contains('indent-guide')).toBe false
|
||||||
|
expect(line2LeafNodes[1].textContent).toBe ' '
|
||||||
|
expect(line2LeafNodes[1].classList.contains('indent-guide')).toBe false
|
||||||
|
expect(line2LeafNodes[2].textContent).toBe ' '
|
||||||
|
expect(line2LeafNodes[2].classList.contains('indent-guide')).toBe false
|
||||||
|
|
||||||
|
getLeafNodes = (node) ->
|
||||||
|
if node.children.length > 0
|
||||||
|
flatten(toArray(node.children).map(getLeafNodes))
|
||||||
|
else
|
||||||
|
[node]
|
||||||
|
|
||||||
describe "when the buffer contains null bytes", ->
|
describe "when the buffer contains null bytes", ->
|
||||||
it "excludes the null byte from character measurement", ->
|
it "excludes the null byte from character measurement", ->
|
||||||
|
@ -189,7 +189,7 @@ LinesComponent = React.createClass
|
|||||||
lineIsWhitespaceOnly = firstTrailingWhitespacePosition is 0
|
lineIsWhitespaceOnly = firstTrailingWhitespacePosition is 0
|
||||||
for token in tokens
|
for token in tokens
|
||||||
innerHTML += @updateScopeStack(scopeStack, token.scopes)
|
innerHTML += @updateScopeStack(scopeStack, token.scopes)
|
||||||
hasIndentGuide = not mini and showIndentGuide and token.hasLeadingWhitespace or (token.hasTrailingWhitespace and lineIsWhitespaceOnly)
|
hasIndentGuide = not mini and showIndentGuide and (token.hasLeadingWhitespace or (token.hasTrailingWhitespace and lineIsWhitespaceOnly))
|
||||||
innerHTML += token.getValueAsHtml({invisibles, hasIndentGuide})
|
innerHTML += token.getValueAsHtml({invisibles, hasIndentGuide})
|
||||||
|
|
||||||
innerHTML += @popScope(scopeStack) while scopeStack.length > 0
|
innerHTML += @popScope(scopeStack) while scopeStack.length > 0
|
||||||
|
Loading…
Reference in New Issue
Block a user