mirror of
https://github.com/icecoder/ICEcoder.git
synced 2026-03-06 08:44:02 +01:00
Wrap in if plus delays on findReplace
onKeyEvent actually happens on multiple events (keypress and keyup at least) Wrapped in an if statement now so we only trigger half the time, meaning half the work, meaning improved usage Clear any existing timeouts and set a new Timeout to trigger the findReplace action in 0.5s This means as you type it's continually clearing & setting timeouts When you pause typing for more then 0.5s, then it'll trigger the findReplace The result is no lag whilst typing and giving find results within inactivity time only
This commit is contained in:
19
editor.php
19
editor.php
@@ -179,12 +179,19 @@ function createNewCMInstance(num) {
|
||||
lintWith: <?php if ($ICEcoder['codeAssist']) {echo 'fileName && fileName.indexOf(".js")>-1 ? CodeMirror.javascriptValidator : ';};?>false,
|
||||
keyMap: "ICEcoder",
|
||||
onKeyEvent: function(thisCM, e) {
|
||||
top.ICEcoder.redoChangedContent(e);
|
||||
top.ICEcoder.findReplace(top.document.getElementById('find').value,true,false);
|
||||
top.ICEcoder.getCaretPosition();
|
||||
top.ICEcoder.updateCharDisplay();
|
||||
top.ICEcoder.updateByteDisplay();
|
||||
tok = thisCM.getTokenAt(thisCM.getCursor());
|
||||
if (e.type=="keyup") {
|
||||
top.ICEcoder.redoChangedContent(e);
|
||||
if ("undefined" != typeof top.doFind) {
|
||||
clearInterval(top.doFind);
|
||||
}
|
||||
top.doFind = setTimeout(function() {
|
||||
top.ICEcoder.findReplace(top.document.getElementById('find').value,true,false);
|
||||
},500);
|
||||
top.ICEcoder.getCaretPosition();
|
||||
top.ICEcoder.updateCharDisplay();
|
||||
top.ICEcoder.updateByteDisplay();
|
||||
tok = thisCM.getTokenAt(thisCM.getCursor());
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user