diff --git a/metainfo.xml b/metainfo.xml
index 232acbefdd..505b370d43 100644
--- a/metainfo.xml
+++ b/metainfo.xml
@@ -122,6 +122,7 @@
Adds DEC Technical Character Set with full 94-position Unicode mapping (Greek letters, math symbols, bracket pieces, arrows)
Fixes VT parser: DCS_Param to DCS_Intermediate transition now correctly collects intermediate bytes
Removes ScreenBase class — merges into Screen, eliminating unnecessary virtual dispatch
+ Fixes loading of optional fields in the config file (#1940)
diff --git a/src/contour/Config.cpp b/src/contour/Config.cpp
index 2eb833c898..f50f8b00a4 100644
--- a/src/contour/Config.cpp
+++ b/src/contour/Config.cpp
@@ -2027,13 +2027,13 @@ std::optional YAMLConfigReader::parseAction(YAML::Node const& n
auto actionOpt = actions::fromString(actionName);
if (!actionOpt)
{
- logger()("Unknown action '{}'.", actionNode["action"].as());
+ logger()("Unknown action '{}'.", actionName);
return std::nullopt;
}
auto action = actionOpt.value();
if (holds_alternative(action))
{
- if (auto name = node["name"]; name.IsScalar())
+ if (auto name = node["name"]; name && name.IsScalar())
{
return actions::ChangeProfile { actionNode.as() };
}
@@ -2043,7 +2043,7 @@ std::optional YAMLConfigReader::parseAction(YAML::Node const& n
if (holds_alternative(action))
{
- if (auto position = node["position"]; position.IsScalar())
+ if (auto position = node["position"]; position && position.IsScalar())
return actions::MoveTabTo { position.as() };
else
return std::nullopt;
@@ -2051,7 +2051,7 @@ std::optional YAMLConfigReader::parseAction(YAML::Node const& n
if (holds_alternative(action))
{
- if (auto position = node["position"]; position.IsScalar())
+ if (auto position = node["position"]; position && position.IsScalar())
{
return actions::SwitchToTab { position.as() };
}
@@ -2071,7 +2071,7 @@ std::optional YAMLConfigReader::parseAction(YAML::Node const& n
if (holds_alternative(action))
{
- if (auto profileName = node["profile"]; profileName.IsScalar())
+ if (auto profileName = node["profile"]; profileName && profileName.IsScalar())
{
return actions::ReloadConfig { profileName.as() };
}
@@ -2081,7 +2081,7 @@ std::optional YAMLConfigReader::parseAction(YAML::Node const& n
if (holds_alternative(action))
{
- if (auto chars = node["chars"]; chars.IsScalar())
+ if (auto chars = node["chars"]; chars && chars.IsScalar())
{
return actions::SendChars { crispy::unescape(chars.as()) };
}
@@ -2133,7 +2133,7 @@ std::optional YAMLConfigReader::parseAction(YAML::Node const& n
if (holds_alternative(action))
{
- if (auto chars = node["chars"]; chars.IsScalar())
+ if (auto chars = node["chars"]; chars && chars.IsScalar())
{
return actions::WriteScreen { chars.as() };
}
@@ -2143,7 +2143,7 @@ std::optional YAMLConfigReader::parseAction(YAML::Node const& n
if (holds_alternative(action))
{
- if (auto delimiters = node["delimiters"]; delimiters.IsScalar())
+ if (auto delimiters = node["delimiters"]; delimiters && delimiters.IsScalar())
{
return actions::CreateSelection { delimiters.as() };
}