Repository: microsoft/terminal (language: cpp)

Issue:
Introduce an option to configure where duplicated tabs open
> Hi, I know this issue is closed, but I actually find it annoying. I liked that duplicate tabs would open at the end... not next to the one that is duplicated. Can you please provide setting, where this can be changed between two options?

_Originally posted by @noheromen in https://github.com/microsoft/terminal/issues/14521#issuecomment-1654527281_
            


Discussion / hints:
Discussed as a team. We should make duplicate tab respect the existing setting to open new tabs at the current index or at the end of the list.
Hey I would like to work on this issue , please assign me 
Hi @carlos-zamora, asking this just for my own clarity..we need to make the duplicate tab consider the existing setting called '**Position of newly created tabs**', right? If yes, then perhaps we can rename it to **'Position of newly created or duplicated tabs'** if that seems appropriate.
![Screenshot 2023-09-14 003444](https://github.com/microsoft/terminal/assets/25024714/00a10123-982f-4cb9-b5a1-ee1a411736ae)


Fix patch:
diff --git a/src/cascadia/TerminalApp/TabManagement.cpp b/src/cascadia/TerminalApp/TabManagement.cpp
index 02bd8940746..9e4ddbe9996 100644
--- a/src/cascadia/TerminalApp/TabManagement.cpp
+++ b/src/cascadia/TerminalApp/TabManagement.cpp
@@ -301,7 +301,12 @@ namespace winrt::TerminalApp::implementation
             // In the future, it may be preferable to just duplicate the
             // current control's live settings (which will include changes
             // made through VT).
-            _CreateNewTabFromPane(_MakePane(nullptr, tab, nullptr), tab.TabViewIndex() + 1);
+            uint32_t insertPosition = _tabs.Size();
+            if (_settings.GlobalSettings().NewTabPosition() == NewTabPosition::AfterCurrentTab)
+            {
+                insertPosition = tab.TabViewIndex() + 1;
+            }
+            _CreateNewTabFromPane(_MakePane(nullptr, tab, nullptr), insertPosition);
 
             const auto runtimeTabText{ tab.GetTabText() };
             if (!runtimeTabText.empty())


Test patch: