@@ -123,26 +123,18 @@ export const openClineInNewTab = async ({ context, outputChannel }: Omit<Registe
123123 // don't need to use that event).
124124 // https://github.com/microsoft/vscode-extension-samples/blob/main/webview-sample/src/extension.ts
125125 const tabProvider = new ClineProvider ( context , outputChannel , "editor" )
126+ const lastCol = Math . max ( ...vscode . window . visibleTextEditors . map ( ( editor ) => editor . viewColumn || 0 ) )
126127
127- const activeEditor = vscode . window . activeTextEditor
128+ // Check if there are any visible text editors, otherwise open a new group
129+ // to the right.
128130 const hasVisibleEditors = vscode . window . visibleTextEditors . length > 0
129131
130- let targetCol : vscode . ViewColumn
131-
132132 if ( ! hasVisibleEditors ) {
133- // No editors open, open in first column
134- targetCol = vscode . ViewColumn . One
135- } else if ( activeEditor && activeEditor . document . isUntitled && vscode . window . visibleTextEditors . length === 1 ) {
136- // Only one editor and it's empty (untitled), reuse it
137- targetCol = activeEditor . viewColumn ?? vscode . ViewColumn . One
138- } else {
139- // Otherwise, create a new group to the right
140133 await vscode . commands . executeCommand ( "workbench.action.newGroupRight" )
141- // New group becomes the last + 1
142- const lastCol = Math . max ( ...vscode . window . visibleTextEditors . map ( ( e ) => e . viewColumn || 1 ) )
143- targetCol = ( lastCol + 1 ) as vscode . ViewColumn
144134 }
145135
136+ const targetCol = hasVisibleEditors ? Math . max ( lastCol + 1 , 1 ) : vscode . ViewColumn . Two
137+
146138 const newPanel = vscode . window . createWebviewPanel ( ClineProvider . tabPanelId , "Roo Code" , targetCol , {
147139 enableScripts : true ,
148140 retainContextWhenHidden : true ,
0 commit comments