Skip to content

Commit

Permalink
Replace words with a space in allowed characters
Browse files Browse the repository at this point in the history
To handle multiple consecutive allowed characters w/o a space in between
  • Loading branch information
aabounegm committed Dec 6, 2023
1 parent 1c4bc8f commit 13c6fd0
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions rzk/src/Rzk/Format.hs
Original file line number Diff line number Diff line change
Expand Up @@ -120,11 +120,14 @@ formatTextEdits contents = go initialState toks
where
spaceCol = col + 1
lineContent = contentLines line
precededBySingleCharOnly = all isPunctuation (words (take (col - 1) lineContent))
isPunctuation tk = tk `elem` concat
-- | This is similar to (\\) but removes all occurrences (not just the first one)
setDifference xs excludes = filter (not . (`elem` excludes)) xs
precededBySingleCharOnly = null $ foldl' setDifference (take (col - 1) lineContent) punctuations
punctuations = concat
[ map fst unicodeTokens -- ASCII sequences will be converted soon
, map snd unicodeTokens
, ["(", ":", ",", "="]
, [" ", "\t"]
]
spacesAfter = length $ takeWhile (== ' ') (drop col lineContent)
isLastNonSpaceChar = all (== ' ') (drop col lineContent)
Expand Down

0 comments on commit 13c6fd0

Please sign in to comment.