Skip to content
This repository was archived by the owner on Dec 15, 2022. It is now read-only.

Commit 4453fc9

Browse files
committed
Pass hasAstral() through to the native buffer
1 parent dc8b3ee commit 4453fc9

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

spec/text-buffer-spec.coffee

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2609,6 +2609,13 @@ describe "TextBuffer", ->
26092609
buffer.setText('\n')
26102610
expect(buffer.isEmpty()).toBeFalsy()
26112611

2612+
describe "::hasAstral()", ->
2613+
it "returns true for buffers containing surrogate pairs", ->
2614+
expect(new TextBuffer('hooray 😄').hasAstral()).toBeTruthy()
2615+
2616+
it "returns false for buffers that do not contain surrogate pairs", ->
2617+
expect(new TextBuffer('nope').hasAstral()).toBeFalsy()
2618+
26122619
describe "::onWillChange(callback)", ->
26132620
it "notifies observers before a transaction, an undo or a redo", ->
26142621
changeCount = 0

src/text-buffer.coffee

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -728,6 +728,12 @@ class TextBuffer
728728
return row unless @isRowBlank(row)
729729
null
730730

731+
# Extended: Return true if the buffer contains any astral-plane Unicode characters that
732+
# are encoded as surrogate pairs.
733+
#
734+
# Returns a {Boolean}.
735+
hasAstral: -> @buffer.hasAstral()
736+
731737
###
732738
Section: Mutating Text
733739
###

0 commit comments

Comments
 (0)