Skip to content

Commit 047b249

Browse files
committed
fix(man): Finding git man page link opportunities
When finding opportunities to create links to git man pages, text of the form "... git-command(1)." or "... git-command(1)," were missed because of the trailing punctuation. These cases are now accounted for correctly. N.B. this repair does not currently affect any generated documents.
1 parent d9e2ce9 commit 047b249

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

src/cmd/completion/man.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -392,14 +392,14 @@ fn make_links(text: &str) -> String {
392392
let mut words = text.split_inclusive(|c| c == ' ' || c == '\n');
393393

394394
while let Some(word) = words.next() {
395-
if word.starts_with("git-") && word.trim_end().ends_with(')') {
396-
let (stuff, trailing_ws) = word.rsplit_once(')').unwrap();
397-
if let Some((command, man_section)) =
398-
stuff.strip_prefix("git-").unwrap().split_once('(')
399-
{
400-
let link = format!("linkgit:git-{command}[{man_section}]");
401-
output.push_str(&link);
402-
output.push_str(trailing_ws);
395+
if let Some(remainder) = word.strip_prefix("git-") {
396+
if let Some((command_and_section, trailings)) = remainder.rsplit_once(')') {
397+
if let Some((command, man_section)) = command_and_section.split_once('(') {
398+
output.push_str(&format!("linkgit:git-{command}[{man_section}]"));
399+
output.push_str(trailings);
400+
} else {
401+
output.push_str(word);
402+
}
403403
} else {
404404
output.push_str(word);
405405
}

0 commit comments

Comments
 (0)