Skip to content

Commit

Permalink
fix: codecov missing coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
sekedus committed Dec 3, 2024
1 parent 45851b9 commit e87351f
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 11 deletions.
4 changes: 0 additions & 4 deletions src/editor.js
Original file line number Diff line number Diff line change
Expand Up @@ -617,10 +617,6 @@ class Editor {

// Update cursor because tab characters can influence the cursor position.
this.$cursorChange();

// Updates "updateCounter" and "ace_nomatch" in the search box
if (this.searchBox && this.searchBox.active === true)
this.searchBox.find(false, false, true);
}

/**
Expand Down
8 changes: 8 additions & 0 deletions src/ext/searchbox.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ class SearchBox {
this.element = div.firstChild;

this.setSession = this.setSession.bind(this);
this.$onEditorInput = this.onEditorInput.bind(this);

this.$init();
this.setEditor(editor);
Expand All @@ -72,6 +73,11 @@ class SearchBox {
this.$syncOptions(true);
}

// Auto update "updateCounter" and "ace_nomatch"
onEditorInput() {
this.find(false, false, true);
}

/**
* @param {HTMLElement} sb
*/
Expand Down Expand Up @@ -283,6 +289,7 @@ class SearchBox {
this.active = false;
this.setSearchRange(null);
this.editor.off("changeSession", this.setSession);
this.editor.off("input", this.$onEditorInput);

this.element.style.display = "none";
this.editor.keyBinding.removeKeyboardHandler(this.$closeSearchBarKb);
Expand All @@ -296,6 +303,7 @@ class SearchBox {
show(value, isReplace) {
this.active = true;
this.editor.on("changeSession", this.setSession);
this.editor.on("input", this.$onEditorInput);
this.element.style.display = "";
this.replaceOption.checked = isReplace;

Expand Down
4 changes: 2 additions & 2 deletions src/search.js
Original file line number Diff line number Diff line change
Expand Up @@ -592,8 +592,8 @@ function addWordBoundary(needle, options) {
}

function multiLineBackwardMatch(line, re, endMargin) {
var match,
from = 0;
var match = null;
var from = 0;
while (from <= line.length) {
re.lastIndex = from;
var newMatch = re.exec(line);
Expand Down
9 changes: 7 additions & 2 deletions src/search_highlight.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ class SearchHighlight {
this.setRegexp(regExp);
this.clazz = clazz;
this.type = type;
this.docLen = 0;
}

setRegexp(regExp) {
Expand All @@ -33,14 +34,15 @@ class SearchHighlight {
update(html, markerLayer, session, config) {
if (!this.regExp)
return;
var start = config.firstRow, end = config.lastRow;
var start = config.firstRow;
var end = config.lastRow;
var renderedMarkerRanges = {};
var _search = session.$editor.$search;
var mtSearch = _search.$isMultilineSearch(session.$editor.getLastSearchOptions());

for (var i = start; i <= end; i++) {
var ranges = this.cache[i];
if (ranges == null) {
if (ranges == null || session.getValue().length != this.docLen) {
if (mtSearch) {
ranges = [];
var match = _search.$multiLineForward(session, this.regExp, i, end);
Expand All @@ -64,6 +66,8 @@ class SearchHighlight {
this.cache[i] = ranges.length ? ranges : "";
}

if (ranges.length === 0) continue;

for (var j = ranges.length; j --; ) {
var rangeToAddMarkerTo = ranges[j].toScreenRange(session);
var rangeAsString = rangeToAddMarkerTo.toString();
Expand All @@ -74,6 +78,7 @@ class SearchHighlight {
html, rangeToAddMarkerTo, this.clazz, config);
}
}
this.docLen = session.getValue().length;
}
}

Expand Down
4 changes: 1 addition & 3 deletions src/search_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -684,8 +684,6 @@ module.exports = {
},

"test: replace with line breaks (\\n) and TAB (\\t) using regular expression" : function() {
var session = new EditSession('\nfunction foo(items, nada) {\n for (var i=0; i<items.length; i++) {\n alert(items[i] + "juhu\\n");\n }\t/* Real Tab */\n\n\n\n\n}\n\n\n// test search/replace line break with regexp\r\n\r\n\t\t\t\t\n');

var search = new Search().set({
needle: "with",
regExp: true,
Expand All @@ -700,7 +698,7 @@ module.exports = {
assert.equal(search.replace("\n", "\t"), "\t");
assert.equal(search.replace("\n\n\n", "\n"), "\n");
assert.equal(search.replace("\n\t\n\n", "\t$1"), "\t\n\t\t\n\n");
assert.equal(search.replace("\r\n /* CRLF */", "\n"), "\n /* CRLF */");
assert.equal(search.replace("\r\n /* CRLF */", "\n"), "\n /* LF */");
}
};

Expand Down

0 comments on commit e87351f

Please sign in to comment.