[mod] tidy

This commit is contained in:
Andy Bunce 2025-08-07 12:12:27 +01:00
parent 08051d5281
commit 5f094cdd95

View file

@ -48,12 +48,12 @@ as xs:integer
};
(:~ convert index into Position :)
declare function pos:toPosition($text as xs:string, $pos as xs:integer)
declare function pos:toPosition($text as xs:string, $index as xs:integer)
as pos:Position {
let $nl:=characters($text)=>index-of(char("\n"))
let $predicate:=fn($r, $i){
let $next:=$nl[$i=>trace("I ")]
return exists($next) and $next < $pos
return exists($next) and $next < $index
}
let $s:= while-do(
@ -61,7 +61,7 @@ as pos:Position {
$predicate,
fn($r,$i){ let $next:=$nl[$i] return {"off": $next+1,"line":$r?line+1}=>trace("AA ") }
)
return pos:Position($s?line, $pos - $s?off)
return pos:Position($s?line, $index - $s?off)
};