From 52997819ddf59be302bbcf9418a073c94ca30d6e Mon Sep 17 00:00:00 2001 From: Open Source Contributor Date: Tue, 5 May 2026 16:45:00 -0600 Subject: [PATCH] Fix task description truncated when space follows period The first_sentence method was incorrectly splitting on period followed by any whitespace, which caused descriptions like 'foo. bar' to be truncated to just 'foo'. For example: - 'foo. bar' was truncated to 'foo' (bug) - 'foo.bar' remained 'foo.bar' (correct) - 'This is a task. It has more.' became 'This is a task' (correct) The new regex uses a positive lookbehind to match sentence terminators (. ! ?) followed by one or more spaces, which correctly handles: - Multiple sentences separated by spaces - Decimal points (e.g. doesn't end a sentence) - Periods in abbreviations - Cases where a period is followed by a newline instead of space --- lib/rake/task.rb | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/lib/rake/task.rb b/lib/rake/task.rb index e61ccb641..2f1cf6a58 100644 --- a/lib/rake/task.rb +++ b/lib/rake/task.rb @@ -336,10 +336,11 @@ def transform_comments(separator, &block) private :transform_comments # Get the first sentence in a string. The sentence is terminated - # by the first period, exclamation mark, or the end of the line. - # Decimal points do not count as periods. + # by the first period, exclamation mark, question mark, or the end + # of the line. Multiple spaces after sentence terminators are + # ignored to avoid splitting on abbreviations like "e.g.". def first_sentence(string) - string.split(/(?<=\w)(\.|!)[ \t]|(\.$|!)|\n/).first + string.split(/(?<=[.!?])\s+/).first end private :first_sentence