Skip to content

Commit 746ec29

Browse files
committed
ghc9: Fix "Remove redundant imports" code action
In ghc9, only the specific unused function is highlighted, instead of the whole line.
1 parent 316f96e commit 746ec29

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

ghcide/src/Development/IDE/Plugin/CodeAction.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -252,7 +252,7 @@ suggestRemoveRedundantImport :: ParsedModule -> Maybe T.Text -> Diagnostic -> [(
252252
suggestRemoveRedundantImport ParsedModule{pm_parsed_source = L _ HsModule{hsmodImports}} contents Diagnostic{_range=_range,..}
253253
-- The qualified import of ‘many’ from module ‘Control.Applicative’ is redundant
254254
| Just [_, bindings] <- matchRegexUnifySpaces _message "The( qualified)? import of ‘([^’]*)’ from module [^ ]* is redundant"
255-
, Just (L _ impDecl) <- find (\(L l _) -> srcSpanToRange l == Just _range ) hsmodImports
255+
, Just (L _ impDecl) <- find (\(L l _) -> _start _range `isInsideSrcSpan` l && _end _range `isInsideSrcSpan` l ) hsmodImports
256256
, Just c <- contents
257257
, ranges <- map (rangesForBindingImport impDecl . T.unpack) (T.splitOn ", " bindings)
258258
, ranges' <- extendAllToIncludeCommaIfPossible False (indexedByPosition $ T.unpack c) (concat ranges)

0 commit comments

Comments
 (0)