mirror of
https://github.com/pulsar-edit/pulsar.git
synced 2025-01-08 16:19:17 +03:00
Buffer.scanInRange can do a case-insensitive search
This commit is contained in:
parent
00f7796e93
commit
533ad84d03
@ -418,6 +418,13 @@ describe 'Buffer', ->
|
||||
expect(buffer.getTextInRange(range)).toBe "ems.length <= 1) return items;\n var pivot = items.shift(), current, left = [], right = [];\n while("
|
||||
|
||||
describe ".scanInRange(range, regex, fn)", ->
|
||||
describe "when given a regex with a ignore case flag", ->
|
||||
it "does a case-insensitive search", ->
|
||||
matches = []
|
||||
buffer.scanInRange /cuRRent/i, [[0,0], [12,0]], (match, range) ->
|
||||
matches.push(match)
|
||||
expect(matches.length).toBe 1
|
||||
|
||||
describe "when given a regex with no global flag", ->
|
||||
it "calls the iterator with the first match for the given regex in the given range", ->
|
||||
matches = []
|
||||
|
@ -297,7 +297,9 @@ class Buffer
|
||||
scanInRange: (regex, range, iterator, reverse=false) ->
|
||||
range = Range.fromObject(range)
|
||||
global = regex.global
|
||||
regex = new RegExp(regex.source, 'gm')
|
||||
flags = "gm"
|
||||
flags += "i" if regex.ignoreCase
|
||||
regex = new RegExp(regex.source, flags)
|
||||
|
||||
startIndex = @characterIndexForPosition(range.start)
|
||||
endIndex = @characterIndexForPosition(range.end)
|
||||
|
Loading…
Reference in New Issue
Block a user