mirror of
https://github.com/koalaman/shellcheck
synced 2025-07-12 08:06:29 -07:00
Realign virtual tabs when applying fix
Fix an off-by-one error, in the case that is commented `should never happen`. It happens when the end of a range is the at the end of a line. In that case we should update the real column count (probably just by +1) instead of returning it. I modified makeNonVirtual to use a helper, realign, that works on Ranged. That way we can share the code to realign a PositionedComment and also a Replacement. Fixes #1420
This commit is contained in:
parent
9acc8fcb53
commit
461be74976
3 changed files with 43 additions and 12 deletions
|
@ -153,10 +153,13 @@ showFixedString color comments lineNum fileLines =
|
|||
-- fixes for that single line. We can fold the fixes (which removes
|
||||
-- overlaps), and apply it as a single fix with multiple replacements.
|
||||
applicableComments -> do
|
||||
let mergedFix = (fold . catMaybes . (map pcFix)) applicableComments
|
||||
let mergedFix = (realignFix . fold . catMaybes . (map pcFix)) applicableComments
|
||||
-- in the spirit of error prone
|
||||
putStrLn $ color "message" "Did you mean: "
|
||||
putStrLn $ unlines $ fixedString mergedFix fileLines
|
||||
where
|
||||
realignFix f = f { fixReplacements = map fix (fixReplacements f) }
|
||||
fix r = realign r fileLines
|
||||
|
||||
fixedString :: Fix -> [String] -> [String]
|
||||
fixedString fix fileLines =
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue