Repository: CodeEditApp/CodeEdit
File: CodeEdit/Features/Documents/Controllers/CodeEditSplitViewController.swift (Swift)

Code before:
    func saveInspectorCollapsedState(isCollapsed: Bool) {
        workspace.addToWorkspaceState(key: isInspectorCollapsedStateName, value: isCollapsed)
    }

    /// Quick fix for list tracking separator needing to be added again after closing,
    /// then opening the inspector with a drag.
    private func insertToolbarItemIfNeeded() {
        guard !(
            view.window?.toolbar?.items.contains(where: { $0.itemIdentifier == .itemListTrackingSeparator }) ?? true
        ) else {
            return
        }
        view.window?.toolbar?.insertItem(withItemIdentifier: .itemListTrackingSeparator, at: 4)
    }

    /// Quick fix for list tracking separator needing to be removed after closing the inspector with a drag
    private func removeToolbarItemIfNeeded() {
        guard let index = view.window?.toolbar?.items.firstIndex(
                where: { $0.itemIdentifier == .itemListTrackingSeparator }
              ) else {
            return
        }
        view.window?.toolbar?.removeItem(at: index)
    }

    func fixInspectorToolbarBackground() {
        let controller = self.view.window?.perform(Selector(("titlebarViewController"))).takeUnretainedValue()
        if let controller = controller as? NSViewController {
            let effectViewCount = controller.view.subviews.filter { $0 is NSVisualEffectView }.count
            guard effectViewCount > 2 else { return }
            if let view = controller.view.subviews[0] as? NSVisualEffectView {
                view.isHidden = true
            }
        }
    }
}


Review comment (suggestion):
Maybe call this `hideInspectorToolbarBackground` to be more specific?
```suggestion
    func hideInspectorToolbarBackground() {
```

Code after:
    func saveInspectorCollapsedState(isCollapsed: Bool) {
        workspace.addToWorkspaceState(key: isInspectorCollapsedStateName, value: isCollapsed)
    }

    /// Quick fix for list tracking separator needing to be added again after closing,
    /// then opening the inspector with a drag.
    private func insertToolbarItemIfNeeded() {
        guard !(
            view.window?.toolbar?.items.contains(where: { $0.itemIdentifier == .itemListTrackingSeparator }) ?? true
        ) else {
            return
        }
        view.window?.toolbar?.insertItem(withItemIdentifier: .itemListTrackingSeparator, at: 4)
    }

    /// Quick fix for list tracking separator needing to be removed after closing the inspector with a drag
    private func removeToolbarItemIfNeeded() {
        guard let index = view.window?.toolbar?.items.firstIndex(
                where: { $0.itemIdentifier == .itemListTrackingSeparator }
              ) else {
            return
        }
        view.window?.toolbar?.removeItem(at: index)
    }

    func hideInspectorToolbarBackground() {
        let controller = self.view.window?.perform(Selector(("titlebarViewController"))).takeUnretainedValue()
        if let controller = controller as? NSViewController {
            let effectViewCount = controller.view.subviews.filter { $0 is NSVisualEffectView }.count
            guard effectViewCount > 2 else { return }
            if let view = controller.view.subviews[0] as? NSVisualEffectView {
                view.isHidden = true
            }
        }
    }
}