Skip to content
This repository was archived by the owner on Apr 6, 2018. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 13 additions & 21 deletions lib/operators/general-operators.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,8 @@ class Operator
vimState: null
motion: null
complete: null
selectOptions: null

# selectOptions - The options object to pass through to the motion when
# selecting.
constructor: (@editor, @vimState, {@selectOptions}={}) ->
constructor: (@editor, @vimState) ->
@complete = false

# Public: Determines when the command can be executed.
Expand Down Expand Up @@ -76,14 +73,9 @@ class OperatorWithInput extends Operator
#
class Delete extends Operator
register: null
allowEOL: null

# allowEOL - Determines whether the cursor should be allowed to rest on the
# end of line character or not.
constructor: (@editor, @vimState, {@allowEOL, @selectOptions}={}) ->
constructor: (@editor, @vimState) ->
@complete = false
@selectOptions ?= {}
@selectOptions.requireEOL ?= true
@register = settings.defaultRegister()

# Public: Deletes the text selected by the given motion.
Expand All @@ -92,7 +84,7 @@ class Delete extends Operator
#
# Returns nothing.
execute: (count) ->
if _.contains(@motion.select(count, @selectOptions), true)
if _.contains(@motion.select(count), true)
@setTextRegister(@register, @editor.getSelectedText())
@editor.transact =>
for selection in @editor.getSelections()
Expand All @@ -109,11 +101,11 @@ class Delete extends Operator
# It toggles the case of everything selected by the following motion
#
class ToggleCase extends Operator
constructor: (@editor, @vimState, {@complete, @selectOptions}={}) ->
constructor: (@editor, @vimState, {@complete}={}) ->

execute: (count=1) ->
if @motion?
if _.contains(@motion.select(count, @selectOptions), true)
if _.contains(@motion.select(count), true)
@editor.replaceSelectedText {}, (text) ->
text.split('').map((char) ->
lower = char.toLowerCase()
Expand Down Expand Up @@ -147,11 +139,11 @@ class ToggleCase extends Operator
# In visual mode or after `g` with a motion, it makes the selection uppercase
#
class UpperCase extends Operator
constructor: (@editor, @vimState, {@selectOptions}={}) ->
constructor: (@editor, @vimState) ->
@complete = false

execute: (count=1) ->
if _.contains(@motion.select(count, @selectOptions), true)
if _.contains(@motion.select(count), true)
@editor.replaceSelectedText {}, (text) ->
text.toUpperCase()

Expand All @@ -161,11 +153,11 @@ class UpperCase extends Operator
# In visual mode or after `g` with a motion, it makes the selection lowercase
#
class LowerCase extends Operator
constructor: (@editor, @vimState, {@selectOptions}={}) ->
constructor: (@editor, @vimState) ->
@complete = false

execute: (count=1) ->
if _.contains(@motion.select(count, @selectOptions), true)
if _.contains(@motion.select(count), true)
@editor.replaceSelectedText {}, (text) ->
text.toLowerCase()

Expand All @@ -177,7 +169,7 @@ class LowerCase extends Operator
class Yank extends Operator
register: null

constructor: (@editor, @vimState, {@allowEOL, @selectOptions}={}) ->
constructor: (@editor, @vimState) ->
@register = settings.defaultRegister()

# Public: Copies the text selected by the given motion.
Expand Down Expand Up @@ -208,7 +200,7 @@ class Yank extends Operator
# It combines the current line with the following line.
#
class Join extends Operator
constructor: (@editor, @vimState, {@selectOptions}={}) -> @complete = true
constructor: (@editor, @vimState) -> @complete = true

# Public: Combines the current with the following lines
#
Expand All @@ -225,7 +217,7 @@ class Join extends Operator
# Repeat the last operation
#
class Repeat extends Operator
constructor: (@editor, @vimState, {@selectOptions}={}) -> @complete = true
constructor: (@editor, @vimState) -> @complete = true

isRecordable: -> false

Expand All @@ -238,7 +230,7 @@ class Repeat extends Operator
# It creates a mark at the current cursor position
#
class Mark extends OperatorWithInput
constructor: (@editor, @vimState, {@selectOptions}={}) ->
constructor: (@editor, @vimState) ->
super(@editor, @vimState)
@viewModel = new ViewModel(this, class: 'mark', singleChar: true, hidden: true)

Expand Down
6 changes: 3 additions & 3 deletions lib/operators/input.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ class Change extends Insert
standalone: false
register: null

constructor: (@editor, @vimState, {@selectOptions}={}) ->
constructor: (@editor, @vimState) ->
@register = settings.defaultRegister()

# Public: Changes the text selected by the given motion.
Expand Down Expand Up @@ -111,7 +111,7 @@ class Change extends Insert
class Substitute extends Insert
register: null

constructor: (@editor, @vimState, {@selectOptions}={}) ->
constructor: (@editor, @vimState) ->
@register = settings.defaultRegister()

execute: (count=1) ->
Expand All @@ -131,7 +131,7 @@ class Substitute extends Insert
class SubstituteLine extends Insert
register: null

constructor: (@editor, @vimState, {@selectOptions}={}) ->
constructor: (@editor, @vimState) ->
@register = settings.defaultRegister()

execute: (count=1) ->
Expand Down
2 changes: 1 addition & 1 deletion lib/operators/put-operator.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ module.exports =
class Put extends Operator
register: null

constructor: (@editor, @vimState, {@location, @selectOptions}={}) ->
constructor: (@editor, @vimState, {@location}={}) ->
@location ?= 'after'
@complete = true
@register = settings.defaultRegister()
Expand Down
2 changes: 1 addition & 1 deletion lib/operators/replace-operator.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ _ = require 'underscore-plus'

module.exports =
class Replace extends OperatorWithInput
constructor: (@editor, @vimState, {@selectOptions}={}) ->
constructor: (@editor, @vimState) ->
super(@editor, @vimState)
@viewModel = new ViewModel(this, class: 'replace', hidden: true, singleChar: true, defaultText: '\n')

Expand Down