Skip to content

Instantly share code, notes, and snippets.

@cimfalab
Created August 12, 2017 04:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cimfalab/99a6834d2edba63874e4e90cb23e9336 to your computer and use it in GitHub Desktop.
Save cimfalab/99a6834d2edba63874e4e90cb23e9336 to your computer and use it in GitHub Desktop.
HTMLInstrumentation.js
function _getMarkerAtDocumentPos(editor, pos, preferParent, markCache) {
var marks, match;
markCache = markCache || {};
marks = _getSortedTagMarks(editor._codeMirror.findMarksAt(pos), markCache);
if (!marks.length) {
return null;
}
// The mark with the latest start is the innermost one.
match = marks[marks.length - 1];
if (preferParent) {
// If the match is exactly at the edge of the range and preferParent is set,
// we want to pop upwards.
if (_posEq(match.range.from, pos) || _posEq(match.range.to, pos)) {
if (marks.length > 1) {
match = marks[marks.length - 2];
} else {
// We must be outside the root, so there's no containing tag.
match = null;
}
}
}
return match.mark;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment