Fixed case sensitivity issues with tags in title parser

pull/14/head
Sam Bosley 12 years ago
parent 9652d0e3df
commit c2058f8a7e

@ -8,6 +8,8 @@ package com.todoroo.astrid.utility;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Calendar; import java.util.Calendar;
import java.util.HashMap; import java.util.HashMap;
import java.util.HashSet;
import java.util.Set;
import java.util.regex.Matcher; import java.util.regex.Matcher;
import java.util.regex.Pattern; import java.util.regex.Pattern;
@ -16,6 +18,7 @@ import com.google.ical.values.RRule;
import com.mdimension.jchronic.AstridChronic; import com.mdimension.jchronic.AstridChronic;
import com.mdimension.jchronic.Chronic; import com.mdimension.jchronic.Chronic;
import com.todoroo.astrid.data.Task; import com.todoroo.astrid.data.Task;
import com.todoroo.astrid.tags.TagService;
@SuppressWarnings("nls") @SuppressWarnings("nls")
public class TitleParser { public class TitleParser {
@ -52,14 +55,21 @@ public class TitleParser {
Pattern contextPattern = Pattern.compile("(\\s|^)@(\\(.*\\)|[^\\s]+)"); Pattern contextPattern = Pattern.compile("(\\s|^)@(\\(.*\\)|[^\\s]+)");
boolean result = false; boolean result = false;
Set<String> addedTags = new HashSet<String>();
TagService tagService = TagService.getInstance();
while(true) { while(true) {
Matcher m = tagPattern.matcher(inputText); Matcher m = tagPattern.matcher(inputText);
if(m.find()) { if(m.find()) {
result = true; result = true;
String[] splitTags = TitleParser.trimParenthesisAndSplit(m.group(2)); String[] splitTags = TitleParser.trimParenthesisAndSplit(m.group(2));
if (splitTags != null) { if (splitTags != null) {
for (String tag : splitTags) for (String tag : splitTags) {
tags.add(tag); String tagWithCase = tagService.getTagWithCase(tag);
if (!addedTags.contains(tagWithCase))
tags.add(tagWithCase);
addedTags.add(tagWithCase);
}
} }
} else { } else {
m = contextPattern.matcher(inputText); m = contextPattern.matcher(inputText);
@ -67,8 +77,12 @@ public class TitleParser {
result = true; result = true;
String[] splitTags = TitleParser.trimParenthesisAndSplit(m.group(2)); String[] splitTags = TitleParser.trimParenthesisAndSplit(m.group(2));
if (splitTags != null) { if (splitTags != null) {
for (String tag : splitTags) for (String tag : splitTags) {
tags.add(tag); String tagWithCase = tagService.getTagWithCase(tag);
if (!addedTags.contains(tagWithCase))
tags.add(tagWithCase);
addedTags.add(tagWithCase);
}
} }
} else{ } else{
break; break;

Loading…
Cancel
Save