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.  Release Notes: - Updated the branch picker to convert spaces to hyphens when creating new branch names. --------- Co-authored-by: Marshall Bowers <git@maxdeviant.com>
This commit is contained in:
parent
b01f7c848b
commit
b7c5540075
1 changed files with 2 additions and 0 deletions
|
@ -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(),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue