New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[RDY] Add v:exiting #5651

Merged
merged 2 commits into from Dec 1, 2016

Conversation

Projects
None yet
4 participants
@mhinz
Member

mhinz commented Nov 22, 2016

Contains the exit value nvim will use.

Before exiting, it is v:null. That way jobs or autocmds (in VimLeavePre or VimLeave)
can check if Neovim is about to quit and with what exit value.

Ref: #4666


Potential use case: mhinz/neovim-remote#27

@marvim marvim added the RFC label Nov 22, 2016

@justinmk

This comment has been minimized.

Member

justinmk commented Nov 24, 2016

There are more cases to handle, right? And tests needed. Possibly bike-shedding on the name as well :>

@mhinz

This comment has been minimized.

Member

mhinz commented Nov 24, 2016

There are more cases to handle, right?

Maybe, maybe not. ;] That's the problem when exiting happens in various places. But as far as I see, getout() seems to be the main means to exit with != 0.

And tests needed.

What would be the proper path for the tests?

Possibly bike-shedding on the name as well :>

I'm open to suggestions! Although I think retval is a typical variable name in C and so exitval (as in "retval on exit") would make sense, too. (FWIW, getout() is using the variable exitval as well.)

@mhinz mhinz changed the title from [RFC] Add v:exitval to [RFC] Add v:exiting Nov 28, 2016

@mhinz mhinz force-pushed the mhinz:vv/exitval branch 6 times, most recently from 4273934 to 94d55b6 Nov 29, 2016

@mhinz mhinz changed the title from [RFC] Add v:exiting to [RDY] Add v:exiting Nov 30, 2016

@mhinz mhinz force-pushed the mhinz:vv/exitval branch from 94d55b6 to 687289f Nov 30, 2016

@marvim marvim added RDY and removed RFC labels Nov 30, 2016

@mhinz mhinz force-pushed the mhinz:vv/exitval branch from 687289f to 78393ec Dec 1, 2016

@mhinz

This comment has been minimized.

Member

mhinz commented Dec 1, 2016

Rebased against the latest conflicts.. If no one has suggestions anymore, I'll merge this later today.

@mhinz mhinz force-pushed the mhinz:vv/exitval branch from 78393ec to 0816c0f Dec 1, 2016

@@ -394,6 +394,7 @@ static struct vimvar {
VV(VV_TYPE_DICT, "t_dict", VAR_NUMBER, VV_RO),
VV(VV_TYPE_FLOAT, "t_float", VAR_NUMBER, VV_RO),
VV(VV_TYPE_BOOL, "t_bool", VAR_NUMBER, VV_RO),
VV(VV_EXITING, "exiting", VAR_SPECIAL, VV_RO),

This comment has been minimized.

@justinmk

justinmk Dec 1, 2016

Member

for clarity, declare it as VAR_NUMBER?

This comment has been minimized.

@mhinz

mhinz Dec 1, 2016

Member

Done.

@@ -17769,6 +17771,8 @@ void set_vcount(long count, long count1, int set_prevcount)
/// @param[in] val Value to set to.
void set_vim_var_nr(const VimVarIndex idx, const varnumber_T val)
{
clear_tv(&vimvars[idx].vv_tv);
vimvars[idx].vv_type = VAR_NUMBER;

This comment has been minimized.

@justinmk

justinmk Dec 1, 2016

Member

similar change needed in set_vim_var_special

This comment has been minimized.

@mhinz

mhinz Dec 1, 2016

Member

Done.

@mhinz mhinz force-pushed the mhinz:vv/exitval branch from 0816c0f to a803240 Dec 1, 2016

*v:exiting* *exiting-variable*
v:exiting The exit value nvim will use. Before exiting, it is |v:null|.
That way jobs or autocmds (in |VimLeavePre| or |VimLeave|) can
check if Neovim is about to quit and with what exit value.

This comment has been minimized.

@justinmk

justinmk Dec 1, 2016

Member
Normally v:null. When Nvim quits (just before |VimLeavePre|) it holds the exit code.

I would leave out the discussion of jobs/autocmds.

run(on_request, nil, on_setup)
end)
it('is greater than 0 on abnormal exit', function()

This comment has been minimized.

@justinmk

justinmk Dec 1, 2016

Member
it('is non-zero after :cquit', function()

Not sure if :cquit is considered abnormal. But anyways it's documented to return non-zero, not necessarily greater than zero.

@mhinz mhinz force-pushed the mhinz:vv/exitval branch from a803240 to 0be0ef8 Dec 1, 2016

it('is 0 on normal exit', function()
local function on_setup()
command('autocmd VimLeavePre * call rpcrequest('..cid..', "")')
command('autocmd VimLeave * call rpcrequest('..cid..', "")')

This comment has been minimized.

@justinmk

justinmk Dec 1, 2016

Member

I would suggest omitting the VimLeave autocmd, it makes the test unclear. Because it never gets run tested. Maybe an additional test for VimLeave also would be worth having.

This comment has been minimized.

@justinmk

justinmk Dec 1, 2016

Member

Another possible test: what happens if VimLeavePre calls :cquit, after :qall triggered VimLeavePre?

This comment has been minimized.

@mhinz

mhinz Dec 1, 2016

Member

Both autocmds fire and get asserted.

@mhinz mhinz force-pushed the mhinz:vv/exitval branch from 0be0ef8 to d17259c Dec 1, 2016

command('cquit')
end
local function on_request()
assert(eval('v:exiting') > 0)

This comment has been minimized.

@justinmk

justinmk Dec 1, 2016

Member

should only test non-zero

This comment has been minimized.

@mhinz

mhinz Dec 1, 2016

Member

Okay, I change it to neq(0, eval('v:exiting')). ;-)

end)
it('defaults to v:null', function()
assert(eval('v:exiting is v:null'))

This comment has been minimized.

@justinmk

justinmk Dec 1, 2016

Member

should test for 1 explicitly.

eq(1, eval('v:exiting is v:null')))

This comment has been minimized.

@mhinz

mhinz Dec 1, 2016

Member

Okay, I change it to neq(0, eval('v:exiting')).

This comment has been minimized.

@justinmk

justinmk Dec 1, 2016

Member

Oh. Why? It's good to test for v:null explicitly, as you already had it.

eq(1, eval('v:exiting is v:null')))

only adds additional constraint than eval() is not returning a dict or something like that.

This is a different request than #5651 (comment)

This comment has been minimized.

@mhinz

mhinz Dec 1, 2016

Member

Argh, I commented for the wrong line. I meant to apply the change you suggested to
assert(eval('v:exiting') ~= 0) (last test) as well. So neq(0, eval('v'exiting')). Sorry for the confusion.

This comment has been minimized.

@justinmk

justinmk Dec 1, 2016

Member

Also, reminder than assert(0) succeeds in lua because 0 is truthy ;)

@@ -1383,6 +1383,9 @@ v:dying Normally zero. When a deadly signal is caught it's set to
< Note: if another deadly signal is caught when v:dying is one,
VimLeave autocommands will not be executed.
*v:exiting* *exiting-variable*
v:exiting The exit value nvim will use. Before exiting, it is |v:null|.

This comment has been minimized.

@justinmk

justinmk Dec 1, 2016

Member

Nvim should be capitalized, else the other docs are inconsistent.

@mhinz mhinz force-pushed the mhinz:vv/exitval branch from d17259c to 26e958e Dec 1, 2016

@justinmk

justinmk requested changes Dec 1, 2016 edited

v:null test #5651 (comment)

mhinz added some commits Nov 22, 2016

Add v:exiting
Contains the exit value nvim will use.

Before exiting, it is v:null. That way jobs or autocmds (in VimLeavePre or
VimLeave) can check if Neovim is about to quit and with what exit value.

Closes #4666.

@mhinz mhinz force-pushed the mhinz:vv/exitval branch from 26e958e to df2ffe4 Dec 1, 2016

@mhinz mhinz merged commit d2e8c76 into neovim:master Dec 1, 2016

0 of 3 checks passed

QuickBuild Build pr-5651 is started
Details
continuous-integration/appveyor/pr Waiting for AppVeyor build to complete
Details
continuous-integration/travis-ci/pr The Travis CI build is in progress
Details

@jszakmeister jszakmeister removed the RDY label Dec 1, 2016

@mhinz mhinz deleted the mhinz:vv/exitval branch Dec 9, 2016

justinmk added a commit to justinmk/neovim that referenced this pull request May 1, 2017

NVIM v0.2.0
FEATURES:
    bc4a2e1 help, man.vim: "outline" (TOC) feature neovim#5169
    58422f1 'guicursor' works in the TUI (and sends info to UIs) neovim#6423
    129f107 api: nvim_get_mode() neovim#6247
    0b59f98 api/ui: externalize tabline neovim#6583
    bc6d868 'listchars': `Whitespace` highlight group neovim#6367
    6afa7d6 writefile() obeys 'fsync' option neovim#6427
    c60e409 eval.c refactor (also improves some error messages) neovim#5119
    9d200cd getcompletion("cmdline") neovim#6376
    2ea7bfc terminal: Support extra arguments in 'shell'. neovim#4504
    bf51102 DirChanged autocmd neovim#5928 neovim#6262
    1743df8 'cpoptions': "_" flag to toggle `cw` behaviour neovim#6235
    22337b1 CTRL-R omits trailing ^M when pasting to cmdline neovim#6137
    0e44916 :edit allows unescaped spaces in filename neovim#6119
    abdbfd2 eval: Add id() function and make printf("%p") useful neovim#6095
    bdfa147 findfile(), :find, gf work in :terminal. neovim#6009
    2f38ed1 providers: Disable if `g:loaded_*` exists.
    b5560a6 setpos() can set lowercase marks in other buffers neovim#5753
    7c513d6 Throttle :! output, pulse "..." message. neovim#5396
    d2e8c76 v:exiting neovim#5651

    :terminal improvements neovim#6185 neovim#6142
      - cursor keeps position after leaving insert-mode.
      - 4ceec30 Follows output only if cursor is at end of buffer.
      - e7bbd35 new option: 'scrollback'
      - fedb844 quasi-support for undo and 'modifiable'
      - b45ddf7 disables 'list' by default
      - disables 'relativenumber' by default

    :help now contains full API documentation at `:help api`.

    man.vim saw numerous improvements.

    Windows support:
      - Windows is no longer "experimental", it is fully supported.
      - Windows package includes a GUI, curl.exe and other utilities.

    "Vim 8" features: partials, lambdas, packages.

FIXES:
    12fc1de ops: fix i<c-r> with multi-byte text neovim#6524
    dd391bf Windows: system() and friends neovim#6497
    13352c0 Windows: os_get_hostname() neovim#6413
    16babc6 tui: Less-noisy mouse seqs neovim#6411
    3a9dd13 (vim bug) folding edge-cases  neovim#6207
    f6946c6 job-control: set CLOEXEC on pty processes. neovim#5986
    d1afd43 rplugin: Call s:LoadRemotePlugins() on startup.
    1215084 backtick-expansion works with `shell=fish` neovim#6224
    e32ec03 tui: Improved behavior after resize. neovim#6202
    86c2adc edit.c: CTRL-SPC: Insert previously-inserted text. neovim#6090
    c318d8e b:changedtick now follows VimL rules neovim#6112
    34e24cb terminal: Initialize colors in reverse order neovim#6160
    e889917 undo: Don't set b_u_curhead in ex_undojoin() neovim#5869
    d25649f undo: :earlier, g-: Set b_u_seq_cur correctly. (neovim#6016)
    043d8ba 'Visual-mode put from @. register' neovim#5782
    42c922b open_buffer(): Do `BufEnter` for directories.
    50d0d89 inccommand: Preview :sub commands only after delimiter neovim#5932
    1420e10 CheckHealth improvements neovim#5519
    c8d5e92 jobstart(): Return -1 if cmd is not executable. neovim#5671

CHANGES:
    NVIM_TUI_ENABLE_CURSOR_SHAPE was removed. Use 'guicursor' instead.
        See https://github.com/neovim/neovim/wiki/Following-HEAD#20170402

    81525dc 'mouse=a' is no longer the default. (This will probably
                 change again after it is improved.) neovim#6022

    0c1f783 defaults: 'showcmd', 'belloff', 'ruler' neovim#6087
    eb0e94f api: {get,set}_option update local options as appropriate neovim#6405
    bdcb2a3 "Reading from stdin..." message was removed. neovim#6298

@justinmk justinmk referenced this pull request May 1, 2017

Merged

NVIM v0.2.0 #6634

justinmk added a commit to justinmk/neovim that referenced this pull request May 1, 2017

NVIM v0.2.0
FEATURES:
    bc4a2e1 help, man.vim: "outline" (TOC) feature neovim#5169
    58422f1 'guicursor' works in the TUI (and sends info to UIs) neovim#6423
    129f107 api: nvim_get_mode() neovim#6247
    0b59f98 api/ui: externalize tabline neovim#6583
    bc6d868 'listchars': `Whitespace` highlight group neovim#6367
    6afa7d6 writefile() obeys 'fsync' option neovim#6427
    c60e409 eval.c refactor (also improves some error messages) neovim#5119
    9d200cd getcompletion("cmdline") neovim#6376
    2ea7bfc terminal: Support extra arguments in 'shell'. neovim#4504
    bf51102 DirChanged autocmd neovim#5928 neovim#6262
    1743df8 'cpoptions': "_" flag to toggle `cw` behaviour neovim#6235
    22337b1 CTRL-R omits trailing ^M when pasting to cmdline neovim#6137
    0e44916 :edit allows unescaped spaces in filename neovim#6119
    abdbfd2 eval: Add id() function and make printf("%p") useful neovim#6095
    bdfa147 findfile(), :find, gf work in :terminal. neovim#6009
    2f38ed1 providers: Disable if `g:loaded_*` exists.
    b5560a6 setpos() can set lowercase marks in other buffers neovim#5753
    7c513d6 Throttle :! output, pulse "..." message. neovim#5396
    d2e8c76 v:exiting neovim#5651

    :terminal improvements neovim#6185 neovim#6142
      - cursor keeps position after leaving insert-mode.
      - 4ceec30 Follows output only if cursor is at end of buffer.
      - e7bbd35 new option: 'scrollback'
      - fedb844 quasi-support for undo and 'modifiable'
      - b45ddf7 disables 'list' by default
      - disables 'relativenumber' by default

    :help now contains full API documentation at `:help api`.

    man.vim saw numerous improvements.

    Windows support:
      - Windows is no longer "experimental", it is fully supported.
      - Windows package includes a GUI, curl.exe and other utilities.

    "Vim 8" features: partials, lambdas.

SECURITY FIXES:
    CVE-2017-5953 CVE-2017-6349 CVE-2017-6350 neovim#6485

CHANGES:
    NVIM_TUI_ENABLE_CURSOR_SHAPE was removed. Use 'guicursor' instead.
        See https://github.com/neovim/neovim/wiki/Following-HEAD#20170402

    81525dc 'mouse=a' is no longer the default. (This will probably
                 change again after it is improved.) neovim#6022

    0c1f783 defaults: 'showcmd', 'belloff', 'ruler' neovim#6087
    eb0e94f api: {get,set}_option update local options as appropriate neovim#6405
    bdcb2a3 "Reading from stdin..." message was removed. neovim#6298

FIXES:
    12fc1de ops: fix i<c-r> with multi-byte text neovim#6524
    dd391bf Windows: system() and friends neovim#6497
    13352c0 Windows: os_get_hostname() neovim#6413
    16babc6 tui: Less-noisy mouse seqs neovim#6411
    3a9dd13 (vim bug) folding edge-cases  neovim#6207
    f6946c6 job-control: set CLOEXEC on pty processes. neovim#5986
    d1afd43 rplugin: Call s:LoadRemotePlugins() on startup.
    1215084 backtick-expansion works with `shell=fish` neovim#6224
    e32ec03 tui: Improved behavior after resize. neovim#6202
    86c2adc edit.c: CTRL-SPC: Insert previously-inserted text. neovim#6090
    c318d8e b:changedtick now follows VimL rules neovim#6112
    34e24cb terminal: Initialize colors in reverse order neovim#6160
    e889917 undo: Don't set b_u_curhead in ex_undojoin() neovim#5869
    d25649f undo: :earlier, g-: Set b_u_seq_cur correctly. (neovim#6016)
    043d8ba 'Visual-mode put from @. register' neovim#5782
    42c922b open_buffer(): Do `BufEnter` for directories.
    50d0d89 inccommand: Preview :sub commands only after delimiter neovim#5932
    1420e10 CheckHealth improvements neovim#5519
    c8d5e92 jobstart(): Return -1 if cmd is not executable. neovim#5671

justinmk added a commit to justinmk/neovim that referenced this pull request May 1, 2017

NVIM v0.2.0
FEATURES:
    bc4a2e1 help, man.vim: "outline" (TOC) feature neovim#5169
    58422f1 'guicursor' works in the TUI (and sends info to UIs) neovim#6423
    129f107 api: nvim_get_mode() neovim#6247
    0b59f98 api/ui: externalize tabline neovim#6583
    bc6d868 'listchars': `Whitespace` highlight group neovim#6367
    6afa7d6 writefile() obeys 'fsync' option neovim#6427
    c60e409 eval.c refactor (also improves some error messages) neovim#5119
    9d200cd getcompletion("cmdline") neovim#6376
    2ea7bfc terminal: Support extra arguments in 'shell'. neovim#4504
    bf51102 DirChanged autocmd neovim#5928 neovim#6262
    1743df8 'cpoptions': "_" flag to toggle `cw` behaviour neovim#6235
    22337b1 CTRL-R omits trailing ^M when pasting to cmdline neovim#6137
    0e44916 :edit allows unescaped spaces in filename neovim#6119
    abdbfd2 eval: Add id() function and make printf("%p") useful neovim#6095
    bdfa147 findfile(), :find, gf work in :terminal. neovim#6009
    2f38ed1 providers: Disable if `g:loaded_*` exists.
    b5560a6 setpos() can set lowercase marks in other buffers neovim#5753
    7c513d6 Throttle :! output, pulse "..." message. neovim#5396
    d2e8c76 v:exiting neovim#5651

    :terminal improvements neovim#6185 neovim#6142
      - cursor keeps position after leaving insert-mode.
      - 4ceec30 Follows output only if cursor is at end of buffer.
      - e7bbd35 new option: 'scrollback'
      - fedb844 quasi-support for undo and 'modifiable'
      - b45ddf7 disables 'list' by default
      - disables 'relativenumber' by default

    :help now contains full API documentation at `:help api`.

    man.vim saw numerous improvements.

    Windows support:
      - Windows is no longer "experimental", it is fully supported.
      - Windows package includes a GUI, curl.exe and other utilities.

    "Vim 8" features: partials, lambdas.

SECURITY FIXES:
    CVE-2017-5953 CVE-2017-6349 CVE-2017-6350 neovim#6485

CHANGES:
    NVIM_TUI_ENABLE_CURSOR_SHAPE was removed. Use 'guicursor' instead.
        See https://github.com/neovim/neovim/wiki/Following-HEAD#20170402

    81525dc 'mouse=a' is no longer the default. (This will probably
                 change again after it is improved.) neovim#6022

    0c1f783 defaults: 'showcmd', 'belloff', 'ruler' neovim#6087
    eb0e94f api: {get,set}_option update local options as appropriate neovim#6405
    bdcb2a3 "Reading from stdin..." message was removed. neovim#6298

FIXES:
    12fc1de ops: fix i<c-r> with multi-byte text neovim#6524
    dd391bf Windows: system() and friends neovim#6497
    13352c0 Windows: os_get_hostname() neovim#6413
    16babc6 tui: Less-noisy mouse seqs neovim#6411
    3a9dd13 (vim bug) folding edge-cases  neovim#6207
    f6946c6 job-control: set CLOEXEC on pty processes. neovim#5986
    d1afd43 rplugin: Call s:LoadRemotePlugins() on startup.
    1215084 backtick-expansion works with `shell=fish` neovim#6224
    e32ec03 tui: Improved behavior after resize. neovim#6202
    86c2adc edit.c: CTRL-SPC: Insert previously-inserted text. neovim#6090
    c318d8e b:changedtick now follows VimL rules neovim#6112
    34e24cb terminal: Initialize colors in reverse order neovim#6160
    e889917 undo: Don't set b_u_curhead in ex_undojoin() neovim#5869
    d25649f undo: :earlier, g-: Set b_u_seq_cur correctly. (neovim#6016)
    043d8ba 'Visual-mode put from @. register' neovim#5782
    42c922b open_buffer(): Do `BufEnter` for directories.
    50d0d89 inccommand: Preview :sub commands only after delimiter neovim#5932
    1420e10 CheckHealth improvements neovim#5519
    c8d5e92 jobstart(): Return -1 if cmd is not executable. neovim#5671

@mhinz mhinz referenced this pull request May 3, 2017

Merged

news: version 0.2 #151

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment