Skip to content

Comments

Replace spaces with dashes when naming branches#88

Open
zachrammell wants to merge 1 commit intojorio:masterfrom
zachrammell:branch-naming
Open

Replace spaces with dashes when naming branches#88
zachrammell wants to merge 1 commit intojorio:masterfrom
zachrammell:branch-naming

Conversation

@zachrammell
Copy link
Contributor

@zachrammell zachrammell commented Feb 23, 2026

This is a small quality-of-life change to make using the New Branch and Rename Branch menus feel more natural. Since spaces in branch names are invalid, this will interactively replace spaces with dashes while typing, ensuring that the input remains valid.

@jorio
Copy link
Owner

jorio commented Feb 24, 2026

Good idea, and I appreciate the test!

I suggest installing a QValidator into the QLineEdit. This way we don't need to fiddle with the cursor.

class ReplaceSpacesWithDashes(QValidator):
    def validate(self, text: str, pos: int) -> tuple[QValidator.State, str, int]:
        text = text.replace(" ", "-")
        return QValidator.State.Acceptable, text, pos

...
...nameEdit.setValidator(...)

Also, please avoid editing ui_newbranchdialog.py, because it's automatically generated from newbranchdialog.ui, so any manual changes may be overwritten in the future (after I edit a form in Qt Designer, I regenerate the ui_*.py files in bulk with update_resources.py --ui).

Feel free to connect any signals/validators in newbranchdialog.py instead!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants