commit 7d1eea0301986c6f7a080bfaf8166d051aa71f05
Author: Scott Kostyshak <[email protected]>
Date: Mon Mar 24 12:37:05 2025 +0100
Give error if adding a branch that already exists
The previous behavior was a silent no-op. Now, we inform the user
that the branch name already exists, and preserve the field text so
it can be easily modified after the message.
---
src/frontends/qt/GuiBranches.cpp | 12 +++++++++++-
1 file changed, 11 insertions(+), 1 deletion(-)
diff --git a/src/frontends/qt/GuiBranches.cpp b/src/frontends/qt/GuiBranches.cpp
index 710d01c1e5..8f67ebb8bb 100644
--- a/src/frontends/qt/GuiBranches.cpp
+++ b/src/frontends/qt/GuiBranches.cpp
@@ -184,7 +184,17 @@ void GuiBranches::on_newBranchLE_textChanged(QString)
void GuiBranches::on_addBranchPB_pressed()
{
QString const new_branch = newBranchLE->text();
- branchlist_.add(qstring_to_ucs4(new_branch));
+ docstring const new_branch_ds = qstring_to_ucs4(new_branch);
+
+ if (branchlist_.find(new_branch_ds)) {
+ docstring text = support::bformat(
+ _("A branch with the name \"%1$s\" already exists."),
+ new_branch_ds);
+ frontend::Alert::error(_("Branch already exists"), text);
+ return;
+ }
+
+ branchlist_.add(new_branch_ds);
newBranchLE->clear();
addBranchPB->setEnabled(false);
--
lyx-cvs mailing list
[email protected]
https://lists.lyx.org/mailman/listinfo/lyx-cvs