From 68b63427c627edf6df9b5e0d3c6aa12476f11a91 Mon Sep 17 00:00:00 2001 From: Ruoyu Zhong Date: Tue, 4 Apr 2023 18:39:13 +0800 Subject: [PATCH] commands: fix completion descriptions Currently, zsh and fish shell completions show incomplete descriptions for certain commands. For example: docs -- Open Homebrew's online documentation (https://docs rbenv-sync -- Create symlinks for Homebrew's installed Ruby versions in ~/ This is because `Commands.command_description` produces incomplete short descriptions for the commands having a dot (from a URL or a path) in the first sentence; the dot is misinterpreted as a full stop: brew(main):001:0> Commands.command_description("docs", short: true) => "Open Homebrew's online documentation (https://docs" brew(main):002:0> Commands.command_description("rbenv-sync", short: true) => "Create symlinks for Homebrew's installed Ruby versions in ~/" We can improve the sentence splitting logic by only splitting at dots either at the end or followed by a whitespace. Now With this change: brew(main):001:0> Commands.command_description("docs", short: true) => "Open Homebrew's online documentation (https://docs.brew.sh) in a browser" brew(main):002:0> Commands.command_description("rbenv-sync", short: true) => "Create symlinks for Homebrew's installed Ruby versions in ~/.rbenv/versions" Signed-off-by: Ruoyu Zhong --- Library/Homebrew/commands.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Library/Homebrew/commands.rb b/Library/Homebrew/commands.rb index 538cf036db..8eccbb1c86 100644 --- a/Library/Homebrew/commands.rb +++ b/Library/Homebrew/commands.rb @@ -203,7 +203,7 @@ module Commands if (cmd_parser = Homebrew::CLI::Parser.from_cmd_path(path)) if short - cmd_parser.description.split(".").first + cmd_parser.description.split(/\.(?>\s|$)/).first else cmd_parser.description end