MCPcopy Create free account
hub / github.com/breck7/scroll / coordsBidiPart

Function coordsBidiPart

external/.scrollLibs.js:4212–4238  ·  view source on GitHub ↗
(cm, lineObj, lineNo$$1, preparedMeasure, order, x, y)

Source from the content-addressed store, hash-verified

4210 }
4211
4212 function coordsBidiPart(cm, lineObj, lineNo$$1, preparedMeasure, order, x, y) {
4213 // Bidi parts are sorted left-to-right, and in a non-line-wrapping
4214 // situation, we can take this ordering to correspond to the visual
4215 // ordering. This finds the first part whose end is after the given
4216 // coordinates.
4217 var index = findFirst(
4218 function (i) {
4219 var part = order[i],
4220 ltr = part.level != 1
4221 return boxIsAfter(cursorCoords(cm, Pos(lineNo$$1, ltr ? part.to : part.from, ltr ? "before" : "after"), "line", lineObj, preparedMeasure), x, y, true)
4222 },
4223 0,
4224 order.length - 1
4225 )
4226 var part = order[index]
4227 // If this isn't the first part, the part's start is also after
4228 // the coordinates, and the coordinates aren't on the same line as
4229 // that start, move one part back.
4230 if (index > 0) {
4231 var ltr = part.level != 1
4232 var start = cursorCoords(cm, Pos(lineNo$$1, ltr ? part.from : part.to, ltr ? "after" : "before"), "line", lineObj, preparedMeasure)
4233 if (boxIsAfter(start, x, y, true) && start.top > y) {
4234 part = order[index - 1]
4235 }
4236 }
4237 return part
4238 }
4239
4240 function coordsBidiPartWrapped(cm, lineObj, _lineNo, preparedMeasure, order, x, y) {
4241 // In a wrapped line, rtl text on wrapping boundaries can do things

Callers

nothing calls this directly

Calls 4

findFirstFunction · 0.85
boxIsAfterFunction · 0.85
cursorCoordsFunction · 0.85
PosFunction · 0.85

Tested by

no test coverage detected