]> git.r.bdr.sh - rbdr/dotfiles/blob - atom/packages/vim-mode/lib/utils.coffee
Remove mc config
[rbdr/dotfiles] / atom / packages / vim-mode / lib / utils.coffee
1 {Range} = require 'atom'
2
3 module.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'
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)