mirror of
https://github.com/neovim/neovim.git
synced 2025-09-21 18:58:18 +00:00
window: simplify logic for entering new float
This commit is contained in:
@@ -15,6 +15,7 @@
|
|||||||
#include "nvim/api/private/defs.h"
|
#include "nvim/api/private/defs.h"
|
||||||
#include "nvim/api/private/dispatch.h"
|
#include "nvim/api/private/dispatch.h"
|
||||||
#include "nvim/api/buffer.h"
|
#include "nvim/api/buffer.h"
|
||||||
|
#include "nvim/api/window.h"
|
||||||
#include "nvim/msgpack_rpc/channel.h"
|
#include "nvim/msgpack_rpc/channel.h"
|
||||||
#include "nvim/msgpack_rpc/helpers.h"
|
#include "nvim/msgpack_rpc/helpers.h"
|
||||||
#include "nvim/lua/executor.h"
|
#include "nvim/lua/executor.h"
|
||||||
@@ -1049,7 +1050,6 @@ Window nvim_open_win(Buffer buffer, Boolean enter,
|
|||||||
Dictionary options, Error *err)
|
Dictionary options, Error *err)
|
||||||
FUNC_API_SINCE(6)
|
FUNC_API_SINCE(6)
|
||||||
{
|
{
|
||||||
win_T *old = curwin;
|
|
||||||
FloatConfig config = FLOAT_CONFIG_INIT;
|
FloatConfig config = FLOAT_CONFIG_INIT;
|
||||||
if (!parse_float_config(options, &config, false, err)) {
|
if (!parse_float_config(options, &config, false, err)) {
|
||||||
return 0;
|
return 0;
|
||||||
@@ -1058,11 +1058,11 @@ Window nvim_open_win(Buffer buffer, Boolean enter,
|
|||||||
if (!wp) {
|
if (!wp) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
if (buffer > 0) {
|
if (enter) {
|
||||||
nvim_set_current_buf(buffer, err);
|
win_enter(wp, false);
|
||||||
}
|
}
|
||||||
if (!enter) {
|
if (buffer > 0) {
|
||||||
win_enter(old, false);
|
nvim_win_set_buf(wp->handle, buffer, err);
|
||||||
}
|
}
|
||||||
return wp->handle;
|
return wp->handle;
|
||||||
}
|
}
|
||||||
|
@@ -541,9 +541,7 @@ static void cmd_with_count(char *cmd, char_u *bufp, size_t bufsize,
|
|||||||
win_T *win_new_float(win_T *wp, int width, int height, FloatConfig config,
|
win_T *win_new_float(win_T *wp, int width, int height, FloatConfig config,
|
||||||
Error *err)
|
Error *err)
|
||||||
{
|
{
|
||||||
bool new = false;
|
|
||||||
if (wp == NULL) {
|
if (wp == NULL) {
|
||||||
new = true;
|
|
||||||
wp = win_alloc(lastwin_nofloating(), false);
|
wp = win_alloc(lastwin_nofloating(), false);
|
||||||
win_init(wp, curwin, 0);
|
win_init(wp, curwin, 0);
|
||||||
} else {
|
} else {
|
||||||
@@ -572,9 +570,6 @@ win_T *win_new_float(win_T *wp, int width, int height, FloatConfig config,
|
|||||||
win_config_float(wp, width, height, config);
|
win_config_float(wp, width, height, config);
|
||||||
wp->w_pos_changed = true;
|
wp->w_pos_changed = true;
|
||||||
redraw_win_later(wp, VALID);
|
redraw_win_later(wp, VALID);
|
||||||
if (new) {
|
|
||||||
win_enter(wp, false);
|
|
||||||
}
|
|
||||||
return wp;
|
return wp;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user