@@ -41,6 +41,7 @@ import Network.Socket hiding (PortNumber, Type,
4141import Options.Applicative (ParseError (..))
4242import qualified Options.Applicative as Opts
4343import System.Directory
44+import System.Info as SysInfo
4445import System.FilePath
4546import System.IO hiding (putStrLn, print)
4647import System.IO.Error (isEOFError)
@@ -66,12 +67,14 @@ data Options = Options
6667 , optionsOutputPath :: FilePath
6768 , optionsPort :: PortNumber
6869 , optionsNoWatch :: Bool
70+ , optionsPolling :: Bool
6971 , optionsDebug :: Bool
70− }
72+ } deriving (Show)
7173
7274main :: IO ()
7375main = do
74− Options dir globs outputPath port noWatch debug <- Opts.execParser opts
76+ opts'@(Options dir globs outputPath port noWatch polling debug) <- Opts.execParser opts
77+ when debug (putText "Parsed Options:" *> print opts')
7578 maybe (pure ()) setCurrentDirectory dir
7679 ideState <- newTVarIO emptyIdeState
7780 cwd <- getCurrentDirectory
@@ -84,7 +87,7 @@ main = do
8487 putText "psc-ide needs you to compile your project (for example by running pulp build)"
8588
8689 unless noWatch $
87− void (forkFinally (watcher ideState fullOutputPath) print)
90+ void (forkFinally (watcher polling ideState fullOutputPath) print)
8891
8992 let conf = Configuration {confDebug = debug, confOutputPath = outputPath, confGlobs = globs}
9093 env = IdeEnvironment {ideStateVar = ideState, ideConfiguration = conf}
@@ -98,12 +101,17 @@ main = do
98101 <*> (fromIntegral <$>
99102 Opts.option Opts.auto (Opts.long "port" `mappend` Opts.short 'p' `mappend` Opts.value (4242 :: Integer)))
100103 <*> Opts.switch (Opts.long "no-watch")
104+ <*> flipIfWindows (Opts.switch (Opts.long "polling"))
101105 <*> Opts.switch (Opts.long "debug")
102106 opts = Opts.info (version <*> Opts.helper <*> parser) mempty
103107 version = Opts.abortOption
104108 (InfoMsg (showVersion Paths.version))
105109 (Opts.long "version" `mappend` Opts.help "Show the version number")
106110
111+ -- polling is the default on Windows and the flag turns it off. See
112+ -- #2209 and #2414 for explanations
113+ flipIfWindows = map (if SysInfo.os == "mingw32" then not else identity)
114+
107115startServer :: PortNumber -> IdeEnvironment -> IO ()
108116startServer port env = withSocketsDo $ do
109117 sock <- listenOnLocalhost port