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.
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.
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.
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.
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.
- 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).
* 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>
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
- 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.
Otherwise cursor and redraw code for normal and insert mode will not run. The
"tickle" workaround was used for this instead, and can now be removed.
The builtin vim.lua got the name
[string "-- Nvim-Lua stdlib: thevimmodule (:help l..."]
in error messages. Fix it to something reasonable.
- Introduce TRY_WRAP() until we have an *architectural* solution.
- TODO: bfredl idea: prepare error-handling at "top level" (nv_event).
- nvim_paste(): Revert luaeval() hack (see parent commit).
- With TRY_WRAP() in nvim_put(), 'nomodifiable' error now correctly
"bubbles up".
- nvim_paste(): Marshal through luaeval() instead of nvim_execute_lua()
because the latter seems to hide some errors.
- Handle 'nomodifiable' in `nvim_put()` explicitly.
- Require explicit `false` from `vim.paste()` in order to "cancel",
otherwise assume true ("continue").
- Show error only once per "paste stream".
- Drain remaining chunks until phase=3.
- Lay groundwork for "cancel".
- Constrain semantics of "cancel" to mean "client must stop"; it is
unrelated to presence of error(s).
Workaround this failure:
[ ERROR ] test/functional/terminal/tui_spec.lua @ 192: TUI paste: exactly 64 bytes
test/functional/helpers.lua:403:
retry() attempts: 478
test/functional/terminal/tui_spec.lua:201: Expected objects to be the same.
Passed in:
(table: 0x47cd77e8) {
*[1] = 'zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz endz' }
Expected:
(table: 0x47cd7830) {
*[1] = 'zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz end' }
This happens because `curwin->w_cursor.col` is sometimes decremented at
the end of `do_put`... because the editor is in Normal-mode instead of
the expected Insert-mode.
Caused by "typeahead race" (#10826): there may be queued input in the
main thread not yet processed, thus the editor mode (`State` global)
will be "wrong" during paste. Example: input "i" followed immediately by
a paste sequence:
i<start-paste>...<stop-paste>
^
"i" does not get processed in time, so the editor is in
Normal-mode instead of Insert-mode while handling the paste.
Attempted workarounds:
- vim.api.nvim_feedkeys('','x',false) in vim._paste()
- exec_normal() in tinput_wait_enqueue()
- LOOP_PROCESS_EVENTS(&main_loop,…,0) in tinput_wait_enqueue()
ref #10826
Fixes strange behavior where sometimes the buffer contents of a series
of paste chunks (vim._paste) would be out-of-order.
Now the tui_spec.lua screen-tests are much more reliable. But they still
sometimes fail because of off-by-one cursor (caused by "typeahead race"
resulting in wrong mode; fixed later in this patch-series).
Also fix V576: use width specification
> Incorrect format. Consider checking the third actual argument of the
> 'sscanf' function. It's dangerous to use string specifier without width
> specification. Buffer overflow is possible.
<Paste> is a 3-byte sequence and the beginning one or two bytes can appear at
the very end of the typeahead buffer. When this happens, we were exiting from
`vgetorpeek()` instead of reading more characters to see the complete sequence.
I think this should fix#7994 -- at least partially. Before this change, when I
paste exactly 64 characters into a freshly booted instance, I get what I pasted
plus the literal text "<Paste>" at the end. Nvim also stays in nopaste mode.
The attached test case fails in this manner without the code change.
Fix#7994
Problem: When we changed startup to wait for the TUI (like a remote UI),
we forgot to set os/input.c:global_fd. That used to be done by
input_start().
Solution: Initialize os/input.c:global_fd before initializing libtermkey
(termkey_new_abstract) so that tui_get_stty_erase() and
friends can inspect the correct fd.
fixes#10134close#10174