Skip to content

Commit 4f42a7e

Browse files
committed
customize the Debouncer
1 parent 41850eb commit 4f42a7e

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

ghcide/src/Development/IDE/Main.hs

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@ import Data.Maybe (catMaybes, fromMaybe,
1515
import qualified Data.Text as T
1616
import qualified Data.Text.IO as T
1717
import Development.IDE (Action, Rules)
18-
import Development.IDE.Core.Debouncer (newAsyncDebouncer)
18+
import Development.IDE.Core.Debouncer (Debouncer,
19+
newAsyncDebouncer)
1920
import Development.IDE.Core.FileStore (makeVFSHandle)
2021
import Development.IDE.Core.IdeConfiguration (IdeConfiguration (..),
2122
registerIdeConfiguration)
@@ -43,7 +44,8 @@ import Development.IDE.Session (SessionLoadingOptions,
4344
loadSessionWithOptions,
4445
runWithDb,
4546
setInitialDynFlags)
46-
import Development.IDE.Types.Location (toNormalizedFilePath')
47+
import Development.IDE.Types.Location (NormalizedUri,
48+
toNormalizedFilePath')
4749
import Development.IDE.Types.Logger (Logger (Logger))
4850
import Development.IDE.Types.Options (IdeGhcSession,
4951
IdeOptions (optCheckParents, optCheckProject, optReportProgress),
@@ -86,6 +88,7 @@ data Arguments = Arguments
8688
, argsLspOptions :: LSP.Options
8789
, argsDefaultHlsConfig :: Config
8890
, argsGetHieDbLoc :: FilePath -> IO FilePath -- ^ Map project roots to the location of the hiedb for the project
91+
, argsDebouncer :: IO (Debouncer NormalizedUri) -- ^ Debouncer used for diagnostics
8992
}
9093

9194
instance Default Arguments where
@@ -101,6 +104,7 @@ instance Default Arguments where
101104
, argsLspOptions = def {LSP.completionTriggerCharacters = Just "."}
102105
, argsDefaultHlsConfig = def
103106
, argsGetHieDbLoc = getHieDbLoc
107+
, argsDebouncer = newAsyncDebouncer
104108
}
105109

106110
-- | Cheap stderr logger that relies on LineBuffering
@@ -123,6 +127,8 @@ defaultMain Arguments{..} = do
123127
argsOnConfigChange _ide = pure . getConfigFromNotification argsDefaultHlsConfig
124128
rules = argsRules >> pluginRules plugins
125129

130+
debouncer <- argsDebouncer
131+
126132
case argFiles of
127133
Nothing -> do
128134
t <- offsetTime
@@ -148,7 +154,6 @@ defaultMain Arguments{..} = do
148154
{ optReportProgress = clientSupportsProgress caps
149155
}
150156
caps = LSP.resClientCapabilities env
151-
debouncer <- newAsyncDebouncer
152157
initialise
153158
argsDefaultHlsConfig
154159
rules
@@ -184,7 +189,6 @@ defaultMain Arguments{..} = do
184189
when (n > 0) $ putStrLn $ " (" ++ intercalate ", " (catMaybes ucradles) ++ ")"
185190
putStrLn "\nStep 3/4: Initializing the IDE"
186191
vfs <- makeVFSHandle
187-
debouncer <- newAsyncDebouncer
188192
sessionLoader <- loadSessionWithOptions argsSessionLoadingOptions dir
189193
let options = (argsIdeOptions Nothing sessionLoader)
190194
{ optCheckParents = pure NeverCheck

0 commit comments

Comments
 (0)