mirror of
https://github.com/neovim/neovim.git
synced 2025-09-06 03:18:16 +00:00
fix(excmd): don't allow range or args for :detach/:restart (#34280)
Also remove the CMDWIN and LOCK_OK flags, so that there is no need to check for text_locked() and curbuf_locked().
This commit is contained in:
@@ -734,7 +734,7 @@ M.cmds = {
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
command = 'detach',
|
command = 'detach',
|
||||||
flags = bit.bor(BANG, FILES, CMDARG, ARGOPT, TRLBAR, CMDWIN, LOCK_OK),
|
flags = TRLBAR,
|
||||||
addr_type = 'ADDR_NONE',
|
addr_type = 'ADDR_NONE',
|
||||||
func = 'ex_detach',
|
func = 'ex_detach',
|
||||||
},
|
},
|
||||||
@@ -2246,6 +2246,12 @@ M.cmds = {
|
|||||||
addr_type = 'ADDR_OTHER',
|
addr_type = 'ADDR_OTHER',
|
||||||
func = 'ex_resize',
|
func = 'ex_resize',
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
command = 'restart',
|
||||||
|
flags = bit.bor(BANG, TRLBAR),
|
||||||
|
addr_type = 'ADDR_NONE',
|
||||||
|
func = 'ex_restart',
|
||||||
|
},
|
||||||
{
|
{
|
||||||
command = 'retab',
|
command = 'retab',
|
||||||
flags = bit.bor(TRLBAR, RANGE, WHOLEFOLD, DFLALL, BANG, WORD1, CMDWIN, LOCK_OK, MODIFY),
|
flags = bit.bor(TRLBAR, RANGE, WHOLEFOLD, DFLALL, BANG, WORD1, CMDWIN, LOCK_OK, MODIFY),
|
||||||
@@ -3368,12 +3374,6 @@ M.cmds = {
|
|||||||
addr_type = 'ADDR_LINES',
|
addr_type = 'ADDR_LINES',
|
||||||
func = 'ex_substitute',
|
func = 'ex_substitute',
|
||||||
},
|
},
|
||||||
{
|
|
||||||
command = 'restart',
|
|
||||||
flags = bit.bor(BANG, FILES, CMDARG, ARGOPT, TRLBAR, CMDWIN, LOCK_OK),
|
|
||||||
addr_type = 'ADDR_NONE',
|
|
||||||
func = 'ex_restart',
|
|
||||||
},
|
|
||||||
-- commands that start with an uppercase letter
|
-- commands that start with an uppercase letter
|
||||||
{
|
{
|
||||||
command = 'Next',
|
command = 'Next',
|
||||||
|
@@ -69,8 +69,6 @@
|
|||||||
#include "nvim/message.h"
|
#include "nvim/message.h"
|
||||||
#include "nvim/mouse.h"
|
#include "nvim/mouse.h"
|
||||||
#include "nvim/move.h"
|
#include "nvim/move.h"
|
||||||
#include "nvim/msgpack_rpc/channel.h"
|
|
||||||
#include "nvim/msgpack_rpc/server.h"
|
|
||||||
#include "nvim/normal.h"
|
#include "nvim/normal.h"
|
||||||
#include "nvim/normal_defs.h"
|
#include "nvim/normal_defs.h"
|
||||||
#include "nvim/ops.h"
|
#include "nvim/ops.h"
|
||||||
@@ -5600,17 +5598,6 @@ static void ex_restart(exarg_T *eap)
|
|||||||
{
|
{
|
||||||
bool forceit = eap && eap->forceit;
|
bool forceit = eap && eap->forceit;
|
||||||
|
|
||||||
// Refuse to restart if text is locked (i.e in command line etc.)
|
|
||||||
if (text_locked()) {
|
|
||||||
text_locked_msg();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Refuse to restart if buffer is locked.
|
|
||||||
if (curbuf_locked()) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
win_T *wp = curwin;
|
win_T *wp = curwin;
|
||||||
|
|
||||||
// If any buffer is changed and not saved, we cannot restart.
|
// If any buffer is changed and not saved, we cannot restart.
|
||||||
|
@@ -108,6 +108,19 @@ describe('TUI :detach', function()
|
|||||||
assert(status)
|
assert(status)
|
||||||
eq(1, #child_uis)
|
eq(1, #child_uis)
|
||||||
|
|
||||||
|
eq(
|
||||||
|
{ false, { 0, 'Vim(detach):E477: No ! allowed: detach!' } },
|
||||||
|
{ child_session:request('nvim_command', 'detach!') }
|
||||||
|
)
|
||||||
|
eq(
|
||||||
|
{ false, { 0, 'Vim(detach):E481: No range allowed: 1detach' } },
|
||||||
|
{ child_session:request('nvim_command', '1detach') }
|
||||||
|
)
|
||||||
|
eq(
|
||||||
|
{ false, { 0, 'Vim(detach):E488: Trailing characters: foo: detach foo' } },
|
||||||
|
{ child_session:request('nvim_command', 'detach foo') }
|
||||||
|
)
|
||||||
|
|
||||||
tt.feed_data('\027\027:detach\013')
|
tt.feed_data('\027\027:detach\013')
|
||||||
-- Note: "Process exited" message is misleading; tt.setup_child_nvim() sees the foreground
|
-- Note: "Process exited" message is misleading; tt.setup_child_nvim() sees the foreground
|
||||||
-- process (client) exited, and doesn't know the server is still running?
|
-- process (client) exited, and doesn't know the server is still running?
|
||||||
@@ -176,14 +189,11 @@ describe('TUI :restart', function()
|
|||||||
]]
|
]]
|
||||||
screen:expect(s0)
|
screen:expect(s0)
|
||||||
|
|
||||||
tt.feed_data(':echo\013')
|
tt.feed_data(':1restart\013')
|
||||||
screen:expect([[
|
screen:expect({ any = vim.pesc('{8:E481: No range allowed}') })
|
||||||
^ |
|
|
||||||
{4:~ }|*3
|
tt.feed_data(':restart foo\013')
|
||||||
{5:[No Name] }|
|
screen:expect({ any = vim.pesc('{8:E488: Trailing characters: foo}') })
|
||||||
|
|
|
||||||
{3:-- TERMINAL --} |
|
|
||||||
]])
|
|
||||||
|
|
||||||
-- Check ":restart" on an unmodified buffer.
|
-- Check ":restart" on an unmodified buffer.
|
||||||
tt.feed_data(':restart\013')
|
tt.feed_data(':restart\013')
|
||||||
|
Reference in New Issue
Block a user