-
Notifications
You must be signed in to change notification settings - Fork 56
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: task tags are ignored if not at the start of a comment #532
Conversation
e37aebb
to
b4b3565
Compare
@@ -50,7 +50,7 @@ public static void reloadMarkerConfigs() { | |||
MARKERCONFIG_BY_TAG.put(markerConfig.tag, markerConfig); | |||
} | |||
TAG_SELECTOR_PATTERN = Pattern | |||
.compile("^\\s*(" + MARKERCONFIG_BY_TAG.keySet().stream().collect(Collectors.joining("|")) + ")\\b"); | |||
.compile("\\b*(" + MARKERCONFIG_BY_TAG.keySet().stream().collect(Collectors.joining("|")) + ")\\b"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @sebthom ,
If we remove the "^", I think we not need the "*", I think \b
should be sufficient, instead of \b*
.
I have a bit more time this morning, and I think that the problem is not the regex, but the fact that the comment delimiter is part of the comment string, commentText
in my case contains "-- TODO this and that", and not " TODO this and that". So ^\\s*
will never match any comment.
Is that maybe the problem? A bit above there is a check
if (commentText.length() < 3)
continue;
I am not sure how it all fits together but if the comment separator is going to be part of the string, that condition will almost always be true, so one could as well remove it and rely on the matcher, I do not think performance wise it is much of a speedup, since in this case most comments will pass that condition. In addition there is no hint that task patterns must have more than n characters.
Sorry for the bunch of unstructured information/questions. I do not know the code at all, so I am just commenting just in case you have overlooked something. If not, you can ignore my comments.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we remove the "^", I think we not need the "*", I think
\b
should be sufficient, instead of\b*
.
That is correct. I changed it. Thanks!
I have a bit more time this morning, and I think that the problem is not the regex, but the fact that the comment delimiter is part of the comment string,
commentText
in my case contains "-- TODO this and that", and not " TODO this and that". So^\\s*
will never match any comment.
Interesting. In the languages that I am using/testing (Dart and Haxe), the commentText
does not contain the comment delimiter. Maybe it depends on how the textmate rule is defined.
Is that maybe the problem? A bit above there is a check
if (commentText.length() < 3) continue;
I am not sure how it all fits together but if the comment separator is going to be part of the string, that condition will almost always be true, so one could as well remove it and rely on the matcher, I do not think performance wise it is much of a speedup, since in this case most comments will pass that condition. In addition there is no hint that task patterns must have more than n characters.
I am hitting that condition quite often in Dart and Haxe so I would prefer to keep that check.
BTW: Our single line comment is defined as
Then if the line has the text " -- TODO this and that" then the variable |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks good to me now. IIRC, it is the same regex that we had before the last release
That was actually my intention with this PR but I apparently needed some attempts... |
as of the last release task tags are only evaluated if they are at the beginning of a comment.
this PR restores the previous behaviour of evaluating task tags anywhere in the comment.