@@ -30,29 +30,29 @@ section Utils
3030 if string.isEmpty then
3131 #[]
3232 else if string.length == 1 then
33- #[f none (string. get 0 ) none]
33+ #[f none (String.Pos.Raw. get string 0 ) none]
3434 else Id.run do
3535 let mut result := Array.mkEmpty string.length
36- result := result.push <| f none (string. get 0 ) (string. get ⟨1 ⟩)
36+ result := result.push <| f none (String.Pos.Raw. get string 0 ) (String.Pos.Raw. get string ⟨1 ⟩)
3737 -- TODO: the following code is assuming all characters are ASCII
3838 for i in [2 :string.length] do
39- result := result.push <| f (string. get ⟨i - 2 ⟩) (string. get ⟨i - 1 ⟩) (string. get ⟨i⟩)
40- result.push <| f (string. get ⟨string.length - 2 ⟩) (string. get ⟨string.length - 1 ⟩) none
39+ result := result.push <| f (String.Pos.Raw. get string ⟨i - 2 ⟩) (String.Pos.Raw. get string ⟨i - 1 ⟩) (String.Pos.Raw. get string ⟨i⟩)
40+ result.push <| f (String.Pos.Raw. get string ⟨string.length - 2 ⟩) (String.Pos.Raw. get string ⟨string.length - 1 ⟩) none
4141
4242private partial def containsInOrderLower (a b : String) : Bool := Id.run do
4343 go ⟨0 ⟩ ⟨0 ⟩
4444where
4545 go (aPos bPos : String.Pos.Raw) : Bool :=
46- if ha : a .atEnd aPos then
46+ if ha : aPos .atEnd a then
4747 true
48- else if hb : b .atEnd bPos then
48+ else if hb : bPos .atEnd b then
4949 false
5050 else
51- let ac := a .get' aPos ha
52- let bc := b .get' bPos hb
53- let bPos := b .next' bPos hb
51+ let ac := aPos .get' a ha
52+ let bc := bPos .get' b hb
53+ let bPos := bPos .next' b hb
5454 if ac.toLower == bc.toLower then
55- let aPos := a .next' aPos ha
55+ let aPos := aPos .next' a ha
5656 go aPos bPos
5757 else
5858 go aPos bPos
@@ -173,7 +173,7 @@ private def fuzzyMatchCore (pattern word : String) (patternRoles wordRoles : Arr
173173
174174 let mut matchScore := .awful
175175
176- if allowMatch (pattern. get ⟨patternIdx⟩) (word. get ⟨wordIdx⟩) patternRoles[patternIdx]! wordRoles[wordIdx]! then
176+ if allowMatch (String.Pos.Raw. get pattern ⟨patternIdx⟩) (String.Pos.Raw. get word ⟨wordIdx⟩) patternRoles[patternIdx]! wordRoles[wordIdx]! then
177177 if patternIdx >= 1 then
178178 let runLength := runLengths[getIdx (patternIdx - 1 ) (wordIdx - 1 )]! + 1
179179 runLengths := runLengths.set! (getIdx patternIdx wordIdx) runLength
@@ -248,7 +248,7 @@ private def fuzzyMatchCore (pattern word : String) (patternRoles wordRoles : Arr
248248 matchResult (patternIdx wordIdx : Nat) (patternRole wordRole : CharRole) (consecutive : Score) : Int16 := Id.run do
249249 let mut score : Int16 := 1
250250 /- Case-sensitive equality or beginning of a segment in pattern and word. -/
251- if (pattern. get ⟨patternIdx⟩) == (word. get ⟨wordIdx⟩) || (patternRole matches CharRole.head && wordRole matches CharRole.head) then
251+ if (String.Pos.Raw. get pattern ⟨patternIdx⟩) == (String.Pos.Raw. get word ⟨wordIdx⟩) || (patternRole matches CharRole.head && wordRole matches CharRole.head) then
252252 score := score + 1
253253 /- Matched end of word with end of pattern -/
254254 if wordIdx == word.length - 1 && patternIdx == pattern.length - 1 then
0 commit comments