|
1 | 1 | _ = require 'underscore-plus' |
2 | | -{$} = require 'atom-space-pen-views' |
3 | 2 |
|
4 | 3 | module.exports = |
5 | 4 | escapeHtml: (str) -> |
@@ -29,17 +28,18 @@ module.exports = |
29 | 28 |
|
30 | 29 | parseSearchResult: -> |
31 | 30 | searchResult = [] |
32 | | - summary = $('span.preview-count', 'div.preview-pane').text() |
| 31 | + summary = document.querySelector('span.preview-count').textContent |
33 | 32 | searchResult.push summary, '' |
34 | 33 |
|
35 | | - $('ol.results-view.list-tree>li.path').each -> |
36 | | - path = $('span.path-name', this).text() |
37 | | - matches = $('span.path-match-number', this).text() |
38 | | - searchResult.push path + ' ' + matches |
| 34 | + document.querySelectorAll('ol.results-view.list-tree>li.path').forEach (el) -> |
| 35 | + path = el.querySelector('span.path-name').textContent |
| 36 | + matches = el.querySelector('span.path-match-number').textContent |
| 37 | + searchResult.push "#{path} #{matches}" |
39 | 38 |
|
40 | | - $('li.search-result', this).filter(':visible').each -> |
41 | | - lineNumber = $('span.line-number', this).text() |
42 | | - preview = $('span.preview', this).text() |
43 | | - searchResult.push '\t' + lineNumber + '\t' + preview |
| 39 | + el.querySelectorAll('li.search-result').forEach (e) -> |
| 40 | + return if e.offsetParent is null # skip invisible elements |
| 41 | + lineNumber = e.querySelector('span.line-number').textContent |
| 42 | + preview = e.querySelector('span.preview').textContent |
| 43 | + searchResult.push "\t#{lineNumber}\t#{preview}" |
44 | 44 | searchResult.push '' |
45 | 45 | searchResult.join('\n') |
0 commit comments