Skip to content
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

todo.txt: Fix trailing space resulting in contexts/projects/due-dates to be entered twice #1282

Merged
merged 2 commits into from
Mar 14, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -388,7 +388,7 @@ private void setDueDate(final int offset) {
// Replace due date
new ReplacePattern(TodoTxtTask.PATTERN_DUE_DATE, "$1" + newDue + "$4"),
// Add due date to end if none already exists. Will correctly handle trailing whitespace.
new ReplacePattern("(\\s)*$", " " + newDue)
new ReplacePattern("\\s*$", " " + newDue)
);
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -424,8 +424,7 @@ private static void _runRegexReplaceAction(final EditText editor, final List<Rep
final CharSequence oldRegion = line.subSequence(matchStart, matchEnd);
// Have to create a new matcher, unfortunately, as replace does not respect region
final Matcher replacer = pattern.searchPattern.matcher(oldRegion);
// Replace first vs all handled in matchStart -> matchEnd search
final String newRegion = replacer.replaceAll(pattern.replacePattern);
final String newRegion = pattern.replaceAll ? replacer.replaceAll(pattern.replacePattern) : replacer.replaceFirst(pattern.replacePattern);
text.replace(matchStart + lineStart, matchEnd + lineStart, newRegion);
// Change effective selection based on update
selEnd += newRegion.length() - oldRegion.length();
Expand Down