Open core-ai-bot opened 3 years ago
Comment by ingorichter Wednesday Jan 14, 2015 at 06:28 GMT
@
RaymondLim do you know about the precision
parameter and what the impact might be, when we pass undefined
vs. true
?
Comment by RaymondLim Wednesday Jan 14, 2015 at 23:03 GMT
@
ingorichter I don't know about the precision
param and its impact, but as@
MarcelGerber pointed out it only affects findStartLine
function. So I guess this pr won't affect in most of the times except in an edge case where we need to search backwards passing more than 100 lines (1000 lines if the current pos is inside the inner mode). I can't imagine how to create a valid test case like that since searching backwards may stop as soon as line.stateAfter
is true in the following code.
function findStartLine(cm, n, precise) {
var minindent, minline, doc = cm.doc;
var lim = precise ? -1 : n - (cm.doc.mode.innerMode ? 1000 : 100);
for (var search = n; search > lim; --search) {
if (search <= doc.first) return doc.first;
var line = getLine(doc, search - 1);
if (line.stateAfter && (!precise || search <= doc.frontier)) return search;
var indented = countColumn(line.text, null, cm.options.tabSize);
if (minline == null || minindent > indented) {
minline = search - 1;
minindent = indented;
}
}
return minline;
}
Comment by ingorichter Thursday Jan 15, 2015 at 00:21 GMT
@
MarcelGerber@
RaymondLim if this is a rather unlikely scenario, then the impact might be minimal on a daily basis. Thanks for the info Raymond.
Comment by MarcelGerber Thursday Jan 15, 2015 at 14:38 GMT
The CM manual says:
If
precise
is true, the token will be guaranteed to be accurate based on recent edits. If false or not specified, the token will use cached state information, which will be faster but might not be accurate if edits were recently made and highlighting has not yet completed.
So if I get this right, in most cases it doesn't matter whether it's set or not. I'd like to know though if this only applies to big changes (like copy-paste-replacing a whole file) or also for small ones.
Comment by MarcelGerber Saturday Apr 11, 2015 at 14:18 GMT
Closing in favor of #10882, which improves TokenUtils.getModeAt
to be a lot faster in cases.
Issue by MarcelGerber Thursday Dec 11, 2014 at 18:30 GMT Originally opened as https://github.com/adobe/brackets/pull/10150
So,
cm.getModeAt
basically just does what our function did, but faster. See https://github.com/codemirror/CodeMirror/blob/b833e63142d18e89a43cc37b712325f5b530c08c/lib/codemirror.js#L4228-L4232MarcelGerber included the following code: https://github.com/adobe/brackets/pull/10150/commits