Commit Graph

4990 Commits

Author SHA1 Message Date
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
Gregory Anders
f1922e78a1 feat: add vim.secure.read()
This function accepts a path to a file and prompts the user if the file
is trusted. If the user confirms that the file is trusted, the contents
of the file are returned. The user's decision is stored in a trust
database at $XDG_STATE_HOME/nvim/trust. When this function is invoked
with a path that is already marked as trusted in the trust database, the
user is not prompted for a response.
2022-11-17 08:23:41 -07:00
zeertzjq
a77be32cf9 test: add a Lua test for swap file created before boot
Change the file modification time instead of uptime.
2022-11-17 22:17:48 +08:00
Jlll1
fedf002cb3
fix(api): nvim_win_set_cursor redraw cursorcolumn for non-current window (#21072)
fix #19063
this fixes the cursorcolumn not being redrawn for non-current windows in `nvim_win_set_cursor()`
2022-11-17 07:18:31 +08:00
Lewis Russell
fa7e1e2601
fix(api): nvim_buf_get_text regression (#21071) 2022-11-15 21:27:42 +00:00
zeertzjq
c70d90dbfd
vim-patch:9.0.0884: mouse shape remains in op-pending mode after failed change (#21066)
Problem:    Mouse shape remains in op-pending mode after failed change.
Solution:   Reset finish_op and restore it. (closes vim/vim#11545)

cdeb65729d
2022-11-15 23:02:48 +08:00
dundargoc
211c568e64
test: don't skip parser_spec on windows (#20294) 2022-11-15 19:33:30 +08:00
Max
e15f61b1bd fix(lua): make vim.deepcopy work with vim.NIL
style: changed double quotes to single quotes

feat: add tests

fix tests
2022-11-14 21:14:27 +01:00
Lewis Russell
f8c6718277
feat(lua-api): avoid unnecessary allocations (#19877)
Lua makes (or reuses) an internal copy of strings, so we can safely push
buf pointers onto the stack.
2022-11-14 18:04:36 +00:00
Lewis Russell
e8cc489acc
feat(test): add Lua forms for API methods (#20152) 2022-11-14 10:01:35 +00:00
dundargoc
5c5187c6f8
test: remove skip for 32-bit MSVC (#21030)
We don't support 32-bit windows anymore so it's not needed.
2022-11-14 16:28:30 +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
bfredl
0a96f18ed7
Merge pull request #21033 from bfredl/winfix
fix(ui): fix some cases of stale highlight definitions
2022-11-13 10:53:59 +01:00
bfredl
d7e7578ada fix(ui): fix some cases of stale highlight definitions
fixes #20695
2022-11-13 10:20:28 +01:00
bfredl
c4f84fc2e2
Merge pull request #20984 from notomo/fix-message-kind-on-history
fix(ui-ext): correct message kind in history before vim.ui_attach()
2022-11-13 09:53:02 +01:00
zeertzjq
e7ba5ba3cd
test(lua/ui_spec): fix Ctrl-C test flakiness (#21039)
Prevent Ctrl-C from flushing the command that starts the prompt.
2022-11-13 08:16:06 +08:00
zeertzjq
47ad4c8701
vim-patch:9.0.0866: no test for what patch 8.2.2207 fixes (#21034)
Problem:    No test for what patch 8.2.2207 fixes.
Solution:   Add a test case. (closes vim/vim#11531)

f7570f2107
2022-11-13 07:06:37 +08:00
Steven Arcangeli
b3f781ba91
fix: vim.ui.input always calls callback #21006
Followup to #20883
Related: #18144

This patch changes the behavior of the default `vim.ui.input` when the user
aborts with `<C-c>`. Currently, it produces an error message + stack and causes
`on_confirm` to not be called. With this patch, `<C-c>` will cause `on_confirm`
to be called with `nil`, the same behavior as when the user aborts with `<Esc>`.
I can think of three good reasons why the behavior should be this way:

1. Easier for the user to understand** It's not intuitive for there to be two
   ways to abort an input dialog that have _different_ outcomes. As a user,
   I would expect any action that cancels the input to leave me in the same
   state. As a plugin author, I see no value in having two possible outcomes for
   aborting the input. I have to handle both cases, but I can't think of
   a situation where I would want to treat one differently than the other.

2. Provides an API that can be overridden by other implementations** The current
   contract of "throw an error upon `<C-c>`" cannot be replicated by async
   implementations of `vim.ui.input`. If the callsite wants to handle the case
   of the user hitting `<C-c>` they need to use `pcall(vim.ui.input, ...)`,
   however an async implementation will instantly return and so there will be no
   way for it to produce the same error-throwing behavior when the user inputs
   `<C-c>`. This makes it impossible to be fully API-compatible with the
   built-in `vim.ui.input`.

3. Provides a useful guarantee to the callsite** As a plugin author, I want the
   guarantee that `on_confirm` will _always_ be called (only catastrophic errors
   should prevent this). If I am in the middle of some async thread of logic,
   I need some way to resume that logic after handing off control to
   `vim.ui.input`. The only way to handle the `<C-c>` case is with `pcall`,
   which as already mentioned, breaks down if you're using an alternative
   implementation.
2022-11-12 06:57:35 -08:00
Thomas Vigouroux
7e6d785d19 feat(extmarks): allow preventing spellchecking with spell = false 2022-11-12 10:19:01 +00:00
Justin M. Keyes
4d2373f5f6
feat(checkhealth): use "help" syntax, avoid tabpage #20879
- If Nvim was just started, don't create a new tab.
- Name the buffer "health://".
- Use "help" syntax instead of "markdown". It fits better, and
  eliminates various workarounds.
- Simplfy formatting, avoid visual noise.
- Don't print a "INFO" status, it is noisy.
- Drop the ":" after statuses, they are already UPPERCASE and highlighted.
2022-11-11 18:33:31 -08:00
zeertzjq
2425fe2dc5
vim-patch:8.2.2207: illegal memory access if popup menu items are changed (#21028)
Problem:    Illegal memory access if popup menu items are changed while the
            menu is visible. (Tomáš Janoušek)
Solution:   Make a copy of the text. (closes vim/vim#7537)

38455a9213

Co-authored-by: Bram Moolenaar <Bram@vim.org>
2022-11-12 09:57:29 +08:00
zeertzjq
fc7ac688c3
fix(messages): don't set cmdline_row when messages have scrolled (#21015)
When 'cmdheight' is changed while messages have scrolled, the position
of msg_grid is not moved up, so cmdline_row should not be set based on
the position of msg_grid.
2022-11-11 16:46:45 +08:00
zeertzjq
f2857dcd5a
fix(messages): reset msg_grid_scroll_discount when redrawing (#21000) 2022-11-10 06:16:54 +08:00
Jongwook Choi
59ff4691f6
fix(vim.ui.input): return empty string when inputs nothing (#20883)
fix(vim.ui.input): return empty string when inputs nothing

The previous behavior of `vim.ui.input()` when typing <CR> with
no text input (with an intention of having the empty string as input)
was to execute `on_confirm(nil)`, conflicting with its documentation.

Inputting an empty string should now correctly execute `on_confirm('')`.
This should be clearly distinguished from cancelling or aborting the
input UI, in which case `on_confirm(nil)` is executed as before.
2022-11-08 08:15:15 +08:00
luukvbaal
8147d3df28
vim-patch:9.0.0844: handling 'statusline' errors is spread out (#20992)
Problem:    Handling 'statusline' errors is spread out.
Solution:   Pass the option name to the lower levels so the option can be
            reset there when an error is encountered. (Luuk van Baal,
            closes vim/vim#11467)

7b224fdf4a
2022-11-08 07:21:22 +08:00
Famiu Haque
c022140ec6 feat(api): add command name to Lua command callback opts
Adds a `name` key to the opts dict passed to Lua command callbacks
created using `nvim_create_user_command()`. This is useful for when
multiple commands use the same callback.

Note that this kind of behavior is not as strange as one might think,
even some internal Neovim commands reuse the same internal C function,
differing their behavior by checking the command name. `substitute`,
`smagic` and `snomagic` are examples of that.

This will also be useful for generalized Lua command preview functions
that can preview a wide range of commands, in which case knowing the
command name is necessary for the preview function to actually be able
to execute the command that it's supposed to preview.
2022-11-07 22:27:37 +06:00
Victor Blanchard
d337814906
feat: ":write ++p" creates parent dirs #20835
- `:write ++p foo/bar/baz.txt` should create parent directories `foo/bar/` if
   they do not exist
    - Note: `:foo ++…` is usually for options. No existing options have
      a single-char abbreviation (presumably by design), so it's safe to
      special-case `++p` here.
- Same for `writefile(…, 'foo/bar/baz.txt', 'p')`
- `BufWriteCmd` can see the ++p flag via `v:cmdarg`.

closes #19884
2022-11-06 19:31:50 -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
notomo
72f8613e97 fix(ui-ext): correct message kind in history before vim.ui_attach() 2022-11-07 10:20:27 +09:00
Raphael
1af4bd04f9
feat(ui): add support to display a title in the border of a float (#20184)
add "title" and "title_pos" keys to win config dict.
2022-11-06 11:59:43 +01:00
zeertzjq
850d7146fc
fix(paste): feed keys as typed in cmdline mode (#20959) 2022-11-06 12:43:05 +08:00
zeertzjq
01ccfb40e3 vim-patch:8.2.1106: crash when trying to use s: variable in typed command
Problem:    Crash when trying to use s: variable in typed command.
Solution:   Don't use the script index when not set. (Ken Takata,
            closes vim/vim#6366)

8e6cbb7232
2022-11-05 21:38:36 +08:00
zeertzjq
6374120558 vim-patch:8.2.4501: with 'showbreak' set cursor displayed in wrong position
Problem:    With 'showbreak' set and after the end of the line the cursor
            may be displayed in the wrong position.
Solution:   Do not apply 'showbreak' after the end of the line. (closes vim/vim#9884)

21efafe4c2

Co-authored-by: Bram Moolenaar <Bram@vim.org>
2022-11-05 19:35:56 +08:00
zeertzjq
a86295cd5c
vim-patch:8.2.0615: regexp benchmark stest is old style (#20940)
Problem:    Regexp benchmark stest is old style.
Solution:   Make it a new style test.  Fix using a NULL list.  Add more tests.
            (Yegappan Lakshmanan, closes vim/vim#5963)

ad48e6c159

N/A patches:
vim-patch:9.0.0829: wrong counts in macro comment
2022-11-05 12:26:17 +08:00
Will Spurgin
19a487bc86
fix(fileio): use first available directory in backupdir for backupcopy (#20655)
Fix backups failing for symlink files

Set backup to NULL prior to continuing & Clear backup prior to NULL set
to avoid leaking

Fixes #11349

Remove testing hacks in scripts for windows

Skip FreeBSD

Something appears up with these types of tests for FreeBSD on
Circus, see 2d6735d8ce
2022-11-05 09:24:34 +08:00
zeertzjq
2476f41a4a vim-patch:8.2.1022: various parts of code not covered by tests
Problem:    Various parts of code not covered by tests.
Solution:   Add more tests. (Yegappan Lakshmanan, closes vim/vim#6300)

845e0ee594

Omit test_iminsert.vim: the commit that created this file was N/A.
Omit test_viminfo.vim: the added tests are N/A.
2022-11-04 20:54:50 +08:00
zeertzjq
dce3fc3e9a
vim-patch:8.2.0540: regexp and other code not tested (#20930)
Problem:    Regexp and other code not tested.
Solution:   Add more tests. (Yegappan Lakshmanan, closes vim/vim#5904)

004a6781b3
2022-11-04 19:31:58 +08:00
Jonathon
04fbb1de44
Enable new diff option linematch (#14537)
Co-authored-by: Lewis Russell <me@lewisr.dev>
2022-11-04 09:07:22 +00:00
dundargoc
4716a578ae docs: fix typos 2022-11-02 21:45:26 +08:00
zeertzjq
428ab6f24e
fix(mark): do not restore view in op-pending mode (#20889) 2022-11-01 06:14:20 +08:00
Justin M. Keyes
cc7c378bf3 feat(checkhealth): check runtime ($VIMRUNTIME)
Move man/health.lua into the "runtime" check.

fix #20696
2022-10-30 16:23:58 +01:00
zeertzjq
23080a4d7a
fix(mouse): ensure no scrolling with "ver:0" in 'mousescroll' (#20861) 2022-10-30 07:10:39 +08:00
zeertzjq
f2d9c330fc
fix(path): don't remove trailing slash when getting absolute path (#20853)
Before Vim patch 8.2.3468 relative_directory is never used in the
resulting path name, so whether it has a trailing slash didn't matter.
Now path_full_dir_name() appends a non-existing relative directory to
the current directory name, so the trailing slash needs to be kept.
2022-10-30 07:10:04 +08:00
zeertzjq
a7d100f052
fix: avoid unsigned overflow in home_replace() (#20854) 2022-10-30 06:49:39 +08:00
zeertzjq
25cf4f2fc7 vim-patch:8.2.2653: build failure
Problem:    Build failure.
Solution:   Add missing changes.

3a0f092ac0

Omit E1176: only applicable to Vim9 script.

Co-authored-by: Bram Moolenaar <Bram@vim.org>
2022-10-27 13:07:51 +08:00
zeertzjq
46a54dd6a0 vim-patch:8.2.1852: map() returing zero for NULL list is unexpected
Problem:    map() returing zero for NULL list is unexpected.
Solution:   Return the empty list. (closes vim/vim#7133)

ffdf8adfa8

Co-authored-by: Bram Moolenaar <Bram@vim.org>
2022-10-26 20:53:39 +08:00
zeertzjq
cfccae9584 vim-patch:8.2.0610: some tests are still old style
Problem:    Some tests are still old style.
Solution:   Convert to new style tests. (Yegappan Lakshmanan, closes vim/vim#5957)

08f4157c5c

Fix missing error message when sort() compare function fails.
Cherry-pick a line in test_utf8.vim from patch 8.2.0448.
Cherry-pick builtin_function() change from patch 8.2.0595.
2022-10-26 20:53:39 +08:00
bfredl
40791f8e82
Merge pull request #20775 from shadmansaleh/fix/opt_tal_not_redrawing_tabline
fix: setting tabline option not redrawing tabline
2022-10-24 20:05:02 +02:00
shadmansaleh
a53998ae78 fix: setting tabline option not redrawing tabline
With #20374 tabline option is marked with 'statuslines' redraw flag.
But 'statuslines' doesn't redraw tabline. As a result, tabline doesn't
get redrawn when tabline option is set and statuslines get unnecessarily redrawn.

This patch fixes the issue by adding a new redraw flag P_RTABL to redraw
tabline.
2022-10-24 21:14:41 +06:00
NAKAI Tsuyoshi
4573cfa3ad
fix(lua): pesc, tbl_islist result types #20751
Problem:
- pesc() returns multiple results, it should return a single result.
- tbl_islist() returns non-boolean in some branches.
- Docstring: @generic must be declared first

Solution:
Constrain docstring annotations.
Fix return types.

Co-authored-by: Justin M. Keyes <justinkz@gmail.com>
2022-10-24 05:53:53 -07:00