Closed bjonnh closed 4 years ago
yasqe.replaceSelection("http://x#") is a problem too. but it seems that http:# is not
Running a waterfall analysis shows that it seems to be stuck in : function findFirstPrefix(cm, line, ch, lineText) {…}
function findFirstPrefix(cm, line, ch, lineText) {
console.log("Step 01")
if (!ch) ch = 0;
if (!lineText) lineText = cm.getLine(line);
console.log("Step 02")
lineText = lineText.toUpperCase();
for (var at = ch, pass = 0; ; ) {
var found = lineText.indexOf(lookFor, at);
if (found == -1) {
//no prefix on this line
if (pass == 1) break;
pass = 1;
at = lineText.length;
continue;
}
console.log("Step 03 pass: "+ pass + " found: " + found + " ch: "+ch + "lineText: " +lineText + "lookFor:" + lookFor)
if (pass == 1 && found < ch) break;
var tokenType = cm.getTokenTypeAt(CodeMirror.Pos(line, found + 1));
console.log("Step 04 token type: " +tokenType)
if (!/^(comment|string)/.test(tokenType)) return found + 1;
at = found - 1;
console.log("Step 05 at is now "+at)
//Could not find a prefix, no use looping any further. Probably invalid query
if (at === pass) break;
}
}```
It is looping doing:
Step 03 pass: 0 found: 47 ch: 0 lineText: HTTP://WWW.W3.ORG/1999/02/22-RDF-SYNTAX-NS#TYPEPREFIX RDFS: <HTTP://WWWRDF-SCHEMA#> lookFor:PREFIX
Step 04 token type: comment prefixFold.js:34
Step 05 at is now 46 prefixFold.js:37
Fixed by PR #141 and also not an issue in the newest release (see https://github.com/TriplyDB/Yasgui)
Try running yasqe.replaceSelection("http://www.w3.org/1999/02/22-rdf-syntax-ns#type")
when the cursor is on the first line (using the Firefox inspector on the Yasqe webpage I can reproduce that 100% of the time).
Selection become impossible and the editor is stuck.