File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -720,6 +720,11 @@ impl Ghci {
720720 // We get _all_ file events in this loop, not just Haskell source files, so let's guard
721721 // adding an entry to the `eval_commands` map by making sure we can convert the path to
722722 // a module name.
723+ //
724+ // However!!! We're _modifying_ an existing map here, so if we look at a path and
725+ // _don't_ find any commands, we need to be careful to _remove_ that entry from the map.
726+ //
727+ // Hey maybe this should just be a generic multimap structure, anyone ever think of that?
723728 if self . search_paths . path_to_module ( path) . is_err ( ) {
724729 if is_haskell_source_file ( path) {
725730 // If the path is a Haskell source file (ends with `.hs` or similar), we should
@@ -730,11 +735,16 @@ impl Ghci {
730735 } else {
731736 tracing:: debug!( %path, "Could not determine module path, skipping parsing eval commands" ) ;
732737 }
738+ self . eval_commands . remove ( path) ;
733739 continue ;
734740 }
735741
736742 let commands = Self :: parse_eval_commands ( path) . await ?;
737- self . eval_commands . insert ( path. clone ( ) , commands) ;
743+ if commands. is_empty ( ) {
744+ self . eval_commands . remove ( path) ;
745+ } else {
746+ self . eval_commands . insert ( path. clone ( ) , commands) ;
747+ }
738748 }
739749
740750 Ok ( ( ) )
Original file line number Diff line number Diff line change @@ -55,6 +55,7 @@ async fn can_eval_commands() {
5555 . expect ( "ghciwatch finishes initializing" ) ;
5656
5757 // Erase the command.
58+ session. clear_events ( ) ;
5859 session. fs ( ) . replace ( module_path, cmd, "" ) . await . unwrap ( ) ;
5960 session
6061 . wait_until_reload ( )
@@ -109,6 +110,7 @@ async fn can_load_new_eval_commands_multiline() {
109110 . expect ( "ghciwatch evals commands" ) ;
110111
111112 // Erase the command.
113+ session. clear_events ( ) ;
112114 session
113115 . fs ( )
114116 . replace ( module_path, eval_cmd, "" )
You can’t perform that action at this time.
0 commit comments