X-Git-Url: https://git.r.bdr.sh/rbdr/dotfiles/blobdiff_plain/24c7594d62d8d7fbbcdb64b11ce4adc5d8e6991a..42178d7b5bc16fae8c74a39d859350f0dc5faffb:/atom/packages/vim-mode/lib/utils.coffee?ds=inline diff --git a/atom/packages/vim-mode/lib/utils.coffee b/atom/packages/vim-mode/lib/utils.coffee index 362b65d..5a26310 100644 --- a/atom/packages/vim-mode/lib/utils.coffee +++ b/atom/packages/vim-mode/lib/utils.coffee @@ -1,3 +1,5 @@ +{Range} = require 'atom' + module.exports = # Public: Determines if a string should be considered linewise or character # @@ -12,3 +14,14 @@ module.exports = 'linewise' else 'character' + + # Public: return a union of two ranges, or simply the newRange if the oldRange is empty. + # + # Returns a Range + mergeRanges: (oldRange, newRange) -> + oldRange = Range.fromObject oldRange + newRange = Range.fromObject newRange + if oldRange.isEmpty() + newRange + else + oldRange.union(newRange)