Files
atom/src/packages/command-panel/lib/operation.coffee
Kevin Sawicki d2f2011ea3 Skip leading space after colon in nak output
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 ':'.
2013-04-02 13:50:48 -07:00

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()