Fix parsing of faces with a base but no attributes

This commit is contained in:
Maxime Coste 2019-04-28 00:35:52 +01:00
parent f6e58e7271
commit 229768841b
2 changed files with 7 additions and 4 deletions

View File

@ -23,12 +23,14 @@ static FaceRegistry::FaceSpec parse_face(StringView facedesc)
and (attr_it + 1) == facedesc.end()) and (attr_it + 1) == facedesc.end())
throw runtime_error(invalid_face_error.str()); throw runtime_error(invalid_face_error.str());
auto colors_end = std::min(attr_it, base_it);
FaceRegistry::FaceSpec spec; FaceRegistry::FaceSpec spec;
auto& face = spec.face; auto& face = spec.face;
face.fg = attr_it != facedesc.begin() ? face.fg = colors_end != facedesc.begin() ?
str_to_color({facedesc.begin(), std::min(attr_it, bg_it)}) : Color::Default; str_to_color({facedesc.begin(), std::min(bg_it, colors_end)}) : Color::Default;
if (bg_it != facedesc.end()) if (bg_it != facedesc.end())
face.bg = bg_it+1 != attr_it ? str_to_color({bg_it+1, attr_it}) : Color::Default; face.bg = bg_it+1 != attr_it ? str_to_color({bg_it+1, colors_end}) : Color::Default;
if (attr_it != facedesc.end()) if (attr_it != facedesc.end())
{ {
for (++attr_it; attr_it != base_it; ++attr_it) for (++attr_it; attr_it != base_it; ++attr_it)

View File

@ -1,3 +1,4 @@
face global Foo default,blue+i face global Foo default,blue+i
face buffer Foo red,default+u@Foo face buffer Foo green,default+u@Foo
face buffer Foo red@Foo
add-highlighter window/ regex foo 0:Foo add-highlighter window/ regex foo 0:Foo