mirror of
https://github.com/gorhill/uBlock.git
synced 2024-09-15 15:32:28 +02:00
Only URLs in comments can be selected through double-click
This commit is contained in:
parent
376ef4645f
commit
6ff72af4aa
@ -578,16 +578,24 @@ CodeMirror.registerHelper('fold', 'ubo-static-filtering', (( ) => {
|
|||||||
return Pass;
|
return Pass;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
const s = cm.getLine(line);
|
|
||||||
|
|
||||||
// Select URL
|
const s = cm.getLine(line);
|
||||||
let lmatch = /\bhttps?:\/\/\S+$/.exec(s.slice(0, ch));
|
const token = cm.getTokenTypeAt(pos);
|
||||||
let rmatch = /^\S+/.exec(s.slice(ch));
|
let lmatch, rmatch;
|
||||||
|
let select = false;
|
||||||
|
|
||||||
|
// Select URL in comments
|
||||||
|
if ( token === 'comment link' ) {
|
||||||
|
lmatch = /\S+$/.exec(s.slice(0, ch));
|
||||||
|
rmatch = /^\S+/.exec(s.slice(ch));
|
||||||
|
select = lmatch !== null && rmatch !== null &&
|
||||||
|
/^https?:\/\//.test(s.slice(lmatch.index));
|
||||||
|
}
|
||||||
|
|
||||||
// TODO: add more convenient word-matching cases here
|
// TODO: add more convenient word-matching cases here
|
||||||
// if ( lmatch === null || rmatch === null ) { ... }
|
// if ( select === false ) { ... }
|
||||||
|
|
||||||
if ( lmatch === null || rmatch === null ) { return Pass; }
|
if ( select === false ) { return Pass; }
|
||||||
cm.setSelection(
|
cm.setSelection(
|
||||||
{ line, ch: lmatch.index },
|
{ line, ch: lmatch.index },
|
||||||
{ line, ch: ch + rmatch.index + rmatch[0].length }
|
{ line, ch: ch + rmatch.index + rmatch[0].length }
|
||||||
|
Loading…
Reference in New Issue
Block a user