Skip to content

Commit

Permalink
simplified
Browse files Browse the repository at this point in the history
  • Loading branch information
soulomoon committed Jan 1, 2024
1 parent 40fe213 commit f7a6314
Showing 1 changed file with 4 additions and 10 deletions.
14 changes: 4 additions & 10 deletions lsp/src/Language/LSP/VFS.hs
Original file line number Diff line number Diff line change
Expand Up @@ -431,11 +431,8 @@ codePointPositionToPosition vFile (CodePointPosition l c) = do
-- See Note [Converting between code points and code units]
let text = _file_text vFile
lineRope <- extractLine text $ fromIntegral l
kLine <- case compare c (fromIntegral $ Rope.charLength lineRope) of
LT -> return $ fst $ Rope.charSplitAt (fromIntegral c) lineRope
EQ -> return lineRope
GT -> Nothing
return $ J.Position l (fromIntegral $ Rope.utf16Length kLine)
guard $ c <= fromIntegral (Rope.charLength lineRope)
return $ J.Position l (fromIntegral $ Rope.utf16Length $ fst $ Rope.charSplitAt (fromIntegral c) lineRope)

{- | Given a virtual file, translate a 'CodePointRange' in that file into a 'J.Range' in that file.
Expand All @@ -460,11 +457,8 @@ positionToCodePointPosition vFile (J.Position l c) = do
-- See Note [Converting between code points and code units]
let text = _file_text vFile
lineRope <- extractLine text $ fromIntegral l
kLine <- case compare c (fromIntegral $ Rope.utf16Length lineRope) of
LT -> fst <$> Rope.utf16SplitAt (fromIntegral c) lineRope
EQ -> return lineRope
GT -> Nothing
return $ CodePointPosition l (fromIntegral $ Rope.charLength kLine)
guard $ c <= fromIntegral (Rope.utf16Length lineRope)
CodePointPosition l . fromIntegral . Rope.charLength . fst <$> Rope.utf16SplitAt (fromIntegral c) lineRope

{- | Given a virtual file, translate a 'J.Range' in that file into a 'CodePointRange' in that file.
Expand Down

0 comments on commit f7a6314

Please sign in to comment.