Commit Graph

453 Commits

Author SHA1 Message Date
Christian Clason
c855eee919
feat(term): enable reflow by default (#21124)
libvterm v0.3 supports reflow of terminal buffer when Nvim is resized
Since v0.3 is now a required dependency, enable it by default to find
(and fix) possible issues.

Note: Neovim's scrollback buffer does not support reflow (yet), so lines
vanishing into the buffer due to a too small window will be restored
without reflow.
2023-05-24 10:04:49 +02:00
Famiu Haque
576dddb461 test: don't unnecessarily specify win/buf for nvim_(get|set)_option_value
`nvim_(get|set)_option_value` pick the current buffer / window by default for buffer-local/window-local (but not global-local) options. So specifying `buf = 0` or `win = 0` in opts is unnecessary for those options. This PR removes those to reduce code clutter.
2023-05-22 13:02:07 +06:00
Lewis Russell
1fe1bb084d refactor(options): deprecate nvim[_buf|_win]_[gs]et_option
Co-authored-by: zeertzjq <zeertzjq@outlook.com>
Co-authored-by: famiu <famiuhaque@protonmail.com>
2023-05-21 15:14:01 +06:00
zeertzjq
c9f47fca8b
fix(messages): ensure msg_grid is at top at more prompt (#23584) 2023-05-17 21:06:27 +08:00
dundargoc
ecd6d679a0
test: skip flaky test on Windows 2023-05-14 14:29:18 +02:00
bfredl
d94db80227
Merge pull request #23415 from zeertzjq/sigwinch-redraw
fix(tui): redraw on SIGWINCH even if size didn't change
2023-05-06 11:48:33 +02:00
Luuk van Baal
197827321a fix(tui): grid_clear properly clears the screen
Problem:    When setting a shell size smaller than the containing
            terminal window through `:winsize` or `:set lines/columns`
            the screen is not properly cleared.
Solution:   Clear the tui dimensions rather than the grid dimensions.
2023-05-03 14:58:25 +02:00
zeertzjq
0f1b511f23 fix(tui): redraw on SIGWINCH even if size didn't change 2023-05-01 13:17:03 +08:00
zeertzjq
95c6e1b741
test(terminal/channel_spec): fix screen test immediate success (#23192)
Check for the [No Name] after wiping the buffer.
2023-04-19 12:10:06 +08:00
Lewis Russell
34ac75b329
refactor: rename local API alias from a to api
Problem:
  Codebase inconsistently binds vim.api onto a or api.

Solution:
  Use api everywhere. a as an identifier is too short to have at the
  module level.
2023-04-05 17:19:53 +01:00
Justin M. Keyes
a40eb7cc99 feat(vim.version): more coercion with strict=false
Problem:
"tmux 3.2a" (output from "tmux -V") is not parsed easily.

Solution:
With `strict=false`, discard everything before the first digit.

- rename Semver => Version
- rename vim.version.version() => vim.version._version()
- rename matches() => has()
- remove `opts` from cmp()
2023-03-20 13:40:38 +01:00
Enan Ajmain
8786b2066d
fix: pasting in terminal buffer on windows #22566
Problem:
On Windows, pasting multiple lines on a terminal buffer cause all the
lines to appear on the same line, i.e., the line breaks are lost.

Cause:
Windows shells expect "\r\n" as line break but "terminal_paste" function
uses "\n".

Solution:
Use "\r\n" as line break for pasting in terminal buffer on Windows.

Note:
Although this issue was reported with powershell set as 'shell', it
occurs in cmd too.

Fixes #14621
2023-03-19 10:23:34 -07:00
dundargoc
b466e1d289
test: unskip working Windows tests (#22537)
Some tests that were previously not working have started to work again
for unspecified reasons, so let's enable them.
2023-03-13 11:15:24 +08:00
Justin M. Keyes
3b92776226
Merge #22382 has('gui_running') 2023-02-28 06:24:23 -05:00
zeertzjq
2630341db6
fix(tui): avoid stack-use-after-scope with cursor color (#22435) 2023-02-28 07:19:03 +08:00
Justin M. Keyes
ce597235a2 feat(ui): restore has('gui_running')
Problem:
has('gui_running') is still common in the wild and our answer has
changed over time, causing frustration.
95a6ccbe9f

Solution:
Use stdin_tty/stdout_tty to decide if a UI is (not) a GUI.
2023-02-27 19:50:59 +01:00
Justin M. Keyes
7f424e2b65 feat(api): more fields in nvim_list_uis
Problem:
nvim_list_uis does not report all ":help ui-option" fields.

Solution:
Store ":help ui-option" fields on the `UI` object and update ui_array.
2023-02-27 19:50:59 +01:00
zeertzjq
9381d08e29 test(tui_spec): use RPC request to setup autocommands
This avoids changing cmdline and fixes a warning.
2023-02-18 10:44:35 +08:00
zeertzjq
9b9f8dfcc4 test: make {MATCH:} behave less unexpectedly in screen:expect()
Include the rest of the line and allow multiple {MATCH:} patterns.
2023-02-18 10:44:35 +08:00
zeertzjq
820430dc0b fix(tui): exit on input eof 2023-02-14 07:49:31 +08:00
zeertzjq
5a8039a0cb test(tui_spec): remove unnecessary arguments for remote UI 2023-02-14 07:49:31 +08:00
zeertzjq
b2b82ff142
fix(rpc): ignore redraw events when exiting (#22184)
When a TUI client has already stopped, handling UI events will cause a
heap-use-after-free, so ignore them.
2023-02-09 14:36:17 +08:00
zeertzjq
2c5906b55b
fix(exit): skip unnecessary steps in TUI preserve_exit() (#21897)
This prevents the TUI from doing unexpected things when receiving a
deadly signal or running out of memory.
2023-02-02 10:05:03 +08:00
zeertzjq
fb805bb8b7
fix(remote): don't leak memory on failure to connect to server (#21931)
Also fix the race between output and resize in the test for this.
2023-01-21 18:54:17 +08:00
zeertzjq
eec979ca81
test(tui_spec): don't expect exact screen in rapid resize test (#21935)
There may be a race between resizes, so don't expect exact screen.
Expect window width instead.
2023-01-21 18:15:38 +08:00
zeertzjq
e336251f2b
test(tui_spec): make rapid resize test test what it wants to test (#21933)
Actually execute the command.
Don't use assert_alive() as it checks the host session instead of the
child session. Use screen:expect() instead.
2023-01-21 17:11:02 +08:00
Christian Clason
7295ed1f6f build(deps): bump libvterm to v0.3.1
Included patches:

821. By Paul "LeoNerd" Evans on 2022-12-29
Don't bother to emit the unrecognised sequence in DECRQSS response as it provides an echo roundtrip possibility

820. By Paul "LeoNerd" Evans on 2022-11-26
erase_internal() should only set fg/bg colour, resetting other attributes (especially RV)

819. By Paul "LeoNerd" Evans on 2022-11-09
Added vterm_screen_set_default_colors(), which repaints the cells in the buffer(s)

818. By Paul "LeoNerd" Evans on 2022-11-09
Permit either colour argument to be NULL to vterm_state_set_default_colors()

817. By Paul "LeoNerd" Evans on 2022-10-01
Delete the mk_wcswidth functions as they're not used; guard the CJK-wide one with an ifdef as by default we don't use it

816. By Paul "LeoNerd" Evans on 2022-10-01
Make sure to supply empty (void) prototype to functions that take no arguments in bin/vterm-ctrl.c
2023-01-16 18:40:19 +01:00
zeertzjq
53adccb6e0
test(tui_spec): doesn't use Unicode in cursor_address test (#21703)
Using Unicode makes the test flaky because of #16245.
2023-01-09 17:02:45 +08:00
zeertzjq
c19bd47c0a
test(tui_spec): improve cursor_address test (#21700) 2023-01-09 12:20:50 +08:00
bfredl
b303ab9a7d fix(tui): do not invoke loop recursively for pad()
fixes #21610
2023-01-06 11:01:02 +01:00
zeertzjq
89232b8b48
fix(tui): make a copy of data->params before unibi_format() (#21643)
Problem:    When unibi_format() modifies params and data->buf overflows,
            unibi_format() is called again, causing the params to be
            modified twice. This can happen for escapes sequences that
            use the %i terminfo format specifier (e.g. cursor_address),
            which makes unibi_format() increase the param by 1.
Solution:   Make a copy of data->params before calling unibi_format().
2023-01-05 00:25:25 +08:00
zeertzjq
ef18c9f9b0
test(tui_spec): avoid race between nvim_paste and nvim_input (#21639)
Now that the TUI calls nvim_paste and nvim_input through RPC, the data
race is much more likely, as nvim_paste is deferred while nvim_input is
not. Add an expect_child_buf_lines() call to avoid the race.
2023-01-04 08:39:20 +08:00
bfredl
43e8ec92de fix(tui): more work in the TUI 2022-12-31 13:25:26 +01:00
hlpr98
2448816956 feat(tui): run TUI as external process 2022-12-31 10:43:28 +01:00
zeertzjq
b640161a69
test(tui_spec): don't use nested terminal for resize at startup (#21583) 2022-12-29 14:13:54 +08:00
zeertzjq
6631df9107
fix(terminal): fix 'mousescroll' not respected in terminal mode (#21415) 2022-12-14 23:45:31 +08:00
Enan Ajmain
1e2cc68889
fix(chansend): sending lines to terminal in reverse order on Windows #19315
Problem: `chansend()` on Windows sends lines in reverse order.
Cause: Using \n instead of \r\n for newlines on Windows.
Solution: on Windows, use CRLF newline characters.

Fixes #18501
2022-12-08 12:55:50 -08:00
dundargoc
5eb5f49488
test: simplify platform detection (#21020)
Extend the capabilities of is_os to detect more platforms such as
freebsd and openbsd. Also remove `iswin()` helper function as it can be
replaced by `is_os("win")`.
2022-11-22 08:13:30 +08:00
dundargoc
cb27c09930
test: use isCI to simplify CI detection (#21134) 2022-11-20 18:26:21 +08:00
Jakub Łuczyński
4650af38f0
test: fix failing tui_spec.lua tests (#21117)
* refactor(test): use exec_lua

* fix(test): fix failing tui_spec tests

test is failing when path of tty-test does not fit cmdline
2022-11-19 20:46:04 +08:00
dundargoc
736c36c02f
test: introduce skip() #21010
This is essentially a convenience wrapper around the `pending()`
function, similar to `skip_fragile()` but more general-purpose.

Also remove `pending_win32` function as it can be replaced by
`skip(iswin())`.
2022-11-13 05:52:19 -08:00
Shougo
4fd876271a
vim-patch:9.0.0756 #20680
Problem:    No autocmd event for changing text in a terminal window.
Solution:   Add TextChangedT. (Shougo Matsushita, closes vim/vim#11366)

4ccaedfcd7
2022-11-06 19:02:29 -08:00
dundargoc
5046b4b4ad
ci: add cirrus to isCI function to skip tests (#20526)
The environment variable CIRRUS_CI is manually passed to RunTests.cmake
as it doesn't get passed when using cmake script mode.
2022-10-17 17:16:31 +02:00
Andrey Bushev
4bb1d1df79 feat(terminal): recognize underdouble and undercurl 2022-09-26 11:53:20 +08:00
zeertzjq
d7052e8e1f test: add tests for #13549 #20285 #20290 2022-09-23 07:38:22 +08:00
dundargoc
2d6735d8ce
ci: move BSD jobs from sourcehut to Cirrus CI #19616
dispatch.sr.ht is being deprecated, meaning that using sourcehut CI
won't be possible (see https://github.com/neovim/neovim/issues/19609).
Since Github Actions doesn't provide any BSD runners an external service
is required and Cirrus CI seems like a good replacement for sourcehut.

Initially experimented with using FreeBSD and OpenBSD virtual machines
in GitHub Actions, but Cirrus has been a much better fit with better
performance, logs and overall experience.

Failing tests are automatically skipped on FreeBSD regardless if it's on
CI or not. Ideally these tests should only be skipped in CI with the
help of `isCI` helper function. Unfortunately, the tests don't recognize
the environment variable CIRRUS_CI even if it's set manually. This
workaround is good enough for the time being, but we might want to only
skip tests when using the CI (or even better, fix the failing tests).

Closes: https://github.com/neovim/neovim/issues/19609
2022-09-08 15:12:42 -07:00
Andreas Schneider
b76e33b598 fix(terminal): adopt altscreen test for libvterm 0.2 changes
Due to a rewrite of the resize handling logic in libvterm, the behavior
changed. It's actually fixing a bug.

16b8574575
2022-09-06 21:48:22 +02:00
zeertzjq
82d128405a feat(pum): pretend 'mousemoveevent' is set when showing right-click menu 2022-09-04 21:18:23 +08:00
zeertzjq
568737d5b3
feat(tui): recognize sidescroll events (#19992)
Ref https://invisible-island.net/xterm/ctlseqs/ctlseqs.html#h3-Other-buttons
This works in xterm and kitty.
CSI < 66 ; x ; y M sequence is for ScrollWheelLeft.
CSI < 67 ; x ; y M sequence is for ScrollWheelRight.
2022-08-30 10:55:00 +08:00
zeertzjq
3030b4d653
feat(tui): allow grid and host to disagree on ambiguous-width chars (#19686)
Note: This only applies to ambiguous-width characters.
2022-08-09 21:08:46 +08:00
zeertzjq
629169462a
fix(terminal): skip aucmd_win when checking terminal size (#19668) 2022-08-07 19:43:29 +08:00
bfredl
9092540315 feat(terminal): implement <c-\><c-o> for terminal mode
this works similar to <c-o> or <c-\><c-o> in insert mode
2022-08-02 13:54:41 +02:00
zeertzjq
d36d9be8ff
fix(terminal): avoid reading over the end of cell.chars (#19580) 2022-07-30 21:40:30 +08:00
zeertzjq
fe159d23fd
vim-patch:9.0.0071: command overlaps with printed text in scrollback (#19505)
Problem:    Command overlaps with printed text in scrollback.
Solution:   Clear until end-of-line and use correct message chunk.
            (closes vim/vim#10765, closes vim/vim#10764)
ecdc82e74e

N/A patches for version.c:

vim-patch:9.0.0070: using utfc_ptr2char_len() when length is negative

Problem:    Using utfc_ptr2char_len() when length is negative.
Solution:   Check value of length. (closes vim/vim#10760)
4dc513a22c
2022-07-26 07:30:33 +08:00
zeertzjq
0cc41a61d1 test: improve some input tests 2022-07-25 09:47:28 +08:00
zeertzjq
4cded8cec1
Merge pull request #19180 from zeertzjq/tui-kitty-keypad
feat(tui): recognize keypad keys when using kitty keyboard protocol
2022-07-07 07:42:22 +08:00
Javier Lopez
1803b0ffd7
fix(tui): resize at startup #17795
* fix(test): screen.lua nil index
  When actual_rows and expected_rows are different avoid a nil index.
* fix(tui): resize at startup
  The deleted code is not needed after 402b4e8.
  It caused the condition to false positive when the function was called
  more than once before startup (first normal mode). Being itself what
  set the dimension and not the user, locking the size of the screen to
  an incorrect size.
  Make got_winch an int to mitigate: tui_grid_resize changing the size
  of the host terminal between the signal handler and the call to
  sigwinch_cb. Since the actual signal handler uv__signal_handle doesn't
  directly call the callback, the event loop does.

Fixes #17285
Fixes #15044
Fixes #11330
2022-07-04 13:09:47 -07:00
zeertzjq
03c9cf3feb test: add tests for keypad keys from kitty keyboard protocol 2022-07-04 22:37:45 +08:00
Justin M. Keyes
f50135a32e
feat: stdpath('run'), /tmp/nvim.user/ #18993
Problem:
- Since c57f6b28d7 #8519, sockets are created in ~/.local/… but XDG
  spec says: "XDG_RUNTIME_DIR: Must be on the local filesystem", which
  implies that XDG_STATE_DIR is potentially non-local.
- Not easy to inspect Nvim-created temp files (for debugging etc).

Solution:
- Store sockets in stdpath('run') ($XDG_RUNTIME_DIR).
- Establish "/tmp/nvim.user/" as the tempdir root shared by all Nvims.
- Make ok() actually useful.
- Introduce assert_nolog().

closes #3517
closes #17093
2022-06-30 04:16:46 -07:00
zeertzjq
995e487915
refactor(highlight)!: rename attributes to match Vim (#19159)
Ref: 84f5463630
Rename:
- `underlineline` to `underdouble`
- `underdot` to `underdotted`
- `underdash` to `underdashed`

`underdouble` also now takes higher precedence than `undercurl`.
2022-06-30 16:57:44 +08:00
Justin M. Keyes
f977f9445f refactor(tests): introduce testprg()
Also:
- Add a describe('shell :!') section to system_spec.
- Make the test for #16271 work on systems without powershell.
2022-06-25 08:27:17 -07:00
Justin M. Keyes
1f2c2a35ad feat(server): instance "name", store pipes in stdpath(state)
Problem:
- Unix sockets are created in random /tmp dirs.
  - /tmp is messy, unclear when OSes actually clear it.
  - The generated paths are very ugly. This adds friction to reasoning
    about which paths belong to which Nvim instances.
- No way to provide a human-friendly way to identify Nvim instances in
  logs or server addresses.

Solution:
- Store unix sockets in stdpath('state')
- Allow --listen "name" and serverstart("name") to given a name (which
  is appended to a generated path).

TODO:
- is stdpath(state) the right place?
2022-06-15 19:29:51 -07:00
Javier Lopez
916d848049
fix(terminal): scrollback delete lines immediately #18832
* on_scrollback_option_changed renamed to adjust_scrollback. The
  function name did not correspond to what it was doing. It is
  called unconditionally in every refresh of the terminal
  unrelated if the scrollback option was changed.
* new on_scrollback_option_changed function, which calls
  refresh_terminal, which then calls adjust_scrollback
* terminal_check_size is not the appropriate function to call when the
  option is changed since it only conditionally adjusts the scrollback.
  Use the new on_scrollback_option_changed

fixes #15477
fixes #11811
2022-06-08 17:46:57 -07:00
zeertzjq
6e414b698c
test: unskip tests on Windows (#18600)
Remove the command('qall!') from mksession_spec.lua because it prevents
helpers.rmdir() from retrying.

Allow extra trailing spaces when matching terminal lines.
2022-05-18 12:57:04 +08:00
zeertzjq
f49699737c
fix(terminal): do not trim whitespace that is actually in the terminal (#16423) 2022-05-17 21:09:28 +08:00
dundargoc
e63e5d1dbd
docs: typo fixes (#17859)
Co-authored-by: Elias Alves Moura <eliamoura.alves@gmail.com>
Co-authored-by: venkatesh <shariharanvenkatesh@gmail.com>
Co-authored-by: zeertzjq <zeertzjq@outlook.com>
Co-authored-by: Vikas Raj <24727447+numToStr@users.noreply.github.com>
Co-authored-by: Steve Vermeulen <sfvermeulen@gmail.com>
Co-authored-by: Evgeni Chasnovski <evgeni.chasnovski@gmail.com>
Co-authored-by: rwxd <rwxd@pm.me>
Co-authored-by: casswedson <58050969+casswedson@users.noreply.github.com>
2022-04-15 12:35:06 +02:00
zeertzjq
a2f157233f
fix(tui)!: remove ESC NUL forced escape (#17198)
This make Nvim recognize `ESC NUL` as <M-C-Space>, as many terminal
emulators (including libvterm) send <M-C-Space> as `ESC NUL`.

There is already another unambiguous way to encode a `ESC` key supported
by libtermkey: `ESC [ 2 7 u`, which is a `CSI u` sequence.

If one still wants to use `ESC NUL` as `ESC`, they can just map
<M-C-Space> to <Esc>.
2022-04-11 10:23:33 +08:00
dundargoc
d238b8f600
chore: fix typos (#17670)
Co-authored-by: zeertzjq <zeertzjq@outlook.com>
2022-03-17 13:21:24 +08:00
zeertzjq
2601e0873f fix(paste): don't move cursor past the end of pasted text in Normal mode 2022-03-15 18:15:18 +08:00
zeertzjq
f1c9065b0e test: improve terminal channel tests 2022-03-12 19:23:45 +08:00
erw7
5051510ade fix(channel): fix channel consistency
- Fix the problem that chanclose() does not work for channel created by
  nvim_open_term().
- Fix the problem that the loopback channel is not released.
- Fix the error message when sending raw data to the loopback channel.
2022-03-12 19:23:45 +08:00
Kirill Chibisov
96bb1784a6
fix(api): highlight attribute for underline
This commit fixes regression introduced in c365de1 when checking for
highlight attribute for underline was returning '0' when it was present

Fixes #17624.
2022-03-06 23:51:25 +03:00
zeertzjq
ede4eac61f test: mention poke_eventloop() instead of wait() 2022-03-02 22:31:20 +08:00
zeertzjq
0545bd2180 test: use helpers.pending_win32(pending) instead of iswin() 2022-02-26 19:40:11 +08:00
Dundar Göc
82c5a02050 ci: skip tests that fail on windows 2022-02-20 10:22:39 +01:00
zeertzjq
818456470c fix(input): put modifiers back into typeahead buffer when needed 2022-01-23 05:58:32 +08:00
zeertzjq
e70ea6ea20
test: remove redundant feed_command('terminal') (#16993)
It just types :terminal<CR> into the terminal, which is redundant.
2022-01-08 08:29:32 -07:00
zeertzjq
a5eadbaf3c
test: make some tests more stable (#16860) 2022-01-01 07:28:52 -07:00
zeertzjq
e0956f7452 fix(terminal): correctly forward mouse events 2021-12-27 06:08:16 +08:00
Björn Linse
99526dc9b3
Merge pull request #16596 from dm1try/do_not_leave_terminal_mode_after_mouse_activation
do not leave Terminal mode after entering to it using a mouse
2021-12-26 19:11:51 +01:00
James McCoy
8d22049513
Merge pull request #16294 from zeertzjq/test-fewest-iteration
test: require fewest number of main loop iterations possible
2021-12-18 13:08:28 -05:00
Gregory Anders
4240ce8eb3
perf: pre-compile embedded Lua source into bytecode (#16631)
The Lua modules that make up vim.lua are embedded as raw source files into the
nvim binary. These sources are loaded by the Lua runtime on startuptime. We can
pre-compile these sources into Lua bytecode before embedding them into the
binary, which minimizes the size of the binary and improves startuptime.
2021-12-16 09:27:39 -07:00
Sean Dewar
0a1391fdd7
fix(terminal): fix resize crash with pending scrollback (#14891)
refresh_scrollback assumes pending scrollback rows exist only if the
terminal window height decreased (or the screen was full).

However, after accumulating scrollback, it's possible in some cases for
the terminal height to increase before refresh_scrollback is called via
invalidation (especially when the terminal buffer isn't initially
displayed in a window before nvim_open_term), which may crash.

As we'll have enough room for some scrollback rows, just append them to
the top of the buffer until it fills the window, then continue with the
previous logic for any remaining scrollback rows if necessary.
2021-12-15 08:18:06 -07:00
zeertzjq
14ffcd190d
test: expect the correct screen in TUI paste: big burst of input (#16656) 2021-12-15 07:35:22 -07:00
zeertzjq
40ed2b51cb fix(tui): end streamed paste correctly when key buffer is empty 2021-12-10 18:09:55 +08:00
James McCoy
b20871526e
Merge pull request #16414 from zeertzjq/terminal-no-invalid-rows
fix(terminal): return early if there are no invalid rows
2021-12-09 21:13:16 -05:00
dm1try
c96f7e29dc fix(terminal): ignore left-release mouse action
if it is not proccesed by the terminal program
to prevent leaving Terminal mode after using
a mouse for window switching

closes #9483
closes #8691
2021-12-10 00:53:30 +03:00
zeertzjq
c83fedf0bd fix(terminal): return early if there are no invalid rows
Prevent on_lines emitting out-of-bounds line indexes.
2021-12-08 08:41:46 +08:00
zeertzjq
2784a5d3d2 fix(terminal): use coladvance() to calculate buffer cursor position 2021-12-08 08:11:27 +08:00
zeertzjq
bd15ff7b84 test: require fewest number of main loop iterations possible
Change exc_exec to pcall_err to reduce one main loop iteration.
No need to call poke_eventloop() unless after nvim_input().
2021-11-15 10:34:43 +08:00
zeertzjq
8b5c32c8cd test: add tests for freeing channel opened by termopen()
This indirectly covers #16264
2021-11-11 09:34:23 +08:00
Gregory Anders
03b805aee6
feat(lua): enable stack traces in error output (#16228) 2021-11-06 08:26:10 -06:00
zeertzjq
f4359b5dbd
vim-patch:8.2.3461: distinguish Normal and Terminal-Normal mode #15878
Problem:    Cannot distinguish Normal and Terminal-Normal mode.
Solution:   Make mode() return "nt" for Terminal-Normal mode. (issue vim/vim#8856)
72406a4bd2
2021-10-09 18:15:46 -07:00
Yorick Peterse
c61a3865ee
fix: set cursorlineopt=number in terminal mode (#15493)
When entering terminal mode, cursorlineopt is no longer entirely
disabled. Instead, it's set to `number`. Doing so ensures that users
using `set cursorline` combined with `set cursorlineopt=number` have
consistent highlighting of the line numbers, instead of this being
disabled when entering terminal mode.

Co-authored-by: Gregory Anders <greg@gpanders.com>
Co-authored-by: Sean Dewar <seandewar@users.noreply.github.com>
2021-10-06 16:31:14 -06:00
Justin M. Keyes
6751d6254b
refactor(tests): use assert_alive() #15546 2021-09-01 09:42:53 -07:00
Gregory Anders
3c081d0280 fix(jobwait): always drain process event queues #15402
Problem:
jobwait() returns early if the job was stopped, but the job might have
pending callbacks on its event queue which are required to complete its
teardown. State such as term->closed might not be updated yet (by the
pending callbacks), so codepaths such as :bdelete think the job is still
running.

Solution:
Always flush the job's event queue before returning from jobwait().

ref #15349
2021-08-31 06:53:06 -07:00
Gregory Anders
55defa1a41 fix(terminal): close without ! if the job is stopped
- If the terminal job is still running then ! is still required.

Closes #4683
2021-08-31 06:46:56 -07:00
Dylan Armstrong
6646280d1a
chore: revert unrelated changes in test 2021-02-27 10:02:56 -06:00
Dylan Armstrong
1d4a7c6039
test: use assert_alive helper rather than eq 2021-02-27 09:38:38 -06:00
Dylan Armstrong
a9eeeec5d5 test: segfault test for empty buffer paste on term 2021-02-26 19:55:32 -06:00
Edwin Pujols
f2ec058602
tests: Take into account magic hyphen. (#13518)
In Lua patterns the hyphen works like a non-greedy version of Vim's `*`.
- Use `%-` when you need a literal hyphen.
- If you don't need a regular expression at all, use something like
  ```
  string.find(text, pattern, 1, true)
  ```
  so that the pattern is regarded as a plain, non-magical string.
  See [1] and [2] in the Lua manual.

[1]: https://www.lua.org/manual/5.1/manual.html#pdf-Patterns
[2]: https://www.lua.org/manual/5.1/manual.html#pdf-string.find
2020-12-11 18:54:39 -05:00
Jan Edmund Lazo
518fe0e8a2
test/wildmode_spec: override $PS1
User config may set $PS1 for a colored prompt.
It breaks the screen tests.
2020-12-01 08:52:34 -05:00
Jan Edmund Lazo
56f5e3bd6b
vim-patch:8.0.1525: using :wqa exits even if a job runs in a terminal window
Problem:    Using :wqa exits even if a job runs in a terminal window. (Jason
            Felice)
Solution:   Check if a terminal has a running job. (closes vim/vim#2654)
7a76092a51
2020-12-01 08:52:33 -05:00
erw7
a539a12d72
test: add functional test for segmented response from terminal 2020-11-20 09:26:17 -05:00
James McCoy
f23b906ddd
GHA: Skip tests that fail due to actions/runner#241 2020-11-13 13:36:57 -05:00
Björn Linse
07cc231142 A Mudholland Dr. Recast
The commit summary maybe does not make sense, but calling a function
that does not wait on anything `wait()` makes even less sense.
2020-10-19 21:48:06 +02:00
Jan Edmund Lazo
0393eec3ea
tests/terminal/tui: wait 1ms to avoid data race in FreeBSD 2020-08-02 12:00:02 -04:00
erw7
b6b270b28f terminal: fix terminal attribute overflow
fixes #11548
2020-07-29 02:16:50 +09:00
Ghjuvan Lacambre
721f69c4af
terminal: preserve mode when using <Cmd>wincmd in terminal mode (#12254) 2020-06-22 23:22:58 +02:00
Justin M. Keyes
7b764bb43d terminal: disable 'scrolloff' (fixes flicker)
Besides the special-case in get_scrolloff_value(), it makes sense for
'scrolloff' and 'sidescrolloff' to reflect the correct values (for
plugins, scripts, …).

ref 53d607af9c53accfd634435908fb79061f1212b9
ref #11915
ref #12230
2020-05-04 21:21:33 -07:00
erw7
6854680579
terminal: Fix mouse coordinates issue (#12158)
Offsets of window were not taken into account when sending mouse
coordinates to the terminal. Therefore, when nu or rnu is set, the mouse
coordinates sent to the terminal were not correct. Change it to send the
correct coordinates by subtract window offset from col.
2020-04-21 15:44:39 +02:00
Chris LaRose
c6ff23d7a0 terminal: absolute CWD in term:// URI #11289
This makes it possible to restore the working directory of :terminal
buffers when reading those buffers from a session file.

Fixes #11288

Co-authored-by: Justin M. Keyes <justinkz@gmail.com>
2020-01-26 00:24:42 -08:00
Matthew Malcomson
dfb676fe0d edit.c: Ensure undo sync when emulating <Esc>x #11706
After PR #8226 an unmapped META key in insert mode behaves like
ESC-<key> (:help i_META).

The behaviour does not fully match, since if <Esc>-<key> is pressed
manually then since it were pressed manually `gotchars` would be called
on the second <key> after insert-mode had already been left.

This would mean that `may_sync_undo` (called from `gotchars`) would
call `u_sync(FALSE)` on the second key (since we would be in normal
mode).

This overall means that <Meta-[something]> behaves differently with
respect to undo than <Esc>[something] when the [something] makes a
change.

As an example, under `nvim -u NONE`:
ihello<M-.>u

leaves the buffer empty, while
ihello<Esc>.u

leaves the buffer with one instance of `hello`.

- Fix by calling u_sync() manually in the new clause under
  `normalchar:` in `insert_handle_key`.
- Update test in tui_spec.lua that accidentally relied on the old behaviour.
2020-01-12 17:09:39 -08:00
Daniel Hahler
e1d63c180c
tests: ex_terminal_spec: retry ":terminal (with fake shell)" (#11588)
Flaky failure (Travis CI, macOS):

    [ RUN      ] :terminal (with fake shell) works with gf: 10518.41 ms FAIL
    test/functional/terminal/ex_terminal_spec.lua:248: Row 1 did not match.
    Expected:
      |*^ready $ echo "scripts/shadacat.py"                |
      |*                                                  |
      |*[Process exited 0]                                |
      |:terminal echo "scripts/shadacat.py"              |
    Actual:
      |*^                                                  |
      |*[Process exited 0]                                |
      |*                                                  |
      |:terminal echo "scripts/shadacat.py"              |
    To print the expect() call that would assert the current screen state, use
    screen:snapshot_util(). In case of non-deterministic failures, use
    screen:redraw_debug() to show all intermediate screen states.
    stack traceback:
            test/functional/ui/screen.lua:579: in function '_wait'
            test/functional/ui/screen.lua:361: in function 'expect'
            test/functional/terminal/ex_terminal_spec.lua:248: in function <test/functional/terminal/ex_terminal_spec.lua:245>
2019-12-22 11:23:39 +01:00
Justin M. Keyes
a3b6c2a3dc API: rename nvim_execute_lua => nvim_exec_lua
- We already find ourselves renaming nvim_execute_lua in tests and
  scripts, which suggests "exec" is the verb we actually want.
- Add "exec" verb to `:help dev-api`.
2019-12-02 22:06:42 -08:00
Justin M. Keyes
c34130d13a API: deprecate nvim_command_output 2019-12-02 20:52:06 -08:00
erw7
1bb7ea189e win_line: Fix crash with 'rightleft' in :terminal #11460
fixes #11438

Backtrace:

    0  schar_from_ascii ( p=0x801cc9e112c3 <error: Cannot access memory at address 0x801cc9e112c3>, c=32 ' ') at ../src/nvim/screen.c:5263
    1  0x00007f31460eccc5 in win_line (wp=wp@entry=0x7fffc9df6230, lnum=lnum@entry=11, startrow=startrow@entry=10, endrow=41, nochange=false, number_only=number_only@entry=false) at ../src/nvim/screen.c:4025
    2  0x00007f31460eed8e in win_update (wp=wp@entry=0x7fffc9df6230) at ../src/nvim/screen.c:1403
    3  0x00007f31460f011f in update_screen (type=<optimized out>) at ../src/nvim/screen.c:502
    4  0x00007f3146138ef4 in normal_redraw (s=s@entry=0x7fffd0a5f700) at ../src/nvim/normal.c:1247
    5  0x00007f314613b159 in normal_check (state=0x7fffd0a5f700) at ../src/nvim/normal.c:1324
    6  0x00007f31460accfe in state_enter (s=0x7fffd0a5f700) at ../src/nvim/state.c:28
    7  0x00007f3146143099 in normal_enter (cmdwin=<optimized out>, noexmode=<optimized out>) at ../src/nvim/normal.c:463
    8  0x00007f314618b541 in main (argc=<optimized out>, argv=<optimized out>) at ../src/nvim/main.c:580
2019-11-28 20:09:03 -08:00
Justin M. Keyes
4abb67c027 test/Screen:expect: replace "{IGNORE}" with "{MATCH:…}"
ref #11004
2019-11-09 22:26:01 -08:00
Justin M. Keyes
7a23b67d35
paste: Select-mode, Visual-mode #11360
fix #11344
2019-11-09 21:18:51 -08:00
Justin M. Keyes
9ef16a1628 doc: vim.fn, vim.call(), vim.api [ci skip] 2019-11-06 01:37:50 -08:00
Björn Linse
f707a7ef68 terminal: add tests for palette color forwarding 2019-11-03 10:14:58 +01:00
Daniel Hahler
4bbad54817
tests: fix non-controversial misuse of pending (#11247)
Ref: https://github.com/neovim/neovim/pull/11184
2019-10-18 04:46:30 +02:00
Daniel Hahler
932edf4f33
tests: tui_spec: fix waiting for terminal to be ready (#11232)
The screen would have '-- TERMINAL --' already initially.

Related to flakiness of "TUI FocusGained/FocusLost in terminal-mode".
2019-10-15 20:50:51 +02:00
Björn Linse
4987311fb5 tests/ui: remove unnecessary screen:detach()
It is perfectly fine and expected to detach from the screen just by
the UI disconnecting from nvim or exiting nvim. Just keep detach() in
screen_basic_spec, to get some coverage of the detach method itself.

This avoids hang on failure in many situations (though one could argue
that detach() should be "fast", or at least "as fast as resize",
which works in press-return already).

Never use detach() just to change the size of the screen, try_resize()
method exists for that specifically.
2019-10-13 22:10:42 +02:00
Björn Linse
a330129a28 tests/ui: cleanup illegitimate usages of "attr_ignore"
"attr_ignore" is an anti-pattern, with snapshot_util()
just include all the highlights already.
2019-10-13 22:10:42 +02:00
Björn Linse
5a85699425 tests/ui: make screen.lua use "linegrid" representation internally
PR #8221 took a short-cut when implementing the tests: screen.lua would
translate the linegrid highlight ids back into the old per-cell
attribute description.

Apart from cleaning up technical debt, this enables to check both rgb
and cterm colors in the same expect(), which previously was needlessly
restricted to ext_hlstate tests only.
2019-10-13 22:10:42 +02:00
Daniel Hahler
cd73a0342a tests: tui_spec: improve/merge OptionSet/deferred
Closes https://github.com/neovim/neovim/pull/11129.
2019-10-04 08:39:16 +02:00
Daniel Hahler
333dc3d138
Fix flaky test: tui_spec: increase timeout (#11134)
Meant to fix:

    [  ERROR   ] test/functional/terminal/tui_spec.lua @ 925: TUI FocusGained/FocusLost in terminal-mode
    test/functional/ui/screen.lua:587: Row 6 did not match.
    Expected:
      |{1:r}eady $                                           |
      |[Process exited 0]                                |
      |                                                  |
      |                                                  |
      |                                                  |
      |*gained                                            |
      |{3:-- TERMINAL --}                                    |
    Actual:
      |{1:r}eady $                                           |
      |[Process exited 0]                                |
      |                                                  |
      |                                                  |
      |                                                  |
      |*:terminal                                         |
      |{3:-- TERMINAL --}                                    |

    To print the expect() call that would assert the current screen state, use
    screen:snapshot_util(). In case of non-deterministic failures, use
    screen:redraw_debug() to show all intermediate screen states.

    stack traceback:
    	test/functional/ui/screen.lua:587: in function '_wait'
    	test/functional/ui/screen.lua:370: in function 'expect'
    	test/functional/terminal/tui_spec.lua:934: in function <test/functional/terminal/tui_spec.lua:925>

I've thought about adding this, but it might not be really relevant, and
slows down the tests a bit (and a warning "warning: Screen test
succeeded immediately" with another test):

```diff
diff --git i/test/functional/terminal/tui_spec.lua w/test/functional/terminal/tui_spec.lua
index ada073c4e..4bc2ab4e0 100644
--- i/test/functional/terminal/tui_spec.lua
+++ w/test/functional/terminal/tui_spec.lua
@@ -818,6 +818,11 @@ describe('TUI FocusGained/FocusLost', function()
       ..'", "-u", "NONE", "-i", "NONE", "--cmd", "set noswapfile noshowcmd noruler"]')
     feed_data(":autocmd FocusGained * echo 'gained'\n")
     feed_data(":autocmd FocusLost * echo 'lost'\n")
+    -- Wait for autocommand to be registered.
+    retry(nil, nil, function()
+      feed_data(":autocmd FocusLost\n")
+      screen:expect{any="         echo 'lost'"}
+    end)
     feed_data("\034\016")  -- CTRL-\ CTRL-N
   end)
```
2019-10-02 04:56:22 +02:00
Daniel Hahler
8a4ae3d664
tui: improve handle_background_color: short-circuit (#11067)
* handle_background_color: short-circuit if handled already

* Unit tests for handle_background_color

* set waiting_for_bg_response to false in tui_terminal_after_startup
  By then it should have been received.
2019-09-30 22:00:55 +02:00
Daniel Hahler
0571145c40
paste: fix handling of "<" in cmdline (#11094)
Fixes https://github.com/neovim/neovim/issues/11088.
2019-09-25 09:15:33 +02:00
Daniel Hahler
2476a97ced
tui_spec: improve "TUI paste: exactly 64 bytes" (#11086)
Doing the screen test first might give insights about a possible
(flaky?) failure, where it looks like "feed_data" is processed out of
order:

    [  ERROR   ] test/functional/terminal/tui_spec.lua @ 561: TUI paste: exactly 64 bytes #10311
    test/functional/helpers.lua:388:
    retry() attempts: 490
    test/functional/terminal/tui_spec.lua:66: Expected objects to be the same.
    Passed in:
    (table: 0x44042de8) {
     *[1] = ' endzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz' }
    Expected:
    (table: 0x41d6e568) {
     *[1] = 'zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz end' }
    stack traceback:
            test/functional/helpers.lua:388: in function 'retry'
            test/functional/terminal/tui_spec.lua:63: in function 'expect_child_buf_lines'
            test/functional/terminal/tui_spec.lua:569: in function <test/functional/terminal/tui_spec.lua:561>

Ref: https://github.com/neovim/neovim/pull/11083#issuecomment-534375201
Build log: https://travis-ci.org/neovim/neovim/jobs/588749739#L5597
2019-09-24 08:35:29 +02:00
Daniel Hahler
4b2d7bb5ea
tests: fix flaky 'scrollback' option deletes lines (only) if necessary (#11003)
Using `screen:expect` with the complete grid appears to fix its
flakiness.

Fixes https://github.com/neovim/neovim/issues/10723.
2019-09-16 19:17:07 +02:00
Jaskaran Singh
3afb397407 syntax, TUI: support "strikethrough"
fix #3436

Includes:
vim-patch:8.0.1038: strike-through text not supported
2019-09-13 14:46:19 -07:00
Justin M. Keyes
492ac04f7e UIEnter/UILeave: fire for embedder UI, builtin TUI
Before this, --embed UIs (without --headless) would not trigger UIEnter.

For TUI, maybe UIEnter isn't useful, but:
- It is less "surprising"/special.
- Makes documentation simpler.
- When TUI becomes a coprocess, it will happen anyway.
2019-09-12 17:04:05 -07:00
Justin M. Keyes
44d45e29ea API/nvim_list_uis(): include "chan" field for TUI
Even though it's always zero currently, it's less confusing if all UIs
have the same fields.
2019-09-12 17:04:05 -07:00
Björn Linse
ffa029ad1c paste: fix paste in terminal mode 2019-09-11 20:12:29 +02:00
Björn Linse
e11dd1110f terminal: fix rgb rendering of palette colors
simplify handling of default colors

nvim is always true color internally, remove ui_rgb_attached() check.

Fix "runtime termguicolors" test. The test actually reflected broken behavior
in (parent) nvim: nvim_ui_set_option("rgb", true) was not respected by existing
:terminal instances, so all 16-palette colors became dark blue.
2019-09-10 20:12:01 +02:00
Justin M. Keyes
05c668f684
paste: fix normal-mode paste by different approach #10976
Forcing insert-mode after the first paste-chunk seems to work, as an
alternative to a9e2bae0eb (insert-before-cursor).

NB: Dot-repeat needs to match the original action.  Since a9e2bae0eb
changed paste to insert-before-cursor, dot-repeat must also. But that
makes dot-repeat unpleasant/unusual.
2019-09-09 08:29:49 -07:00
Justin M. Keyes
a9e2bae0eb paste: insert before cursor always
Inserting "after" the cursor in Normal-mode, for big paste-streams, is
not reliable: sometimes the text "after" the cursor ends up in the
middle of the pasted text.  Maybe the cursor position is not updated?

To avoid weird behavior, always paste "before".  Maybe nvim_put() or
vim.paste() can be fixed more properly later.
2019-09-08 16:42:11 -07:00
Justin M. Keyes
acd2729573 paste: do not clobber msg area for small pastes 2019-09-08 15:37:32 -07:00
Justin M. Keyes
0dea44f93c paste/cmdline: discard all chunks after first line
Problem:  If multiple paste "chunks" are streamed, chunks after the
          first line are pasted into the buffer.
Solution: Check for cmdline-mode for all chunks in a paste-stream.
2019-09-08 15:37:32 -07:00
Justin M. Keyes
d91f4cd7d0
paste: reset 'paste' option immediately #10974
- Workaround #10966: 'paste' option is not always reset.
- In any case there's not much reason to wait until phase=3, because
  pasting in cmdline-mode skips lines after the first line (thus the
  `:set paste .. :set nopaste` dance happens only ~once).
2019-09-08 14:58:47 -07:00
Björn Linse
c705e3fb0b update tests for new resize behavior (resize at pager, but not at :!cmd) 2019-09-08 15:24:14 +02:00
Daniel Hahler
fa90f6cdaa tests: fix flaky "TUI FocusGained/FocusLost in terminal-mode" #10754
* longer timeout with first expect
* Wait for :term to be ready

Failure seen on quickbuild (note the "retry() attempts: 1"):

    09:41:07,627  INFO  - # test/functional/terminal/tui_spec.lua @ 437: TUI FocusGained/FocusLost in terminal-mode
    09:41:07,627  INFO  - not ok 2976 - TUI FocusGained/FocusLost in terminal-mode
    09:41:07,627  INFO  - # test/functional/terminal/tui_spec.lua @ 437
    09:41:07,627  INFO  - # Failure message: ./test/functional/helpers.lua:403:
    09:41:07,627  INFO  - # retry() attempts: 1
    09:41:07,627  INFO  - # ./test/functional/ui/screen.lua:579: Row 1 did not match.
    09:41:07,627  INFO  - # Expected:
    09:41:07,627  INFO  - # |*{1:r}eady $ |
    09:41:07,627  INFO  - # |[Process exited 0] |
    09:41:07,627  INFO  - # | |
    09:41:07,627  INFO  - # | |
    09:41:07,627  INFO  - # | |
    09:41:07,627  INFO  - # |gained |
    09:41:07,628  INFO  - # |{3:-- TERMINAL --} |
    09:41:07,628  INFO  - # Actual:
    09:41:07,628  INFO  - # |*{1: } |
    09:41:07,628  INFO  - # |{4:~ }|
    09:41:07,628  INFO  - # |{4:~ }|
    09:41:07,628  INFO  - # |{4:~ }|
    09:41:07,628  INFO  - # |{5:[No Name] }|
    09:41:07,628  INFO  - # | |
    09:41:07,628  INFO  - # |{3:-- TERMINAL --} |
    09:41:07,628  INFO  - #
    09:41:07,628  INFO  - # To print the expect() call that would assert the current screen state, use
    09:41:07,628  INFO  - # screen:snapshot_util(). In case of non-deterministic failures, use
    09:41:07,628  INFO  - # screen:redraw_debug() to show all intermediate screen states.
    09:41:07,628  INFO  - # stack traceback:
    09:41:07,628  INFO  - #     ./test/functional/helpers.lua:403: in function 'retry'
    09:41:07,628  INFO  - #     test/functional/terminal/tui_spec.lua:441: in function <test/functional/terminal/tui_spec.lua:437>
2019-09-07 22:40:38 -07:00
Justin M. Keyes
7e1c959861 test: Eliminate expect_err
Eliminate `expect_err` in favor of `pcall_err` + `eq` or `matches`.
2019-09-06 17:19:07 -07:00
Björn Linse
1fc6489f30 test: add tests for pager glitches and crashes 2019-09-06 19:38:27 +02:00
Daniel Hahler
d7aea13fee
tests: scrollback_spec: use shell-test instead of awk (#10914)
Ref: #10804
Ref: b64af88
2019-09-04 20:01:38 +02:00
Justin M. Keyes
ead39d6ce6 test/uname(): always lowercase 2019-09-01 22:49:33 -07:00
Edd Barrett
b64af88c84 CI/OpenBSD: run functional tests
Adapt some tests for OpenBSD:

- scrollback_spec:
  - seq(1) is not available on OpenBSD: we'd use jot(1).
  - Instead use a (hopefully) portable awk(1) snippet.
- channels_spec
- job_spec
- tui_spec
2019-09-01 22:49:33 -07:00
Justin M. Keyes
976c6667e1 paste: one undo-block per stream
- All "chunks" in a paste-stream should form a single undo-block. Side
  effect of 7a85792884 was to create an undo-block for each chunk.
- Also: remove old :redraw force logic, irrelevant after 7a85792884.
2019-09-02 02:27:13 +02:00