]> git.r.bdr.sh - rbdr/dotfiles/blame - atom/packages/vim-mode/lib/utils.coffee
Update atoms
[rbdr/dotfiles] / atom / packages / vim-mode / lib / utils.coffee
CommitLineData
455f099b
BB
1{Range} = require 'atom'
2
24c7594d
BB
3module.exports =
4 # Public: Determines if a string should be considered linewise or character
5 #
6 # text - The string to consider
7 #
8 # Returns 'linewise' if the string ends with a line return and 'character'
9 # otherwise.
10 copyType: (text) ->
11 if text.lastIndexOf("\n") is text.length - 1
12 'linewise'
13 else if text.lastIndexOf("\r") is text.length - 1
14 'linewise'
15 else
16 'character'
455f099b
BB
17
18 # Public: return a union of two ranges, or simply the newRange if the oldRange is empty.
19 #
20 # Returns a Range
21 mergeRanges: (oldRange, newRange) ->
22 oldRange = Range.fromObject oldRange
23 newRange = Range.fromObject newRange
24 if oldRange.isEmpty()
25 newRange
26 else
27 oldRange.union(newRange)