diff --git a/webapp/lsp/position.xqm b/webapp/lsp/position.xqm index 47d0eb5..cb1509f 100644 --- a/webapp/lsp/position.xqm +++ b/webapp/lsp/position.xqm @@ -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) };