Repository: CodeEditApp/CodeEdit
File: CodeEdit/TabBar/TabBarItem.swift (Swift)

Code before:
        .contentShape(Rectangle())
        .onHover { hover in
            isHovering = hover
            DispatchQueue.main.async {
                if hover {
                    NSCursor.arrow.push()
                } else {
                    NSCursor.pop()
                }
            }
        }
    }

    var body: some View {
        Button(
            action: switchAction,
            label: { content }
        )
        .buttonStyle(TabBarItemButtonStyle())
        .background {
            if prefs.preferences.general.tabBarStyle == .xcode {
                Color(nsColor: isActive ? .selectedControlColor : .clear)
                    .opacity(
                        colorScheme == .dark
                        ? (activeState != ControlActiveState.inactive ? 0.70 : 0.50)
                        : (activeState != ControlActiveState.inactive ? 0.50 : 0.35)
                    )
                    .background(
                        // This layer of background is to hide dividers of other tab bar items
                        // because the original background above is translucent (by opacity).
                        Color(nsColor: .controlBackgroundColor)
                    )
                    .animation(.easeInOut(duration: 0.08), value: isHovering)
            } else {
                EffectView(
                    NSVisualEffectView.Material.titlebar,
                    blendingMode: NSVisualEffectView.BlendingMode.withinWindow
                )
                .background(
                    // This background is used to avoid color-split between title bar and tab bar.
                    // The material will tint the color hind, which will result in a color-split.
                    Color(nsColor: .controlBackgroundColor)
                )
                .overlay {
                    if !isActive {
                        ZStack {
                            // Native inactive tab background dim.
                            Color(nsColor: .black)
                                .opacity(colorScheme == .dark ? 0.50 : 0.05)

                            // Native inactive tab hover state.

Review comment (suggestion):
just use `.inactive` since Swift implicitly gets the Type.

Code after:
        .padding(
            // This padding is to avoid background color overlapping with top divider.
            .top, prefs.preferences.general.tabBarStyle == .xcode ? 1 : 0
        )
        .offset(
            x: isAppeared || prefs.preferences.general.tabBarStyle == .native ? 0 : -14,
            y: 0
        )
        .opacity(isAppeared ? 1.0 : 0.0)
        .zIndex(isActive ? 1 : 0)
        .onAppear {
            withAnimation(.easeOut(duration: 0.20)) {
                isAppeared = true
            }
        }
        .id(item.id)
        .contextMenu {
            Button("Close Tab") {
                withAnimation {
                    workspace.closeFileTab(item: item)
                }
            }
            Button("Close Other Tabs") {
                withAnimation {
                    workspace.closeFileTab(where: { $0.id != item.id })
                }
            }
            Button("Close Tabs to the Right") {
                withAnimation {
                    workspace.closeFileTabs(after: item)
                }
            }
        }
    }
}

fileprivate extension WorkspaceDocument {
    func getTabKeyEquivalent(item: WorkspaceClient.FileItem) -> KeyEquivalent {
        for counter in 0..<9 where self.selectionState.openFileItems.count > counter &&
        self.selectionState.openFileItems[counter].fileName == item.fileName {
            return KeyEquivalent.init(
                Character.init("\(counter + 1)")
            )
        }
        return "0"
    }
}

private struct TabBarItemButtonStyle: ButtonStyle {
    @Environment(\.colorScheme)
    var colorScheme