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
|
-- userTags is guaranteed nonNull
|
||||||
end = case t of
|
end = case t of
|
||||||
[] -> replicate (length start) $ last alphabet
|
[] -> 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]
|
nextStart :: NonNull [CI Char]
|
||||||
-- end is guaranteed nonNull, all empty tags are filtered out in users'
|
-- end is guaranteed nonNull, all empty tags are filtered out in users'
|
||||||
nextStart = impureNonNull $ reverse $ increase $ reverse end
|
nextStart = impureNonNull $ reverse $ increase $ reverse end
|
||||||
@ -578,8 +587,12 @@ examAutoOccurrence (hash -> seed) rule ExamAutoOccurrenceConfig{..} occurrences
|
|||||||
increase :: [CI Char] -> [CI Char]
|
increase :: [CI Char] -> [CI Char]
|
||||||
increase [] = []
|
increase [] = []
|
||||||
increase (c:cs)
|
increase (c:cs)
|
||||||
| nextChar == head alphabet = nextChar : increase cs
|
| nextChar == head alphabet
|
||||||
| otherwise = nextChar : cs
|
= nextChar : increase cs
|
||||||
|
| nextChar == paddingChar
|
||||||
|
= head alphabet : cs
|
||||||
|
| otherwise
|
||||||
|
= nextChar : cs
|
||||||
where
|
where
|
||||||
nextChar :: CI Char
|
nextChar :: CI Char
|
||||||
nextChar = dropWhile (/= c) alphabetCycle List.!! 1
|
nextChar = dropWhile (/= c) alphabetCycle List.!! 1
|
||||||
|
|||||||
Reference in New Issue
Block a user