         
         super.tabView(tabView, willSelect: tabViewItem)
         
-        if let frame = self.lastFrame {
-            tabView.selectedTabViewItem?.view?.frame = frame
-        }
-        
-        self.lastFrame = tabViewItem?.view?.frame
+        self.lastFrameSize = tabViewItem?.view?.frame.size
     }
     
     

    /// resize window to fit to new view
    private func switchPane(to tabViewItem: NSTabViewItem) {
        
        guard let viewFrame = self.lastFrame ?? tabViewItem.view?.frame else { return assertionFailure() }
        
        // initialize tabView's frame size
        guard let window = self.view.window else {
            self.view.frame = viewFrame
            return
        }
        
        // calculate window frame
        var frame = window.frameRect(forContentRect: viewFrame)
        frame.origin = window.frame.origin
        frame.origin.y += window.frame.height - frame.height
        
        self.view.isHidden = true
        NSAnimationContext.runAnimationGroup({ _ in
            window.animator().setFrame(frame, display: false)
            
        }, completionHandler: { [weak self] in
            self?.view.isHidden = false


final class PreferencesTabViewController: NSTabViewController {
    
    private var lastFrameSize: NSSize?
    
    
    
