Skip to content
Snippets Groups Projects
Commit b9984efa authored by Marijn Haverbeke's avatar Marijn Haverbeke
Browse files

[matchbrackets addon] Simplify code a little

parent dbb2645c
No related branches found
No related tags found
No related merge requests found
......@@ -18,25 +18,16 @@
function findMatchingBracket(cm, where, strict, config) {
var line = cm.getLineHandle(where.line), pos = where.ch - 1;
var match;
var afterCursor;
if (!config || config.afterCursor === undefined) {
var paddedClassName = ' ' + cm.getWrapperElement().className + ' ';
afterCursor = (paddedClassName.indexOf(' cm-fat-cursor ') > -1);
} else {
afterCursor = config.afterCursor;
}
var afterCursor = config && config.afterCursor
if (afterCursor == null)
afterCursor = /(^| )cm-fat-cursor($| )/.test(cm.getWrapperElement().className)
// A cursor is defined as between two characters, but in in vim command mode
// (i.e. not insert mode), the cursor is visually represented as a
// highlighted box on top of the 2nd character. Otherwise, we allow matches
// from before or after the cursor.
if (afterCursor) {
match = matching[line.text.charAt(++pos)];
} else {
match = (pos >= 0 && matching[line.text.charAt(pos)]) ||
matching[line.text.charAt(++pos)];
}
var match = (!afterCursor && pos >= 0 && matching[line.text.charAt(pos)]) ||
matching[line.text.charAt(++pos)];
if (!match) return null;
var dir = match.charAt(1) == ">" ? 1 : -1;
if (strict && (dir > 0) != (pos == where.ch)) return null;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment