Fix handling of unclosed override blocks starting at position 0

This commit is contained in:
Thomas Goyne 2012-11-11 17:09:16 -08:00
parent 7ca7b1d934
commit b3c1af11b7
2 changed files with 11 additions and 3 deletions

View file

@ -186,7 +186,7 @@ public:
// all tokens after the last override block are TEXT
for (size_t i = tokens.size(); i > 0; --i) {
if (tokens[i - 1].type == dt::OVR_END) {
last_ovr_end = i - 1;
last_ovr_end = i;
break;
}
}
@ -197,7 +197,7 @@ public:
case dt::LINE_BREAK: break;
case dt::TEXT: SplitText(i); break;
case dt::TAG_NAME:
if (i > last_ovr_end) {
if (i + 1 > last_ovr_end) {
SplitText(i);
break;
}
@ -221,7 +221,7 @@ public:
}
break;
default:
if (i > last_ovr_end)
if (i + 1 > last_ovr_end)
SplitText(i);
break;
}

View file

@ -131,5 +131,13 @@ TEST(lagi_word_split, unclosed_ovr) {
EXPECT_EQ(dt::TEXT, tokens[1].type);
EXPECT_EQ(dt::TEXT, tokens[2].type);
EXPECT_EQ(dt::WORD, tokens[3].type);
text = "{";
tokens.clear();
tokens.emplace_back(dt::OVR_BEGIN, 1);
SplitWords(text, tokens);
ASSERT_EQ(1u, tokens.size());
EXPECT_EQ(dt::TEXT, tokens[0].type);
}