@@ -12,6 +12,7 @@ import Control.Monad.Reader
1212import Data.List (mapAccumL)
1313import Data.Map.Ordered (OMap)
1414import qualified Data.Map.Ordered as OMap
15+import Data.Maybe (fromMaybe)
1516import Data.Ratio ((%))
1617import Data.Semigroup (First(..))
1718import Data.Set.Ordered (OSet)
@@ -395,14 +396,14 @@ instance (HasFocus t m, Monad m) => HasFocus t (Layout t m)
395396instance (Monad m, MonadNodeId m, Reflex t, MonadFix m) => MonadLayout t (Layout t m) where
396397 axis o c (Layout x) = Layout $ do
397398 nodeId <- getNextNodeId
398− (result, forest) <- lift $ local (\t -> (\(Just a) -> a) . lookupLF nodeId . childrenLT <$> t) $ runDynamicWriterT x
399+ (result, forest) <- lift $ local (\t -> fromMaybe (LayoutTree (Region 0 0 0 0, Orientation_Column) mempty) . lookupLF nodeId . childrenLT <$> t) $ runDynamicWriterT x
399400 tellDyn $ singletonLF nodeId <$> (LayoutTree <$> ((,) <$> c <*> o) <*> forest)
400401 pure result
401402 region c = do
402403 nodeId <- lift getNextNodeId
403404 Layout $ tellDyn $ ffor c $ \c' -> singletonLF nodeId $ LayoutTree (c', Orientation_Row) mempty
404405 solutions <- Layout ask
405− pure $ maybe (error "region: could not find layout solution") (fst . rootLT) . lookupLF nodeId . childrenLT <$> solutions
406+ pure $ maybe (Region 0 0 0 0) (fst . rootLT) . lookupLF nodeId . childrenLT <$> solutions
406407 askOrientation = Layout $ asks $ fmap (snd . rootLT)
407408
408409instance (MonadFix m, MonadFocus t m) => MonadFocus t (Layout t m) where