ollef / rope-utf16-splay

Thick strings optimised for indexing and updating using UTF-16 code units and row/column pairs
BSD 3-Clause "New" or "Revised" License
14 stars 3 forks source link

codeUnitsRowColumn as companion to rowColumnCodeUnits #3

Closed alanz closed 3 years ago

alanz commented 3 years ago

We have

rowColumnCodeUnits :: RowColumn -> Rope -> Int

Can we have the inverse

codeUnitsRowColumn :: Int -> Rope -> RowColumn

It looks like it should be some combination of splitAt and measure

alanz commented 3 years ago

And it seems that what I am looking for is

codeUnitsRowColumn :: Int -> Rope ->RowColumn
codeUnitsRowColumn offset rope = rowColumn . measure . fst $ splitAt offset rope
ollef commented 3 years ago

Sounds good. Wanna create a PR with that?