From c3506f07eaf79a3c26e00bc6750708323cac4c99 Mon Sep 17 00:00:00 2001
From: Petar Popovic <pjoetri@gmail.com>
Date: Sat, 29 Nov 2025 17:41:30 +0100
Subject: [PATCH] Fix tui new-layout -horizontal argument placement

The optional argument `-horizontal` from `tui new-layout` is supposed
to be checked directly after the command but instead it is checked
after the layout name.
This commit moves the check to the correct place.
---

First time using an email list for patches.
Sorry for the previous "just copy/pasted" patches:
https://sourceware.org/pipermail/gdb-patches/2025-November/222937.html
https://sourceware.org/pipermail/gdb-patches/2025-November/223021.html

 gdb/tui/tui-layout.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/gdb/tui/tui-layout.c b/gdb/tui/tui-layout.c
index 95d20fbf22c..1dcd7086cac 100644
--- a/gdb/tui/tui-layout.c
+++ b/gdb/tui/tui-layout.c
@@ -1207,17 +1207,17 @@ validate_window_name (const std::string &name)
 static void
 tui_new_layout_command (const char *spec, int from_tty)
 {
+  bool is_vertical = true;
+  spec = skip_spaces (spec);
+  if (check_for_argument (&spec, "-horizontal"))
+    is_vertical = false;
+
   std::string new_name = extract_arg (&spec);
   if (new_name.empty ())
     error (_("No layout name specified"));
   if (new_name[0] == '-')
     error (_("Layout name cannot start with '-'"));
 
-  bool is_vertical = true;
-  spec = skip_spaces (spec);
-  if (check_for_argument (&spec, "-horizontal"))
-    is_vertical = false;
-
   std::vector<std::unique_ptr<tui_layout_split>> splits;
   splits.emplace_back (new tui_layout_split (is_vertical));
   gdb::unordered_set<std::string> seen_windows;
--
2.52.0