Skip to content
This repository was archived by the owner on Dec 12, 2021. It is now read-only.

Commit b56a289

Browse files
committed
FIX: Prompt search & tag usage
1 parent a96715e commit b56a289

File tree

4 files changed

+17
-7
lines changed

4 files changed

+17
-7
lines changed

CHANGELOG.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,10 @@
77
#### Features
88
- Snippet tag functionalities
99
#### Improvements
10-
-
10+
1111
#### Patches
1212
- Debug output
13+
- Search prompt
1314

1415

1516
---

lib/icon-helper.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/snippet-injector.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,8 @@ export default {
180180
var elem = new Snippet(JSON.parse(storage.retrieveFile(currentValue.replace('.json',''))));
181181
listitems.push({
182182
title: elem.getTitle(),
183-
uid: elem.getUID()
183+
uid: elem.getUID(),
184+
tags: elem.getTags()
184185
});
185186
icons.push(elem.getLang());
186187
});

lib/util.js

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -140,10 +140,15 @@ export default class Util {
140140
var text = edit.getText();
141141
$('#prompt-list').find('.list-item, .notice').remove();
142142
var filteredItems = options.listItems.filter(function(element) {
143-
element = element.toLowerCase();
144143
text = text.toLowerCase();
145144
if(text !== '' && text !== ' ' && text !== null && text !== undefined) {
146-
return (element.indexOf(text) > -1 ? true : false);
145+
var title = element.title.toLowerCase();
146+
var tags = element.tags.join(' ').toLowerCase();
147+
if(text.startsWith('#')) {
148+
return (tags.indexOf(text.split('#').join('')) > -1 ? true : false);
149+
} else {
150+
return (title.indexOf(text) > -1 ? true : false);
151+
}
147152
} else {
148153
return true;
149154
}
@@ -159,14 +164,17 @@ export default class Util {
159164
listDOMstring += IconHelper.getIconTag('default');
160165
}
161166
}
162-
listDOMstring += '<p class="value">';
163-
listDOMstring += currentValue;
167+
listDOMstring += '<p class="value" data-id="'+currentValue.uid+'">';
168+
listDOMstring += currentValue.title;
164169
listDOMstring += '</p></li>';
165170
});
166171
} else {
167172
listDOMstring += '<li class="notice"><i>'+options.nothingfound+'</i></li>';
168173
}
169174
$('#prompt-list').append(listDOMstring);
175+
if(options.icons.length > 0) {
176+
IconHelper.colorize('colored-svg');
177+
}
170178
});
171179
var handleCancel = function(e) {
172180
window.removeEventListener('keyup',handleKey,true);

0 commit comments

Comments
 (0)