Created
August 12, 2017 04:12
-
-
Save cimfalab/99a6834d2edba63874e4e90cb23e9336 to your computer and use it in GitHub Desktop.
HTMLInstrumentation.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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