chore: add padding to mappingRange if names are too short
This commit is contained in:
parent
5a3b2881c4
commit
8f2b31acef
@ -569,7 +569,16 @@ examAutoOccurrence (hash -> seed) rule ExamAutoOccurrenceConfig{..} occurrences
|
||||
-- userTags is guaranteed nonNull
|
||||
end = case t of
|
||||
[] -> replicate (length start) $ last alphabet
|
||||
_nonEmpty -> maximum $ impureNonNull $ map (transformTag start) userTags
|
||||
_nonEmpty
|
||||
| length biggestTag < length start
|
||||
-- add padding, to keep equal length
|
||||
-> biggestTag ++ replicate (length start - length biggestTag) paddingChar
|
||||
| otherwise -> biggestTag
|
||||
where
|
||||
biggestTag :: [CI Char]
|
||||
biggestTag = maximum $ impureNonNull $ map (transformTag start) userTags
|
||||
paddingChar :: CI Char
|
||||
paddingChar = CI.mk ' '
|
||||
nextStart :: NonNull [CI Char]
|
||||
-- end is guaranteed nonNull, all empty tags are filtered out in users'
|
||||
nextStart = impureNonNull $ reverse $ increase $ reverse end
|
||||
@ -578,8 +587,12 @@ examAutoOccurrence (hash -> seed) rule ExamAutoOccurrenceConfig{..} occurrences
|
||||
increase :: [CI Char] -> [CI Char]
|
||||
increase [] = []
|
||||
increase (c:cs)
|
||||
| nextChar == head alphabet = nextChar : increase cs
|
||||
| otherwise = nextChar : cs
|
||||
| nextChar == head alphabet
|
||||
= nextChar : increase cs
|
||||
| nextChar == paddingChar
|
||||
= head alphabet : cs
|
||||
| otherwise
|
||||
= nextChar : cs
|
||||
where
|
||||
nextChar :: CI Char
|
||||
nextChar = dropWhile (/= c) alphabetCycle List.!! 1
|
||||
|
||||
Loading…
Reference in New Issue
Block a user