forked from phcode-dev/staging.phcode.dev
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathcss.js
More file actions
1 lines (1 loc) · 1.53 KB
/
css.js
File metadata and controls
1 lines (1 loc) · 1.53 KB
1
define(function(require,exports,module){const EditorManager=require("editor/EditorManager"),QuickOpen=require("search/QuickOpen"),QuickOpenHelper=require("search/QuickOpenHelper"),CSSUtils=require("language/CSSUtils"),DocumentManager=require("document/DocumentManager"),StringMatch=require("utils/StringMatch");function createSelectorList(){var doc=DocumentManager.getCurrentDocument();if(doc){var docText=doc.getText();return CSSUtils.extractAllSelectors(docText,doc.getLanguage().getMode())}}function search(query,matcher){var selectorList=matcher.selectorList;selectorList||(selectorList=createSelectorList(),matcher.selectorList=selectorList),query=query.slice(query.indexOf("@")+1,query.length);var filteredList=$.map(selectorList,function(itemInfo){var searchResult=matcher.match(CSSUtils.getCompleteSelectors(itemInfo),query);return searchResult&&(searchResult.selectorInfo=itemInfo),searchResult});return StringMatch.basicMatchSort(filteredList),filteredList}function itemFocus(selectedItem,query,explicit){if(!(!selectedItem||query.length<2&&!explicit)){var selectorInfo=selectedItem.selectorInfo,from={line:selectorInfo.selectorStartLine,ch:selectorInfo.selectorStartChar},to={line:selectorInfo.selectorStartLine,ch:selectorInfo.selectorEndChar};EditorManager.getCurrentFullEditor().setSelection(from,to,!0)}}function itemSelect(selectedItem,query){itemFocus(selectedItem,query,!0)}QuickOpen.addQuickOpenPlugin({name:"CSS Selectors",languageIds:["css","less","scss"],search:search,match:QuickOpenHelper.match,itemFocus:itemFocus,itemSelect:itemSelect})});