From 9cd6ca7864dc737d4fd64acd61a435e58ed931f0 Mon Sep 17 00:00:00 2001 From: liuderchi Date: Sun, 27 Nov 2016 16:59:48 +0800 Subject: [PATCH] :art: remove space-pen dependency - output using string interpolation --- lib/project/util.coffee | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/lib/project/util.coffee b/lib/project/util.coffee index e48b3e79..84d46f2c 100644 --- a/lib/project/util.coffee +++ b/lib/project/util.coffee @@ -1,5 +1,4 @@ _ = require 'underscore-plus' -{$} = require 'atom-space-pen-views' module.exports = escapeHtml: (str) -> @@ -29,17 +28,18 @@ module.exports = parseSearchResult: -> searchResult = [] - summary = $('span.preview-count', 'div.preview-pane').text() + summary = document.querySelector('span.preview-count').textContent searchResult.push summary, '' - $('ol.results-view.list-tree>li.path').each -> - path = $('span.path-name', this).text() - matches = $('span.path-match-number', this).text() - searchResult.push path + ' ' + matches + document.querySelectorAll('ol.results-view.list-tree>li.path').forEach (el) -> + path = el.querySelector('span.path-name').textContent + matches = el.querySelector('span.path-match-number').textContent + searchResult.push "#{path} #{matches}" - $('li.search-result', this).filter(':visible').each -> - lineNumber = $('span.line-number', this).text() - preview = $('span.preview', this).text() - searchResult.push '\t' + lineNumber + '\t' + preview + el.querySelectorAll('li.search-result').forEach (e) -> + return if e.offsetParent is null # skip invisible elements + lineNumber = e.querySelector('span.line-number').textContent + preview = e.querySelector('span.preview').textContent + searchResult.push "\t#{lineNumber}\t#{preview}" searchResult.push '' searchResult.join('\n')