| Commit message (Collapse) | Author | Age |
... | |
| |
| |
| |
| |
| |
| | |
- reduce variable scope
- prefer initialization over declaration and assignment
- use bool to represent boolean values
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
Problem: recursive callback may cause issues on some archs
Solution: Decrease the limit drastically to 20
Recursive callback limit causes problems on some architectures
Since commit 47510f3d6598a1218958c03ed11337a43b73f48d we have a test
that causes a recursive popup callback function to be executed. However
it seems the current limit of 'maxfuncdepth' option value is still too
recursive for some 32bit architectures (e.g. 32bit ARM).
So instead of allowing a default limit of 100 (default value for
'maxfuncdepth'), let's reduce this limit to 20. I don't think there is a
use case where one would need such a high recursive callback limit and a
limit of 20 seems reasonable (although it is currently hard-coded).
closes: vim/vim#13495
closes: vim/vim#13502
https://github.com/vim/vim/commit/2076463e383901cef44685aaf4b63e4306444f9e
Co-authored-by: Christian Brabandt <cb@256bit.org>
|
| |
| |
| |
| |
| |
| |
| | |
We already have an extensive suite of static analysis tools we use,
which causes a fair bit of redundancy as we get duplicate warnings. PVS
is also prone to give false warnings which creates a lot of work to
identify and disable.
|
| | |
|
| |
| |
| |
| | |
When the given length is exactly the number of bytes to copy, xmemdupz()
makes the intention clearer.
|
| |
| |
| |
| |
| |
| | |
long is 32 bits on windows, while it is 64 bits on other architectures.
This makes the type suboptimal for a codebase meant to be
cross-platform. Replace it with more appropriate integer types.
|
| |
| |
| |
| |
| |
| |
| |
| | |
While the interfaces for setting number and boolean options are now unified by #25394, there is still a separate `set_string_option` function that is used for setting a string option. This PR removes that function and merges it with set_option.
BREAKING CHANGE: `v:option_old` is now the old global value for all global-local options, instead of just string global-local options. Local value for a global-local number/boolean option is now unset when the option is set (e.g. using `:set` or `nvim_set_option_value`) without a scope, which means they now behave the same way as string options.
Ref: #25672
|
| | |
|
| |
| |
| |
| | |
BREAKING CHANGE: This breaks the OptionSet autocommand, as the `v:` values associated with it (`v:option_new`, `v:option_old`, `v:option_oldlocal` and `v:option_oldglobal`) are now the same type as the option, instead of all option values being converted to strings.
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
Problem: no max callback recursion limit
Solution: bail out, if max call recursion for callback functions
has been reached.
This checks the 'maxfuncdepth' setting and throws E169 when a callback
function recursively calls itself.
closes: vim/vim#13337
closes: vim/vim#13339
https://github.com/vim/vim/commit/47510f3d6598a1218958c03ed11337a43b73f48d
Co-authored-by: Christian Brabandt <cb@256bit.org>
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
PROBLEM:
Currently `:echoerr` prints multi-line strings in a single line
as `:echom` does (Note: `:echon` can print multi-line strings well).
This makes stacktrace printed via echoerr difficult to read.
Example code:
try
lua error("lua stacktrace")
catch
echoerr v:exception
endtry
Output:
Error detected while processing a.vim[5]..a.vim:
line 4:
Vim(lua):E5108: Error executing lua [string ":lua"]:1: lua stacktrace^@stack traceback:^@^I[C]: in function 'error'^@^I[string ":lua"]:1: in main chunk
SOLUTION:
Allow echoerr to print multiline messages (e.g., lua exceptions),
because this command is usually used to print stacktraces.
Output after the fix:
Error detected while processing a.vim[5]..a.vim:
line 4:
Vim(lua):E5108: Error executing lua [string ":lua"]:1: lua stacktrace
stack traceback:
[C]: in function 'error'
[string ":lua"]:1: in main chunk
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
(#25605)
Problem: Vim9: in script cannot set item in uninitialized list.
Solution: When a list is NULL allocate an empty one. (closes vim/vim#8461)
https://github.com/vim/vim/commit/e65081d1b591f16dc6e380a830d87565c5eb7b03
Co-authored-by: Bram Moolenaar <Bram@vim.org>
|
| |
| |
| |
| |
| |
| | |
Problem: The style guide states that all switch statements that are not conditional on an enum must have a `default` case, but does not give any explicit guideline for switch statements that are conditional on enums. As a result, a `default` case is added in many enum switch statements, even when the switch statement is exhaustive. This is not ideal because it removes the ability to have compiler errors to easily detect unchanged switch statements when a new possible value for an enum is added.
Solution: Add explicit guidelines for switch statements that are conditional on an enum, clarifying that a `default` case is not necessary if the switch statement is exhaustive. Also refactor pre-existing code with unnecessary `default` cases.
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
This adds the checks in https://neovim.io/doc/reports/clang/ when using
clang-tidy. The strategy is to enable all clang-analyzer checks, and
disable only the checks for the warnings that exist currently. This
allows us to eliminate each warning type without blocking ongoing work,
but also without adding bugs for already eliminated warnings.
The plan is to eventually eliminate https://neovim.io/doc/reports/clang/
by completely integrating it into the clang-tidy check.
Also add make and cmake targets `clang-analyzer` to run this check.
|
| |
| |
| |
| |
| |
| | |
long is 32 bits on windows, while it is 64 bits on other architectures.
This makes the type suboptimal for a codebase meant to be
cross-platform. Replace it with more appropriate integer types.
|
| |
| |
| |
| |
| |
| |
| |
| | |
Problem: Invalid memory access when 'foldexpr' returns empty string.
Solution: Check for NUL.
closes: vim/vim#13293
https://github.com/vim/vim/commit/a991ce9c083bb8c02b1b1ec34ed35728197050f3
|
| |
| |
| |
| |
| |
| | |
long is 32 bits on windows, while it is 64 bits on other architectures.
This makes the type suboptimal for a codebase meant to be
cross-platform. Replace it with more appropriate integer types.
|
| |
| |
| |
| |
| |
| |
| |
| |
| | |
msg_puts_display was more complex than necessary in nvim, as in
nvim, it no longer talks directly with a terminal.
In particular we don't need to scroll the grid before emiting the last
char. The TUI already takes care of things like that, for terminals
where it matters.
|
| | |
|
| | |
|
| |
| |
| |
| |
| |
| | |
- Move vimoption_T to option.h
- option_defs.h is for option-related types
- option_vars.h corresponds to Vim's option.h
- option_defs.h and option_vars.h don't include each other
|
| | |
|
| | |
|
| | |
|
| | |
|
| |
| |
| |
| |
| | |
problem: there are too many different functions in message.c
solution: fold some of the functions into themselves
|
| |
| |
| |
| |
| |
| |
| |
| |
| | |
Problem: Cannot use an import in 'foldexpr'.
Solution: Set the script context to where 'foldexpr' was set. (closes vim/vim#9584)
Fix that the script context was not set for all buffers.
https://github.com/vim/vim/commit/e70dd11ef41f69bd5e94f630194e6b3c4f3f2102
Co-authored-by: Bram Moolenaar <Bram@vim.org>
|
| |
| |
| | |
Co-authored-by: Lewis Russell <lewis6991@gmail.com>
|
| |
| |
| |
| |
| |
| |
| | |
Problem: Duplicate code for converting float to string.
Solution: Use tv_get_string(). (closes vim/vim#12521)
https://github.com/vim/vim/commit/19dfa276c37dcf657922c6f9b48cf2954191e8b6
|
| |
| |
| |
| |
| |
| |
| |
| |
| | |
Problem: Vim9: ":put =expr" does not handle a list properly.
Solution: Use the same logic as eval_to_string_eap(). (closes vim/vim#7684)
https://github.com/vim/vim/commit/883cf97f109d2ff281cf77f7b2e3bb44aced7cb3
Co-authored-by: Bram Moolenaar <Bram@vim.org>
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
This involves two redesigns of the map.c implementations:
1. Change of macro style and code organization
The old khash.h and map.c implementation used huge #define blocks with a
lot of backslash line continuations.
This instead uses the "implementation file" .c.h pattern. Such a file is
meant to be included multiple times, with different macros set prior to
inclusion as parameters. we already use this pattern e.g. for
eval/typval_encode.c.h to implement different typval encoders reusing a
similar structure.
We can structure this code into two parts. one that only depends on key
type and is enough to implement sets, and one which depends on both key
and value to implement maps (as a wrapper around sets, with an added
value[] array)
2. Separate the main hash buckets from the key / value arrays
Change the hack buckets to only contain an index into separate key /
value arrays
This is a common pattern in modern, state of the art hashmap
implementations. Even though this leads to one more allocated array, it
is this often is a net reduction of memory consumption. Consider
key+value consuming at least 12 bytes per pair. On average, we will have
twice as many buckets per item.
Thus old implementation:
2*12 = 24 bytes per item
New implementation
1*12 + 2*4 = 20 bytes per item
And the difference gets bigger with larger items.
One might think we have pulled a fast one here, as wouldn't the average size of
the new key/value arrays be 1.5 slots per items due to amortized grows?
But remember, these arrays are fully dense, and thus the accessed memory,
measured in _cache lines_, the unit which actually matters, will be the
fully used memory but just rounded up to the nearest cache line
boundary.
This has some other interesting properties, such as an insert-only
set/map will be fully ordered by insert only. Preserving this ordering
in face of deletions is more tricky tho. As we currently don't use
ordered maps, the "delete" operation maintains compactness of the item
arrays in the simplest way by breaking the ordering. It would be
possible to implement an order-preserving delete although at some cost,
like allowing the items array to become non-dense until the next rehash.
Finally, in face of these two major changes, all code used in khash.h
has been integrated into map.c and friends. Given the heavy edits it
makes no sense to "layer" the code into a vendored and a wrapper part.
Rather, the layered cake follows the specialization depth: code shared
for all maps, code specialized to a key type (and its equivalence
relation), and finally code specialized to value+key type.
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
ml_get_buf() takes a third parameters to indicate whether the
caller wants to mutate the memline data in place. However
the vast majority of the call sites is using this function
just to specify a buffer but without any mutation. This makes
it harder to grep for the places which actually perform mutation.
Solution: Remove the bool param from ml_get_buf(). it now works
like ml_get() except for a non-current buffer. Add a new
ml_get_buf_mut() function for the mutating use-case, which can
be grepped along with the other ml_replace() etc functions which
can modify the memline.
|
| |
| |
| |
| |
| |
| |
| |
| |
| | |
Problem: Cannot check the current state.
Solution: Add the state() function.
https://github.com/vim/vim/commit/0e57dd859ecb1e8a3b91509d2f4343e839340eb8
Co-authored-by: Bram Moolenaar <Bram@vim.org>
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
Problem: Fix regression in {func} argument of reduce()
Solution: pass function name as string again
Before patch 9.0.0548, passing a string as {func} argument of reduce()
is treated as a function name, but after patch 9.0.0548 it is treated as
an expression instead, which is useless as reduce() doesn't set any v:
variables. This PR restores the behavior of {func} before that patch.
Also correct an emsg() call, as e_string_list_or_blob_required doesn't
contain format specifiers.
closes: vim/vim#12824
https://github.com/vim/vim/commit/ad0c442f1fcc6fe9c433777ee3e5b9e6addc6d69
|
| |
| |
| |
| |
| |
| |
| |
| |
| | |
Problem: Crash when collection is modified when using filter().
Solution: Lock the list/dict/blob. (Ernie Rael, closes vim/vim#12183)
https://github.com/vim/vim/commit/e6d40dcdc7227594935d2db01eca29f0e575dcee
Co-authored-by: Ernie Rael <errael@raelity.com>
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
Problem: Functions implementing reduce and map are too long.
Solution: Use a function for each type of value. Add a few more test cases
and add to the help. (Yegappan Lakshmanan, closes vim/vim#9370)
https://github.com/vim/vim/commit/389b72196e6aaeafe3f907c73d271f2c6b931140
Partial port as this doesn't include handling for non-materialized List.
Co-authored-by: Yegappan Lakshmanan <yegappan@yahoo.com>
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
Problem: Cannot use reduce() for a string.
Solution: Make reduce() work with a string. (Naruhiko Nishino, closes vim/vim#9366)
https://github.com/vim/vim/commit/0ccb5842f5fb103763d106c7aa364d758343c35a
Omit tv_get_first_char() as it doesn't really save much code.
Co-authored-by: rbtnn <naru123456789@gmail.com>
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
Problem: Cannot use a script-local function for 'foldtext'.
Solution: Expand "s:" and "<SID>". (Yegappan Lakshmanan, closes vim/vim#9411)
https://github.com/vim/vim/commit/27708e6c7b6f444fd599f3dc5015336b002b874d
Cherry-pick test_filter_map.vim change from patch 8.2.3871.
Co-authored-by: Yegappan Lakshmanan <yegappan@yahoo.com>
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
Problem: Leaking memory in map() and filter(), cannot use a string argument
in Vim9 script.
Solution: Fix the leak, adjust the argument check, also run the tests as
Vim9 script. (Yegappan Lakshmanan, closes vim/vim#9354)
https://github.com/vim/vim/commit/2d877599ee1cede063ef4abe3a2272e67c116238
Co-authored-by: Bram Moolenaar <Bram@vim.org>
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
Problem: Cannot filter or map characters in a string.
Solution: Make filter() and map() work on a string. (Naruhiko Nishino,
closes vim/vim#9327)
https://github.com/vim/vim/commit/c479ce032f5d4d14bab9e479acbf42d758879893
Co-authored-by: rbtnn <naru123456789@gmail.com>
|
| |
| |
| |
| |
| |
| |
| |
| |
| | |
Problem: Error for const argument to mapnew().
Solution: Don't give an error. (closes vim/vim#7400)
https://github.com/vim/vim/commit/57cf4973a283941c92744554474b2c52ce892fd1
Co-authored-by: Bram Moolenaar <Bram@vim.org>
|
| |
| |
| |
| |
| |
| |
| |
| |
| | |
Problem: Memory leak when map() fails.
Solution: Clear the typval.
https://github.com/vim/vim/commit/c56936e2ba4fd219f56aab616fcb283132455697
Co-authored-by: Bram Moolenaar <Bram@vim.org>
|
| |
| |
| |
| |
| |
| |
| |
| |
| | |
Problem: Vim9: map() may change the list or dict item type.
Solution: Add mapnew().
https://github.com/vim/vim/commit/ea696852e7abcdebaf7f17a7f23dc90df1f5e2ed
Co-authored-by: Bram Moolenaar <Bram@vim.org>
|
| |
| |
| |
| | |
followup to #24109
fix #16150
|
| |
| |
| |
| |
| |
| |
| |
| |
| | |
Problem: Vim9: cannot assign to range in list.
Solution: Implement overwriting a list range.
https://github.com/vim/vim/commit/4f0884d6e24d1d45ec83fd86b372b403177d3298
Co-authored-by: Bram Moolenaar <Bram@vim.org>
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
Problem: Vim9: not enough tests.
Solution: Also run existing tests for Vim9 script. Make errors more
consistent.
https://github.com/vim/vim/commit/f47c5a8e2d8eda7c2c8a9cccf9568eb56c03a0cf
Co-authored-by: Bram Moolenaar <Bram@vim.org>
|
| |
| |
| |
| |
| |
| |
| |
| |
| | |
Problem: Vim9: cannot use a range with :unlet.
Solution: Implement ISN_UNLETRANGE.
https://github.com/vim/vim/commit/5b5ae29bd3d7b832b6f15320430f7f191e0abd1f
Co-authored-by: Bram Moolenaar <Bram@vim.org>
|
| |
| |
| |
| | |
This reverts commit 82cd0be2eaf71c0476e15c66ba3e83c76896d407.
|
| |
| |
| |
| |
| |
| |
| |
| | |
Removes the `getoption_T` struct and also introduces the `OptVal` struct
to unify the methods of getting/setting different option value types.
This is the first of many PRs to reduce code duplication in the Vim
option code as well as to make options easier to maintain. It also
increases the flexibility and extensibility of options. Which opens the
door for things like Array and Dictionary options.
|
| |
| |
| |
| |
| |
| |
| |
| |
| | |
Problem: Cursor ends up below the window after a put.
Solution: Mark w_crow and w_botline invalid when changing the cursor line.
(closes vim/vim#12465)
https://github.com/vim/vim/commit/8509014adda188ee8bdf6a2e123fbf15a91b29d2
Co-authored-by: Bram Moolenaar <Bram@vim.org>
|