

def window_logic(state, old_state):
    '\n    Window create/resize logic. The function name is not very good :(\n\n      new_state  |   old_state   | same directions | same size |  action\n    -------------|---------------|-----------------|-----------|-----------\n      vertical   |    vertical   |      True       |   True    |  reuse\n      vertical   |    vertical   |      True       |   False   |  resize\n      vertical   |    vertical   |      False      |   True    |  close old; create\n      vertical   |    vertical   |      False      |   False   |  close old; create\n      vertical   |   horizontal  |      True       |   True    |  close old; create\n      vertical   |   horizontal  |      True       |   False   |  close old; create\n      vertical   |   horizontal  |      False      |   True    |  close old; create\n      vertical   |   horizontal  |      False      |   False   |  close old; create\n     horizontal  |    vertical   |      True       |   True    |  close old; create\n     horizontal  |    vertical   |      True       |   False   |  close old; create\n     horizontal  |    vertical   |      False      |   True    |  close old; create\n     horizontal  |    vertical   |      False      |   False   |  close old; create\n     horizontal  |   horizontal  |      True       |   True    |  reuse\n     horizontal  |   horizontal  |      True       |   False   |  resize\n     horizontal  |   horizontal  |      False      |   True    |  close old; create\n     horizontal  |   horizontal  |      False      |   False   |  close old; create\n    '
    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)
        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

dataset/ETHPy150Open azure-satellite/pyunite/pyunite/core.py window_logic/original