+ # Private: insert the contents of the register in the editor
+ #
+ # name - the name of the register to insert
+ #
+ # Returns nothing.
+ insertRegister: (name) ->
+ text = @getRegister(name)?.text
+ @editor.insertText(text) if text?
+
+ # Private: ensure the mode follows the state of selections
+ checkSelections: =>
+ return unless @editor?
+ if @editor.getSelections().every((selection) -> selection.isEmpty())
+ @ensureCursorsWithinLine() if @mode is 'normal'
+ @activateNormalMode() if @mode is 'visual'
+ else
+ @activateVisualMode('characterwise') if @mode is 'normal'
+
+ # Private: ensure the cursor stays within the line as appropriate
+ ensureCursorsWithinLine: =>
+ for cursor in @editor.getCursors()
+ {goalColumn} = cursor
+ if cursor.isAtEndOfLine() and not cursor.isAtBeginningOfLine()
+ cursor.moveLeft()
+ cursor.goalColumn = goalColumn
+
+ @editor.mergeCursors()
+