mirror of
https://github.com/pulsar-edit/pulsar.git
synced 2024-11-10 10:17:11 +03:00
Don’t tokenize spaces preceding combining chars as leading whitespace
Fixes #5349
This commit is contained in:
parent
5fdb3cde08
commit
0bf0c0527f
@ -318,6 +318,18 @@ describe "TokenizedBuffer", ->
|
|||||||
expect(tokenizedBuffer.tokenizedLineForRow(5).tokens[1].isAtomic).toBeFalsy()
|
expect(tokenizedBuffer.tokenizedLineForRow(5).tokens[1].isAtomic).toBeFalsy()
|
||||||
expect(tokenizedBuffer.tokenizedLineForRow(5).tokens[1].value).toBe " current "
|
expect(tokenizedBuffer.tokenizedLineForRow(5).tokens[1].value).toBe " current "
|
||||||
|
|
||||||
|
it "does not tokenize whitespaces followed by combining characters as leading whitespace", ->
|
||||||
|
buffer.setText(" \u030b")
|
||||||
|
fullyTokenize(tokenizedBuffer)
|
||||||
|
|
||||||
|
{tokens} = tokenizedBuffer.tokenizedLineForRow(0)
|
||||||
|
expect(tokens[0].value).toBe " "
|
||||||
|
expect(tokens[0].hasLeadingWhitespace()).toBe true
|
||||||
|
expect(tokens[1].value).toBe " "
|
||||||
|
expect(tokens[1].hasLeadingWhitespace()).toBe true
|
||||||
|
expect(tokens[2].value).toBe " \u030b"
|
||||||
|
expect(tokens[2].hasLeadingWhitespace()).toBe false
|
||||||
|
|
||||||
describe "when the buffer contains hard-tabs", ->
|
describe "when the buffer contains hard-tabs", ->
|
||||||
beforeEach ->
|
beforeEach ->
|
||||||
waitsForPromise ->
|
waitsForPromise ->
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
_ = require 'underscore-plus'
|
_ = require 'underscore-plus'
|
||||||
|
{isPairedCharacter} = require './text-utils'
|
||||||
|
|
||||||
NonWhitespaceRegex = /\S/
|
NonWhitespaceRegex = /\S/
|
||||||
LeadingWhitespaceRegex = /^\s*/
|
LeadingWhitespaceRegex = /^\s*/
|
||||||
@ -147,6 +148,8 @@ class TokenizedLine
|
|||||||
|
|
||||||
markLeadingAndTrailingWhitespaceTokens: ->
|
markLeadingAndTrailingWhitespaceTokens: ->
|
||||||
firstNonWhitespaceIndex = @text.search(NonWhitespaceRegex)
|
firstNonWhitespaceIndex = @text.search(NonWhitespaceRegex)
|
||||||
|
if firstNonWhitespaceIndex > 0 and isPairedCharacter(@text, firstNonWhitespaceIndex - 1)
|
||||||
|
firstNonWhitespaceIndex--
|
||||||
firstTrailingWhitespaceIndex = @text.search(TrailingWhitespaceRegex)
|
firstTrailingWhitespaceIndex = @text.search(TrailingWhitespaceRegex)
|
||||||
@lineIsWhitespaceOnly = firstTrailingWhitespaceIndex is 0
|
@lineIsWhitespaceOnly = firstTrailingWhitespaceIndex is 0
|
||||||
index = 0
|
index = 0
|
||||||
|
Loading…
Reference in New Issue
Block a user