]> git.r.bdr.sh - rbdr/dotfiles/blob - atom/packages/ex-mode/lib/find.coffee
Update vim plugins
[rbdr/dotfiles] / atom / packages / ex-mode / lib / find.coffee
1 module.exports = {
2 findInBuffer : (buffer, pattern) ->
3 found = []
4 buffer.scan(new RegExp(pattern, 'g'), (obj) -> found.push obj.range)
5 return found
6
7 findNextInBuffer : (buffer, curPos, pattern) ->
8 found = @findInBuffer(buffer, pattern)
9 more = (i for i in found when i.compare([curPos, curPos]) is 1)
10 if more.length > 0
11 return more[0].start.row
12 else if found.length > 0
13 return found[0].start.row
14 else
15 return null
16
17 findPreviousInBuffer : (buffer, curPos, pattern) ->
18 found = @findInBuffer(buffer, pattern)
19 less = (i for i in found when i.compare([curPos, curPos]) is -1)
20 if less.length > 0
21 return less[less.length - 1].start.row
22 else if found.length > 0
23 return found[found.length - 1].start.row
24 else
25 return null
26 }