File tree Expand file tree Collapse file tree 2 files changed +30
-3
lines changed
plugins/hls-refactor-plugin
src/Development/IDE/Plugin Expand file tree Collapse file tree 2 files changed +30
-3
lines changed Original file line number Diff line number Diff line change @@ -1973,15 +1973,18 @@ regexSingleMatch msg regex = case matchRegexUnifySpaces msg regex of
1973
1973
_ -> Nothing
1974
1974
1975
1975
-- | Process a list of (module_name, filename:src_span) values
1976
- -- | Eg. [(Data.Map, app/ModuleB.hs:2:1-18), (Data.HashMap.Strict, app/ModuleB.hs:3:1-29)]
1976
+ --
1977
+ -- Eg. [(Data.Map, app/ModuleB.hs:2:1-18), (Data.HashMap.Strict, app/ModuleB.hs:3:1-29)]
1977
1978
regExImports :: T. Text -> Maybe [(T. Text , T. Text )]
1978
1979
regExImports msg
1979
1980
| Just mods' <- allMatchRegex msg " ‘([^’]*)’"
1980
1981
, Just srcspans' <- allMatchRegex msg
1982
+ -- This regex has to be able to deal both with single-line srcpans like "(/path/to/File.hs:2:1-18)"
1983
+ -- as well as multi-line srcspans like "(/path/to/File.hs:(3,1)-(5,2))"
1981
1984
#if MIN_VERSION_ghc(9,7,0)
1982
- " \\ (at ([^)]* )\\ )"
1985
+ " \\ (at ([^:]+:[^ ]+ )\\ )"
1983
1986
#else
1984
- " \\ (([^)]* )\\ )"
1987
+ " \\ (([^:]+:[^ ]+ )\\ )"
1985
1988
#endif
1986
1989
, mods <- [mod | [_,mod ] <- mods']
1987
1990
, srcspans <- [srcspan | [_,srcspan] <- srcspans']
Original file line number Diff line number Diff line change @@ -1501,6 +1501,30 @@ extendImportTests = testGroup "extend import actions"
1501
1501
, " f :: Foo"
1502
1502
, " f = undefined"
1503
1503
])
1504
+ , testSession " data constructor with two multiline import lists that can be extended with it" $ template
1505
+ []
1506
+ (" A.hs" , T. unlines
1507
+ [ " module A where"
1508
+ , " import Prelude ("
1509
+ , " )"
1510
+ , " import Data.Maybe ("
1511
+ , " )"
1512
+ , " f = Nothing"
1513
+ ])
1514
+ (Range (Position 5 5 ) (Position 5 6 ))
1515
+ [ " Add Maybe(..) to the import list of Data.Maybe"
1516
+ , " Add Maybe(..) to the import list of Prelude"
1517
+ , " Add Maybe(Nothing) to the import list of Data.Maybe"
1518
+ , " Add Maybe(Nothing) to the import list of Prelude"
1519
+ ]
1520
+ (T. unlines
1521
+ [" module A where"
1522
+ , " import Prelude ("
1523
+ , " )"
1524
+ , " import Data.Maybe (Maybe (..)"
1525
+ , " )"
1526
+ , " f = Nothing"
1527
+ ])
1504
1528
]
1505
1529
where
1506
1530
codeActionTitle CodeAction {_title= x} = x
You can’t perform that action at this time.
0 commit comments