def window_logic(state, old_state):
    old_window = vimh.window_with_buffer(old_state.buff) if old_state else None

    if not old_state or not old_window:
        window = make_pyunite_window(state, autocmd=True)

    elif ((state.options['vsplit'], state.options['direction']) ==
          (old_state.options['vsplit'], old_state.options['direction'])):
        ui.change_window(old_window, autocmd=True)
        ui.resize_window(state.options['size'] or old_state.options['size'], vsplit=state.options['vsplit'])
        window = old_window

    else:
        ui.change_window(old_window)
        # If bufhidden=wipe, buffer will dissapear when we close its window
        with ui.restore(vim.current.window), misc.scoped(state.buff.options, bufhidden='hide'):
            ui.quit_window()
        window = make_pyunite_window(state, autocmd=True)

    state.options['size'] = window.width if state.options['vsplit'] else window.height
    return window
POST Handler.
dataset/ETHPy150Open azure-satellite/pyunite/pyunite/core.py/window_logic--crossover with--dataset/ETHPy150Open google/simian/src/simian/mac/admin/uploadpkg.py/UploadPackage.post