Skip to content
This repository has been archived by the owner on Jan 16, 2018. It is now read-only.

Commit

Permalink
order definitions
Browse files Browse the repository at this point in the history
  • Loading branch information
faceair committed Apr 17, 2017
1 parent 0d87de5 commit 4e34f46
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 14 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
node_modules
npm-debug.log
.tags*
.history/*
28 changes: 14 additions & 14 deletions lib/searcher.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,21 +42,21 @@ export default class Searcher {

static atomBufferScan(fileTypes, regex, iterator, callback) {
// atomBufferScan just search opened files
const panels = atom.workspace.getPaneItems();
callback(panels.map((editor) => {
if (editor.constructor.name === 'TextEditor') {
const filePath = editor.getPath();
if (filePath) {
const fileExtension = `*.${filePath.split('.').pop()}`;
if (fileTypes.includes(fileExtension)) {
editor.scan(new RegExp(regex, 'ig'), (match) => {
const item = Searcher.transformUnsavedMatch(match);
item.fileName = filePath;
iterator([Searcher.fixColumn(item)].filter(Searcher.filterMatch));
});
}
return filePath;
const activeEditor = atom.workspace.getActiveTextEditor();
const editors = atom.workspace.getTextEditors().filter(x => !Object.is(activeEditor, x));
editors.unshift(activeEditor);
callback(editors.map((editor) => {
const filePath = editor.getPath();
if (filePath) {
const fileExtension = `*.${filePath.split('.').pop()}`;
if (fileTypes.includes(fileExtension)) {
editor.scan(new RegExp(regex, 'ig'), (match) => {
const item = Searcher.transformUnsavedMatch(match);
item.fileName = filePath;
iterator([Searcher.fixColumn(item)].filter(Searcher.filterMatch));
});
}
return filePath;
}
return null;
}).filter(x => x !== null));
Expand Down

0 comments on commit 4e34f46

Please sign in to comment.