Always pull line text from buffer

This accounts for positional changes that may occur if the marker
the operation is tracking moves.
This commit is contained in:
Kevin Sawicki
2013-04-02 14:17:47 -07:00
parent 7b0ce258d1
commit 699212a13e
4 changed files with 7 additions and 9 deletions

View File

@@ -178,7 +178,7 @@ class Project
for [column, length] in matchPositions
range = new Range([row, column], [row, column + length])
match = lineText.substr(column, length)
iterator({path, range, match, lineText})
iterator({path, range, match})
deferred = $.Deferred()
exit = (code) ->

View File

@@ -13,12 +13,11 @@ class SelectAllMatchesInProject extends Command
compile: (project, buffer, range) ->
deferred = $.Deferred()
operations = []
promise = project.scan @regex, ({path, range, match, lineText}) ->
promise = project.scan @regex, ({path, range}) ->
operations.push(new Operation(
project: project
path: path
bufferRange: range
lineText: lineText
))
promise.done -> deferred.resolve(operations)

View File

@@ -1,6 +1,6 @@
module.exports =
class Operation
constructor: ({@project, @path, @buffer, @bufferRange, @lineText, @newText, @preserveSelection, @errorMessage}) ->
constructor: ({@project, @path, @buffer, @bufferRange, @newText, @preserveSelection, @errorMessage}) ->
if @buffer?
@buffer.retain()
@getMarker()
@@ -24,9 +24,10 @@ class Operation
preview: ->
range = @getBufferRange()
prefix = @lineText[0...range.start.column]
match = @lineText[range.start.column...range.end.column]
suffix = @lineText[range.end.column..]
line = @getBuffer().lineForRow(range.start.row)
prefix = line[0...range.start.column]
match = line[range.start.column...range.end.column]
suffix = line[range.end.column..]
{prefix, suffix, match, range}