Fix in_tag and is_tag calls, fixes #47

This commit is contained in:
Twan van Laarhoven
2020-05-19 22:59:38 +02:00
parent a0f077e3b6
commit 09139128e1
5 changed files with 25 additions and 10 deletions
+1 -1
View File
@@ -203,7 +203,7 @@ unique_ptr<TextValueAction> typing_action(const TextValueP& value, size_t start_
TextToggleReminderAction::TextToggleReminderAction(const TextValueP& value, size_t pos_in)
: ValueAction(value)
{
pos = in_tag(value->value(), _("<kw-"), pos_in, pos_in);
pos = in_tag(value->value(), _("<kw"), pos_in, pos_in);
if (pos == String::npos) {
throw InternalError(_("TextToggleReminderAction: not in <kw- tag"));
}
+3 -3
View File
@@ -531,9 +531,9 @@ String expand_keywords(const String& tagged_str, vector<KeywordMatch> const& mat
} else {
bool is_close = (it+1) != end && *(it+1) == '/';
if (is_close && !close || !is_close && !open) return;
if (is_substr(it, end, "<atom")) {
if (is_tag(it, end, "<atom")) {
atom++;
} else if (is_substr(it, end, "</atom")) {
} else if (is_tag(it, end, "</atom")) {
atom++;
}
// keep tag in output
@@ -602,7 +602,7 @@ String::const_iterator keyword_match_detail(String::const_iterator it, String::c
// The even captures are parameter values, the odd ones are the plain text in between
// submatch 0 is the whole match
assert(match.size() - 1 == 1 + 2 * keyword.parameters.size());
for (int sub = 1; sub < match.size(); ++sub) {
for (int sub = 1; sub < (int)match.size(); ++sub) {
// The matched part, indices in untagged string. We only need the length
size_t part_len_untagged = match.length(sub);
// Translate back to tagged position