This commit is contained in:
Corey Johnson & Nathan Sobo
2012-04-09 11:41:04 -07:00
parent f3372f08de
commit a21082395d
7 changed files with 25 additions and 25 deletions

View File

@@ -162,7 +162,7 @@ class Buffer
@mode = new (require("ace/mode/#{modeName}").Mode)
scanRegexMatchesInRange: (regex, range, iterator) ->
scanInRange: (regex, range, iterator) ->
range = Range.fromObject(range)
global = regex.global
regex = new RegExp(regex.source, 'gm')
@@ -207,12 +207,12 @@ class Buffer
endIndex = @characterIndexForPosition(range.end)
traverseRecursively(@getText(), startIndex, endIndex, 0)
backwardsTraverseRegexMatchesInRange: (regex, range, iterator) ->
backwardsScanInRange: (regex, range, iterator) ->
global = regex.global
regex = new RegExp(regex.source, 'gm')
matches = []
@scanRegexMatchesInRange regex, range, (match, matchRange) ->
@scanInRange regex, range, (match, matchRange) ->
matches.push([match, matchRange])
matches.reverse()

View File

@@ -12,14 +12,14 @@ class RegexAddress extends Address
rangeToSearch = new Range(currentRange.end, editor.getEofPosition())
rangeToReturn = null
editor.buffer.scanRegexMatchesInRange @regex, rangeToSearch, (match, range) ->
editor.buffer.scanInRange @regex, rangeToSearch, (match, range) ->
rangeToReturn = range
if rangeToReturn
rangeToReturn
else
rangeToSearch = new Range([0, 0], rangeToSearch.start)
editor.buffer.scanRegexMatchesInRange @regex, rangeToSearch, (match, range) ->
editor.buffer.scanInRange @regex, rangeToSearch, (match, range) ->
rangeToReturn = range
rangeToReturn or currentRange

View File

@@ -10,6 +10,6 @@ class SelectAllMatches extends Command
execute: (editor, currentRange) ->
rangesToSelect = []
editor.buffer.scanRegexMatchesInRange @regex, currentRange, (match, range) ->
editor.buffer.scanInRange @regex, currentRange, (match, range) ->
rangesToSelect.push(range)
rangesToSelect

View File

@@ -10,6 +10,6 @@ class Substitution extends Command
@regex = new RegExp(pattern, options.join(''))
execute: (editor, currentRange) ->
editor.buffer.scanRegexMatchesInRange @regex, currentRange, (match, matchRange, { replace }) =>
editor.buffer.scanInRange @regex, currentRange, (match, matchRange, { replace }) =>
replace(@replacementText)
[currentRange]

View File

@@ -86,7 +86,7 @@ class Cursor extends View
range = [bufferPosition, @editor.getEofPosition()]
nextPosition = null
@editor.scanRegexMatchesInRange @wordRegex, range, (match, matchRange, { stop }) =>
@editor.scanInRange @wordRegex, range, (match, matchRange, { stop }) =>
if matchRange.start.isGreaterThan(bufferPosition)
nextPosition = matchRange.start
stop()
@@ -104,7 +104,7 @@ class Cursor extends View
position = null
bufferPosition = @getBufferPosition()
range = [[0,0], bufferPosition]
@editor.backwardsTraverseRegexMatchesInRange @wordRegex, range, (match, matchRange, { stop }) =>
@editor.backwardsScanInRange @wordRegex, range, (match, matchRange, { stop }) =>
position = matchRange.start
if not allowPrevious and matchRange.end.isLessThan(bufferPosition)
position = bufferPosition
@@ -116,7 +116,7 @@ class Cursor extends View
position = null
bufferPosition = @getBufferPosition()
range = [bufferPosition, @editor.getEofPosition()]
@editor.scanRegexMatchesInRange @wordRegex, range, (match, matchRange, { stop }) =>
@editor.scanInRange @wordRegex, range, (match, matchRange, { stop }) =>
position = matchRange.end
if not allowNext and matchRange.start.isGreaterThan(bufferPosition)
position = bufferPosition
@@ -141,7 +141,7 @@ class Cursor extends View
position = @getBufferPosition()
range = @editor.rangeForBufferRow(position.row)
newPosition = null
@editor.scanRegexMatchesInRange /^\s*/, range, (match, matchRange) =>
@editor.scanInRange /^\s*/, range, (match, matchRange) =>
newPosition = matchRange.end
newPosition = [position.row, 0] if newPosition.isEqual(position)
@setBufferPosition(newPosition)

View File

@@ -412,8 +412,8 @@ class Editor extends View
lineForBufferRow: (row) -> @buffer.lineForRow(row)
lineLengthForBufferRow: (row) -> @buffer.lineLengthForRow(row)
rangeForBufferRow: (row) -> @buffer.rangeForRow(row)
scanRegexMatchesInRange: (args...) -> @buffer.scanRegexMatchesInRange(args...)
backwardsTraverseRegexMatchesInRange: (args...) -> @buffer.backwardsTraverseRegexMatchesInRange(args...)
scanInRange: (args...) -> @buffer.scanInRange(args...)
backwardsScanInRange: (args...) -> @buffer.backwardsScanInRange(args...)
insertText: (text) ->
@compositeSelection.insertText(text)