X-Git-Url: https://git.r.bdr.sh/rbdr/dotfiles/blobdiff_plain/24c7594d62d8d7fbbcdb64b11ce4adc5d8e6991a..dc228a52bc420fb3d6c9c482da638ed90d39ffb8:/atom/packages/vim-mode/lib/utils.coffee 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)