chore: make tab indexes 0-based (#674)

Fixes https://github.com/microsoft/playwright-mcp/issues/570
This commit is contained in:
Pavel Feldman
2025-07-16 09:55:08 -07:00
committed by GitHub
parent a5a57df105
commit da818d113a
2 changed files with 20 additions and 20 deletions

View File

@@ -101,7 +101,7 @@ export class Context {
}
async selectTab(index: number) {
this._currentTab = this._tabs[index - 1];
this._currentTab = this._tabs[index];
await this._currentTab.page.bringToFront();
}
@@ -121,13 +121,13 @@ export class Context {
const title = await tab.title();
const url = tab.page.url();
const current = tab === this._currentTab ? ' (current)' : '';
lines.push(`- ${i + 1}:${current} [${title}] (${url})`);
lines.push(`- ${i}:${current} [${title}] (${url})`);
}
return lines.join('\n');
}
async closeTab(index: number | undefined) {
const tab = index === undefined ? this._currentTab : this._tabs[index - 1];
const tab = index === undefined ? this._currentTab : this._tabs[index];
await tab?.page.close();
return await this.listTabsMarkdown();
}