mirror of
https://github.com/atom/atom.git
synced 2026-04-06 03:02:13 -04:00
This was causing a spec to fail since the line text now had a leading space for all results since the separator before the line text is now ': ' instead of just ':'.
36 lines
958 B
CoffeeScript
36 lines
958 B
CoffeeScript
module.exports =
|
|
class Operation
|
|
constructor: ({@project, @path, @buffer, @bufferRange, @lineText, @newText, @preserveSelection, @errorMessage}) ->
|
|
if @buffer?
|
|
@buffer.retain()
|
|
@getMarker()
|
|
|
|
getMarker: ->
|
|
@marker ?= @getBuffer().markRange(@bufferRange)
|
|
|
|
getBuffer: ->
|
|
@buffer ?= @project.bufferForPath(@path).retain()
|
|
|
|
getPath: ->
|
|
path = @path ? @getBuffer().getPath()
|
|
@project.relativize(path)
|
|
|
|
getBufferRange: ->
|
|
@getBuffer().getMarkerRange(@getMarker())
|
|
|
|
execute: (editSession) ->
|
|
@getBuffer().change(@getBufferRange(), @newText) if @newText
|
|
@getBufferRange() unless @preserveSelection
|
|
|
|
preview: ->
|
|
range = @bufferRange
|
|
prefix = @lineText[0...range.start.column]
|
|
match = @lineText[range.start.column...range.end.column]
|
|
suffix = @lineText[range.end.column..]
|
|
|
|
{prefix, suffix, match, range}
|
|
|
|
destroy: ->
|
|
@buffer?.destroyMarker(@marker) if @marker?
|
|
@buffer?.release()
|