mirror of
https://github.com/atom/atom.git
synced 2026-04-06 03:02:13 -04:00
💄
This commit is contained in:
@@ -225,12 +225,12 @@ describe 'Buffer', ->
|
||||
range = [[2,10], [4,10]]
|
||||
expect(buffer.getTextInRange(range)).toBe "ems.length <= 1) return items;\n var pivot = items.shift(), current, left = [], right = [];\n while("
|
||||
|
||||
describe ".traverseRegexMatchesInRange(range, regex, fn)", ->
|
||||
describe ".scanRegexMatchesInRange(range, regex, fn)", ->
|
||||
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 = []
|
||||
ranges = []
|
||||
buffer.traverseRegexMatchesInRange /cu(rr)ent/, [[4,0], [6,44]], (match, range) ->
|
||||
buffer.scanRegexMatchesInRange /cu(rr)ent/, [[4,0], [6,44]], (match, range) ->
|
||||
matches.push(match)
|
||||
ranges.push(range)
|
||||
|
||||
@@ -245,7 +245,7 @@ describe 'Buffer', ->
|
||||
it "calls the iterator with each match for the given regex in the given range", ->
|
||||
matches = []
|
||||
ranges = []
|
||||
buffer.traverseRegexMatchesInRange /cu(rr)ent/g, [[4,0], [6,59]], (match, range) ->
|
||||
buffer.scanRegexMatchesInRange /cu(rr)ent/g, [[4,0], [6,59]], (match, range) ->
|
||||
matches.push(match)
|
||||
ranges.push(range)
|
||||
|
||||
@@ -269,7 +269,7 @@ describe 'Buffer', ->
|
||||
it "calls the iterator with the truncated match", ->
|
||||
matches = []
|
||||
ranges = []
|
||||
buffer.traverseRegexMatchesInRange /cu(r*)/g, [[4,0], [6,9]], (match, range) ->
|
||||
buffer.scanRegexMatchesInRange /cu(r*)/g, [[4,0], [6,9]], (match, range) ->
|
||||
matches.push(match)
|
||||
ranges.push(range)
|
||||
|
||||
@@ -288,7 +288,7 @@ describe 'Buffer', ->
|
||||
it "calls the iterator with the truncated match", ->
|
||||
matches = []
|
||||
ranges = []
|
||||
buffer.traverseRegexMatchesInRange /cu(r*)e/g, [[4,0], [6,9]], (match, range) ->
|
||||
buffer.scanRegexMatchesInRange /cu(r*)e/g, [[4,0], [6,9]], (match, range) ->
|
||||
matches.push(match)
|
||||
ranges.push(range)
|
||||
|
||||
@@ -302,7 +302,7 @@ describe 'Buffer', ->
|
||||
describe "when the iterator calls the 'replace' control function with a replacement string", ->
|
||||
it "replaces each occurrence of the regex match with the string", ->
|
||||
ranges = []
|
||||
buffer.traverseRegexMatchesInRange /cu(rr)ent/g, [[4,0], [6,59]], (match, range, { replace }) ->
|
||||
buffer.scanRegexMatchesInRange /cu(rr)ent/g, [[4,0], [6,59]], (match, range, { replace }) ->
|
||||
ranges.push(range)
|
||||
replace("foo")
|
||||
|
||||
@@ -316,7 +316,7 @@ describe 'Buffer', ->
|
||||
describe "when the iterator calls the 'stop' control function", ->
|
||||
it "stops the traversal", ->
|
||||
ranges = []
|
||||
buffer.traverseRegexMatchesInRange /cu(rr)ent/g, [[4,0], [6,59]], (match, range, { stop }) ->
|
||||
buffer.scanRegexMatchesInRange /cu(rr)ent/g, [[4,0], [6,59]], (match, range, { stop }) ->
|
||||
ranges.push(range)
|
||||
stop() if ranges.length == 2
|
||||
|
||||
|
||||
@@ -155,7 +155,7 @@ class Buffer
|
||||
|
||||
@mode = new (require("ace/mode/#{modeName}").Mode)
|
||||
|
||||
traverseRegexMatchesInRange: (regex, range, iterator) ->
|
||||
scanRegexMatchesInRange: (regex, range, iterator) ->
|
||||
range = Range.fromObject(range)
|
||||
global = regex.global
|
||||
regex = new RegExp(regex.source, 'gm')
|
||||
@@ -205,7 +205,7 @@ class Buffer
|
||||
regex = new RegExp(regex.source, 'gm')
|
||||
|
||||
matches = []
|
||||
@traverseRegexMatchesInRange regex, range, (match, matchRange) ->
|
||||
@scanRegexMatchesInRange regex, range, (match, matchRange) ->
|
||||
matches.push([match, matchRange])
|
||||
|
||||
matches.reverse()
|
||||
|
||||
@@ -13,14 +13,14 @@ class RegexAddress extends Address
|
||||
rangeToSearch = new Range(selectedRange.end, editor.getEofPosition())
|
||||
|
||||
rangeToReturn = null
|
||||
editor.buffer.traverseRegexMatchesInRange @regex, rangeToSearch, (match, range) ->
|
||||
editor.buffer.scanRegexMatchesInRange @regex, rangeToSearch, (match, range) ->
|
||||
rangeToReturn = range
|
||||
|
||||
if rangeToReturn
|
||||
rangeToReturn
|
||||
else
|
||||
rangeToSearch = new Range([0, 0], rangeToSearch.start)
|
||||
editor.buffer.traverseRegexMatchesInRange @regex, rangeToSearch, (match, range) ->
|
||||
editor.buffer.scanRegexMatchesInRange @regex, rangeToSearch, (match, range) ->
|
||||
rangeToReturn = range
|
||||
|
||||
rangeToReturn or selectedRange
|
||||
|
||||
@@ -11,7 +11,7 @@ class SelectAllMatches extends Command
|
||||
execute: (editor) ->
|
||||
rangesToSelect = []
|
||||
for selection in editor.getSelections()
|
||||
editor.buffer.traverseRegexMatchesInRange @regex, selection.getBufferRange(), (match, range) ->
|
||||
editor.buffer.scanRegexMatchesInRange @regex, selection.getBufferRange(), (match, range) ->
|
||||
rangesToSelect.push(range)
|
||||
|
||||
editor.clearSelections()
|
||||
|
||||
@@ -11,6 +11,6 @@ class Substitution extends Command
|
||||
|
||||
execute: (editor) ->
|
||||
range = editor.getSelection().getBufferRange()
|
||||
editor.buffer.traverseRegexMatchesInRange @regex, range, (match, matchRange, { replace }) =>
|
||||
editor.buffer.scanRegexMatchesInRange @regex, range, (match, matchRange, { replace }) =>
|
||||
replace(@replacementText)
|
||||
|
||||
|
||||
@@ -77,7 +77,7 @@ class Cursor extends View
|
||||
range = [bufferPosition, @editor.getEofPosition()]
|
||||
|
||||
nextPosition = null
|
||||
@editor.traverseRegexMatchesInRange @wordRegex, range, (match, matchRange, { stop }) =>
|
||||
@editor.scanRegexMatchesInRange @wordRegex, range, (match, matchRange, { stop }) =>
|
||||
if matchRange.start.isGreaterThan(bufferPosition)
|
||||
nextPosition = matchRange.start
|
||||
stop()
|
||||
@@ -95,7 +95,7 @@ class Cursor extends View
|
||||
bufferPosition = @getBufferPosition()
|
||||
range = [bufferPosition, @editor.getEofPosition()]
|
||||
|
||||
@editor.traverseRegexMatchesInRange @wordRegex, range, (match, matchRange, { stop }) =>
|
||||
@editor.scanRegexMatchesInRange @wordRegex, range, (match, matchRange, { stop }) =>
|
||||
@setBufferPosition matchRange.end
|
||||
stop()
|
||||
|
||||
@@ -111,7 +111,7 @@ class Cursor extends View
|
||||
position = @getBufferPosition()
|
||||
range = @editor.rangeForBufferRow(position.row)
|
||||
newPosition = null
|
||||
@editor.traverseRegexMatchesInRange /^\s*/, range, (match, matchRange) =>
|
||||
@editor.scanRegexMatchesInRange /^\s*/, range, (match, matchRange) =>
|
||||
newPosition = matchRange.end
|
||||
newPosition = [position.row, 0] if newPosition.isEqual(position)
|
||||
@setBufferPosition(newPosition)
|
||||
|
||||
@@ -394,7 +394,7 @@ class Editor extends View
|
||||
lineForBufferRow: (row) -> @buffer.lineForRow(row)
|
||||
lineLengthForBufferRow: (row) -> @buffer.lineLengthForRow(row)
|
||||
rangeForBufferRow: (row) -> @buffer.rangeForRow(row)
|
||||
traverseRegexMatchesInRange: (args...) -> @buffer.traverseRegexMatchesInRange(args...)
|
||||
scanRegexMatchesInRange: (args...) -> @buffer.scanRegexMatchesInRange(args...)
|
||||
backwardsTraverseRegexMatchesInRange: (args...) -> @buffer.backwardsTraverseRegexMatchesInRange(args...)
|
||||
|
||||
insertText: (text) ->
|
||||
|
||||
Reference in New Issue
Block a user