From b7c5540075bb4a0b358e0ce88d1f340195797de4 Mon Sep 17 00:00:00 2001 From: 5brian Date: Tue, 27 May 2025 13:10:20 -0400 Subject: [PATCH] git_ui: Replace spaces with hyphens in new branch names (#27873) This PR improves UX by converting spaces to hyphens, following branch naming conventions and allowing users to create branches without worrying about naming restrictions. I think a few other git tools do this, which was nice. ![image](https://github.com/user-attachments/assets/db40ec31-e461-4ab3-a3de-e249559994fc) Release Notes: - Updated the branch picker to convert spaces to hyphens when creating new branch names. --------- Co-authored-by: Marshall Bowers --- crates/git_ui/src/branch_picker.rs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/crates/git_ui/src/branch_picker.rs b/crates/git_ui/src/branch_picker.rs index aaa69373636a3c0dfd01bdb823f4cfcb70f323a5..5f51f8e2db87703d8c05acb2773dab5f7af1d91d 100644 --- a/crates/git_ui/src/branch_picker.rs +++ b/crates/git_ui/src/branch_picker.rs @@ -221,6 +221,7 @@ impl BranchListDelegate { let Some(repo) = self.repo.clone() else { return; }; + let new_branch_name = new_branch_name.to_string().replace(' ', "-"); cx.spawn(async move |_, cx| { repo.update(cx, |repo, _| { repo.create_branch(new_branch_name.to_string()) @@ -325,6 +326,7 @@ impl PickerDelegate for BranchListDelegate { .first() .is_some_and(|entry| entry.branch.name() == query) { + let query = query.replace(' ', "-"); matches.push(BranchEntry { branch: Branch { ref_name: format!("refs/heads/{query}").into(),