Skip to content
This repository was archived by the owner on Apr 1, 2020. It is now read-only.

Commit adf404a

Browse files
rgehanbryphe
authored andcommitted
Fix tabs so that they use the correct id when closing/focusing (#1761)
* Fix tabs so that they use the correct id when closing/focusing * Add integration test for opening/closing tabs with tabs.modes set to tabs
1 parent f06c25b commit adf404a

File tree

4 files changed

+50
-1
lines changed

4 files changed

+50
-1
lines changed

browser/src/UI/components/Tabs.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -303,7 +303,7 @@ const getTabsFromVimTabs = createSelector(
303303
allBuffers: State.IBuffer[],
304304
) => {
305305
return tabState.tabs.map((t: State.ITab, idx: number) => ({
306-
id: t.id,
306+
id: idx + 1,
307307
name: getIdPrefix((idx + 1).toString(), shouldShowId) + getTabName(t.name),
308308
highlightColor: t.id === tabState.selectedTabId ? color : "transparent",
309309
iconFileName: showFileIcon ? getTabName(t.name) : "",

test/CiTests.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ const CiTests = [
2626
"Editor.BufferModifiedState",
2727
"Editor.OpenFile.PathWithSpacesTest",
2828
"Editor.TabModifiedState",
29+
"Editor.CloseTabWithTabModesTabsTest",
2930
"MarkdownPreviewTest",
3031
"PaintPerformanceTest",
3132
"QuickOpenTest",

test/ci/Common.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,11 @@ export const getElementByClassName = (className: string) => {
2222
}
2323
}
2424

25+
export const getElementsBySelector = (selector: string) => {
26+
const elements = document.body.querySelectorAll(selector)
27+
return elements || []
28+
}
29+
2530
export const createNewFile = async (
2631
fileExtension: string,
2732
oni: Oni.Plugin.Api,
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
import * as assert from "assert"
2+
import * as Oni from "oni-api"
3+
4+
import { getElementsBySelector } from "./Common"
5+
6+
export const test = async (oni: Oni.Plugin.Api) => {
7+
const getTabsCount = () => getElementsBySelector(".tabs .tab").length
8+
const waitForTabCount = count => oni.automation.waitFor(() => getTabsCount() === count)
9+
10+
const openTab = () => {
11+
const initialTabCount = getTabsCount()
12+
oni.automation.sendKeys(":tabnew")
13+
oni.automation.sendKeys("<cr>")
14+
return waitForTabCount(initialTabCount + 1)
15+
}
16+
17+
const closeLastTabWithMouse = () => {
18+
const tabs = getElementsBySelector(".tabs .tab")
19+
const closeButton = tabs[tabs.length - 1].querySelector(".corner.enable-hover")
20+
closeButton.click()
21+
return waitForTabCount(tabs.length - 1)
22+
}
23+
24+
await oni.automation.waitForEditors()
25+
26+
// 1. Create two tabs, then close the last on
27+
await openTab()
28+
await openTab()
29+
await closeLastTabWithMouse()
30+
31+
// 3. Open another tab
32+
await openTab()
33+
34+
// 4.1 Attempt to close it
35+
await closeLastTabWithMouse()
36+
}
37+
38+
// Bring in custom config.
39+
export const settings = {
40+
config: {
41+
"tabs.mode": "tabs",
42+
},
43+
}

0 commit comments

Comments
 (0)