Skip to content

Commit 876f0b3

Browse files
DavidDavid
authored andcommitted
Add matches search into code mirror
1 parent aa318e0 commit 876f0b3

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

client/utils/codemirror-search.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,8 @@ export default function(CodeMirror) {
7373
CodeMirror.on(searchField, "keyup", function (e) {
7474
if (e.keyCode !== 13 && searchField.value.length > 1) { // not enter and more than 1 character to search
7575
startSearch(cm, getSearchState(cm), searchField.value);
76+
} else {
77+
cm.display.wrapper.querySelector('.CodeMirror-search-results').innerText = '';
7678
}
7779
});
7880

@@ -260,6 +262,7 @@ export default function(CodeMirror) {
260262
</button>
261263
</div>
262264
<div class="CodeMirror-search-nav">
265+
<button class="CodeMirror-search-results"></button>
263266
<button
264267
title="Previous"
265268
aria-label="Previous"
@@ -292,6 +295,10 @@ export default function(CodeMirror) {
292295
if (state.annotate) { state.annotate.clear(); state.annotate = null; }
293296
state.annotate = cm.showMatchesOnScrollbar(state.query, state.caseInsensitive);
294297
}
298+
var num_match = cm.state.search.annotate.matches.length;
299+
var text_match =
300+
'Results: ' + num_match;
301+
cm.display.wrapper.querySelector('.CodeMirror-search-results').innerText = text_match;
295302
}
296303

297304
function doSearch(cm, rev, persistent, immediate, ignoreQuery) {

0 commit comments

Comments
 (0)