mirror of
https://github.com/RooVetGit/Roo-Code.git
synced 2026-08-28 05:27:24 +00:00
Better logic for choosing the view column when opening Roo in a tab (#2282)
* Better logic for choosing the view column when opening Roo in a tab * PR feedback
This commit is contained in:
parent
5ef0a6a8ce
commit
7eea755703
1 changed files with 15 additions and 7 deletions
|
|
@ -123,17 +123,25 @@ export const openClineInNewTab = async ({ context, outputChannel }: Omit<Registe
|
|||
// don't need to use that event).
|
||||
// https://github.com/microsoft/vscode-extension-samples/blob/main/webview-sample/src/extension.ts
|
||||
const tabProvider = new ClineProvider(context, outputChannel, "editor")
|
||||
const lastCol = Math.max(...vscode.window.visibleTextEditors.map((editor) => editor.viewColumn || 0))
|
||||
|
||||
// Check if there are any visible text editors, otherwise open a new group
|
||||
// to the right.
|
||||
const activeEditor = vscode.window.activeTextEditor
|
||||
const hasVisibleEditors = vscode.window.visibleTextEditors.length > 0
|
||||
|
||||
if (!hasVisibleEditors) {
|
||||
await vscode.commands.executeCommand("workbench.action.newGroupRight")
|
||||
}
|
||||
let targetCol: vscode.ViewColumn
|
||||
|
||||
const targetCol = hasVisibleEditors ? Math.max(lastCol + 1, 1) : vscode.ViewColumn.Two
|
||||
if (!hasVisibleEditors) {
|
||||
// No editors open, open in first column
|
||||
targetCol = vscode.ViewColumn.One
|
||||
} else if (activeEditor && activeEditor.document.isUntitled && vscode.window.visibleTextEditors.length === 1) {
|
||||
// Only one editor and it's empty (untitled), reuse it
|
||||
targetCol = activeEditor.viewColumn ?? vscode.ViewColumn.One
|
||||
} else {
|
||||
// Otherwise, create a new group to the right
|
||||
await vscode.commands.executeCommand("workbench.action.newGroupRight")
|
||||
// New group becomes the last + 1
|
||||
const lastCol = Math.max(...vscode.window.visibleTextEditors.map((e) => e.viewColumn || 1))
|
||||
targetCol = (lastCol + 1) as vscode.ViewColumn
|
||||
}
|
||||
|
||||
const newPanel = vscode.window.createWebviewPanel(ClineProvider.tabPanelId, "Roo Code", targetCol, {
|
||||
enableScripts: true,
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue