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

Function searchInVisualLine

external/.scrollLibs.js:9420–9437  ·  view source on GitHub ↗
(partPos, dir, wrappedLineExtent)

Source from the content-addressed store, hash-verified

9418 // the current bidi part
9419
9420 var searchInVisualLine = function (partPos, dir, wrappedLineExtent) {
9421 var getRes = function (ch, moveInStorageOrder) {
9422 return moveInStorageOrder ? new Pos(start.line, mv(ch, 1), "before") : new Pos(start.line, ch, "after")
9423 }
9424
9425 for (; partPos >= 0 && partPos < bidi.length; partPos += dir) {
9426 var part = bidi[partPos]
9427 var moveInStorageOrder = dir > 0 == (part.level != 1)
9428 var ch = moveInStorageOrder ? wrappedLineExtent.begin : mv(wrappedLineExtent.end, -1)
9429 if (part.from <= ch && ch < part.to) {
9430 return getRes(ch, moveInStorageOrder)
9431 }
9432 ch = moveInStorageOrder ? part.from : mv(part.to, -1)
9433 if (wrappedLineExtent.begin <= ch && ch < wrappedLineExtent.end) {
9434 return getRes(ch, moveInStorageOrder)
9435 }
9436 }
9437 }
9438
9439 // Case 3a: Look for other bidi parts on the same visual line
9440 var res = searchInVisualLine(partPos + dir, dir, wrappedLineExtent)

Callers 1

moveVisuallyFunction · 0.85

Calls 2

mvFunction · 0.85
getResFunction · 0.85

Tested by

no test coverage detected