mirror of
https://github.com/atom/atom.git
synced 2026-02-16 01:25:13 -05:00
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:
@@ -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) ->
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user