forked from phcode-dev/staging.phcode.dev
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathhtml.js
More file actions
1 lines (1 loc) · 1.34 KB
/
html.js
File metadata and controls
1 lines (1 loc) · 1.34 KB
1
define(function(require,exports,module){const QuickOpen=require("search/QuickOpen"),QuickOpenHelper=require("search/QuickOpenHelper"),DocumentManager=require("document/DocumentManager"),StringMatch=require("utils/StringMatch");function FileLocation(fullPath,line,chFrom,chTo,id){this.fullPath=fullPath,this.line=line,this.chFrom=chFrom,this.chTo=chTo,this.id=id}function createIDList(){var doc=DocumentManager.getCurrentDocument();if(doc){var idList=[],docText,lines=doc.getText().split("\n"),regex=new RegExp(/\s+id\s*?=\s*?["'](.*?)["']/gi),id,chFrom,chTo,i,line;for(i=0;i<lines.length;i++){var info;for(line=lines[i];null!==(info=regex.exec(line));)id=info[1],chTo=(chFrom=line.indexOf(id))+id.length,idList.push(new FileLocation(null,i,chFrom,chTo,id))}return idList}}function search(query,matcher){var idList=matcher.idList;idList||(idList=createIDList(),matcher.idList=idList),query=query.slice(query.indexOf("@")+1,query.length);var filteredList=$.map(idList,function(fileLocation){var searchResult=matcher.match(fileLocation.id,query);return searchResult&&(searchResult.fileLocation=fileLocation),searchResult});return StringMatch.basicMatchSort(filteredList),filteredList}QuickOpen.addQuickOpenPlugin({name:"html ids",languageIds:["html"],search:search,match:QuickOpenHelper.match,itemFocus:QuickOpenHelper.itemFocus,itemSelect:QuickOpenHelper.itemSelect})});