[vim/vim] terminal: mouse stays enabled after Vim is killed with SIGTERM (PR #21095)

h_east (Vim Github Repository) <[email protected]>
Newsgroups gmane.editors.vim.devel
Message-ID <vim/vim/pull/[email protected]>
```
Problem:  After Vim is killed with a deadly signal such as SIGTERM the mouse
          stays enabled in the terminal, so moving the mouse afterwards
          produces escape sequences in the shell.
Solution: Switch the mouse off when exiting after a deadly signal.  The
          terminal mode is restored with "full_screen" already reset, which
          makes settmode() return before it can do this.
```

fixes: #21090

`deathtrap()` resets `full_screen` before calling `preserve_exit()`
(os_unix.c:1193), and `settmode()` returns early when it is not set
(term.c:3987).  The `mch_setmouse(FALSE)` that lives inside `settmode()` is
therefore never reached.  `stoptermcap()` does not look at `full_screen`,
which is why the alternate screen, bracketed paste and focus reporting are
restored and only the mouse is left enabled.

The added call is guarded by `!full_screen`.  The other callers of
`preserve_exit()`, `read_error_exit()` and the MS-Windows console control
handler, leave `full_screen` set, and there `settmode()` still switches the
mouse off after reading pending terminal responses, as before.

Recorded with `script` while sending SIGTERM from another process.  Before:

    ^[[?1002h        <- no matching l
    ^[[?1006;1000h   <- no matching l
    ^[[?1049h / ^[[?1049l
    ^[[?1004h / ^[[?1004l

After the change every mode is paired again.

No test: reproducing this needs a pty plus a signal, which is hard to keep
reliable in the test suite.
You can view, comment on, or merge this pull request online at:

  https://github.com/vim/vim/pull/21095

-- Commit Summary --

  * terminal: mouse stays enabled after Vim is killed with SIGTERM

-- File Changes --

    M src/misc1.c (5)

-- Patch Links --

https://github.com/vim/vim/pull/21095.patch
https://github.com/vim/vim/pull/21095.diff

-- 
Reply to this email directly or view it on GitHub:
https://github.com/vim/vim/pull/21095
You are receiving this because you are subscribed to this thread.

Message ID: <vim/vim/pull/[email protected]>

-- 
-- 
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

--- 
You received this message because you are subscribed to the Google Groups "vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [email protected].
To view this discussion visit https://groups.google.com/d/msgid/vim_dev/vim/vim/pull/21095%40github.com.
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.