aboutsummaryrefslogtreecommitdiff
path: root/test/functional/api/buffer_spec.lua
Commit message (Collapse)AuthorAge
* fix(api): load buffer first on nvim_buf_set_lines (#25823)Raphael2023-10-29
| | | | Fix #22670 Fix #8659
* fix(api): more intuitive cursor updates in nvim_buf_set_textSergey Slipchenko2023-09-11
| | | | Fixes #22526
* fix(api): nvim_buf_get_offset in a new buffer with zero or one linesbfredl2023-08-30
| | | | fixes #24930
* fix(api): better topline adjustments in nvim_buf_set_linesbfredl2023-08-29
| | | | | | | Some more reasonable defaults for topline: - if topline was replaced with another line, that now becomes topline - if line was inserted just before topline, display it. This is more similar to the previous API behavior.
* fix(api): handle clearing out last line of non-current bufferbfredl2023-08-28
| | | | fixes #24911
* fix(undo): fix crash caused by checking undolevels in wrong bufferbfredl2023-08-27
| | | | fixes #24894
* fix(api): fix inconsistent behavior of topline touched in recent refactorbfredl2023-08-27
| | | | | | | | | | | | | | | | The change in #24824 0081549 was not a regression, however it was an incomplete change. Unfortunately some common plugins come to depend on this exising self-inconsistent behavior. These plugins are going to need to update for 0.10 nvim_buf_set_lines used to NOT adjust the topline correctly if a buffer was displayed in just one window. However, if displayed in multiple windows, it was correctly adjusted for any window not deemed the current window for the buffer (which could be an arbitrary choice if the buffer was not already current, as noted in the last rafactor) This fixes so that all windows have their topline adjusted. The added tests show this behavior, which should be the reasonable one.
* refactor(change): do API changes to buffer without curbuf switchbfredl2023-08-26
| | | | | | | | | | | | | | | | | | | | | | | Most of the messy things when changing a non-current buffer is not about the buffer, it is about windows. In particular, it is about `curwin`. When editing a non-current buffer which is displayed in some other window in the current tabpage, one such window will be "borrowed" as the curwin. But this means if two or more non-current windows displayed the buffers, one of them will be treated differenty. this is not desirable. In particular, with nvim_buf_set_text, cursor _column_ position was only corrected for one single window. Two new tests are added: the test with just one non-current window passes, but the one with two didn't. Two corresponding such tests were also added for nvim_buf_set_lines. This already worked correctly on master, but make sure this is well-tested for future refactors. Also, nvim_create_buf no longer invokes autocmds just because you happened to use `scratch=true`. No option value was changed, therefore OptionSet must not be fired.
* fix(api): allow negative column arguments for nvim_buf_set_text (#23501)notomo2023-07-04
|
* refactor(defaults): do not use C specific default values for options (#22500)Gregory Anders2023-06-06
| | | | | | | | | | The options 'path', 'include', and 'define' all use C-specific default values. This may have made sense a long time ago when Vim was mostly used just for writing C, but this is no longer the case, and we have ample support for filetype specific configuration. Make the default values of these options empty and move the C-specific values into a filetype plugin where they belong. Co-authored-by: zeertzjq <zeertzjq@outlook.com>
* test: don't unnecessarily specify win/buf for `nvim_(get|set)_option_value`Famiu Haque2023-05-22
| | | | `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.
* refactor(options): deprecate nvim[_buf|_win]_[gs]et_optionLewis Russell2023-05-21
| | | | | Co-authored-by: zeertzjq <zeertzjq@outlook.com> Co-authored-by: famiu <famiuhaque@protonmail.com>
* refactor(api): VALIDATE macros #22256Justin M. Keyes2023-02-14
| | | | | | - VALIDATE() takes a format string - deduplicate check_string_array - VALIDATE_RANGE - validate UI args
* fix(api): nvim_buf_get_text regression (#21071)Lewis Russell2022-11-15
|
* feat(lua-api): avoid unnecessary allocations (#19877)Lewis Russell2022-11-14
| | | | Lua makes (or reuses) an internal copy of strings, so we can safely push buf pointers onto the stack.
* feat(test): add Lua forms for API methods (#20152)Lewis Russell2022-11-14
|
* fix(api): fix nvim_buf_set_text heap-use-after-free (#19644)zeertzjq2022-08-06
| | | | The line returned but ml_get_buf() may be freed by another call to ml_get_buf(), so it is necessary to make a copy.
* fix(api): check for inclusive buffer line index out of bounds correctly (#19056)zeertzjq2022-06-23
|
* fix(api)!: correctly handle negative line numbers for nvim_buf_set_text (#17498)Gregory Anders2022-02-23
| | | | | | | | | | | | | | | | | | | | | | | | nvim_buf_set_text does not handle negative row numbers correctly: for example, nvim_buf_set_text(0, -2, 0, -1, 20, {"Hello", "world"}) should replace the 2nd to last line in the buffer with "Hello" and the first 20 characters of the last line with "world". Instead, it reports "start_row out of bounds". This happens because when negative line numbers are used, they are incremented by one additional number to make the non-negative line numbers end-exclusive. However, the line numbers for nvim_buf_set_text should be end-inclusive. In #15181 we handled this for nvim_buf_get_text by adding a new parameter to `normalize_index`. We can solve the problem with nvim_buf_set_text by simply availing ourselves of this new argument. This is a breaking change, but makes the semantics of negative line numbers much clearer and more obvious (as well as matching nvim_buf_get_text). BREAKING CHANGE: Existing usages of nvim_buf_set_text that use negative line numbers will be off-by-one.
* feat(api): implement nvim_buf_get_text (#15181)Gregory Anders2022-02-22
| | | | | | | | | | nvim_buf_get_text is the mirror of nvim_buf_set_text. It differs from nvim_buf_get_lines in that it allows retrieving only portions of lines. While this can typically be done easily enough by API clients, implementing this function provides symmetry between the get/set text/lines APIs, and also provides a nice convenience that saves API clients the work of having to slice the result of nvim_buf_get_lines themselves.
* feat(api): add nvim_get_option_valueGregory Anders2021-12-04
|
* refactor(api/marks)!: add opts param for feature extensibility (#16146)Javier Lopez2021-11-01
| | | | | In the future we might want to extend the concept of named marks and adding opts reduces the need of changing the function signature in the furute.
* feat(api): named marks set, get, delete #15346Javier Lopez2021-10-05
| | | | | | | | | | | | | | | | | | | | | | | Adds the following API functions. - nvim_buf_set_mark(buf, name, line, col) * Set marks in a buffer. - nvim_buf_del_mark(buf, name) * Delete a mark that belongs to buffer. - nvim_del_mark(name) * Delete a global mark. - nvim_get_mark(name) * Get a global mark. Tests: - Adds test to all the new api functions, and adds more for the existing nvim_buf_get_mark. * Tests include failure cases. Documentation: - Adds documentation for all the new functions, and improves the existing fucntion docs.
* correctly mark changed regions for set_textchentau2021-02-07
|
* api: set_text: more tests, and fixing lintchentau2021-01-01
| | | | | | | | removing pending virtcol tests Allow passing in empty array as a shorthand for array with empty string; add more documentation add check for start_row as well
* api: set_text: rebase, update to new api, and add more testsTony Chen2021-01-01
|
* api: set_text: fix validation and some issuesBlaž Hrastnik2021-01-01
| | | | | | | | | | | | fix double free because intermediary lines weren't xmemdup'd. NL-for-NUL dance. Normalize row indices and perform more validation. Adjust the cursor position if it's on the right side of the replacement. Tests and documentation.
* api: nvim_buf_deleteTJ DeVries2020-10-22
|
* test: Eliminate expect_errJustin M. Keyes2019-09-06
| | | | Eliminate `expect_err` in favor of `pcall_err` + `eq` or `matches`.
* test: Rename meth_pcall to pcall_errJustin M. Keyes2019-09-06
| | | | | | | - Rename `meth_pcall`. - Make `pcall_err` raise an error if the function does not fail. - Add `vim.pesc()` to treat a string as literal where a Lua pattern is expected.
* API: nvim_buf_set_lines: handle 'nomodifiable' #10910Justin M. Keyes2019-09-01
|
* API: fix cursor position when lines are added #9961hashinclude2019-05-07
| | | | Restore code removed in #9674.
* aucmd_prepbuf: also restore `prevwin` #9741Justin M. Keyes2019-03-17
| | | | | | | | | | | | | | | bisected to f5d5da391715 Other test steps: nvim -u NORC :terminal tree / " Produces lots of output :edit somefile.txt :vsplit :vsplit <c-w>l <c-w>l <c-w>h <c-w>p
* buffer: use aucmd_prepbuf() instead of switch_to_win_for_buf()Björn Linse2019-03-05
|
* api: simplify nvim_buf_get_offset functionBjörn Linse2018-11-01
|
* api: implement nvim_buf_get_offset_for_lineBjörn Linse2018-11-01
| | | | | Like line2byte, but works for any buffer, and uses zero-based indexing (API conventions).
* API: Avoid overrun when formatting error-messageJustin M. Keyes2018-09-05
| | | | | | | msgpack_rpc_to_object (called by handle_request .. msgpack_rpc_to_array) always NUL-terminates API Strings. But handle_request .. msgpack_rpc_get_handler_for operates on a raw msgpack_object, before preparation.
* functests: tests related to operations on unloaded buffers #7688Peter Hodge2018-07-25
|
* Merge branch 'master' into luaviml'/luaZyX2017-05-08
|\
| * api: Do not translate error messages.Justin M. Keyes2017-04-24
| | | | | | | | | | | | | | | | | | | | Also re-word some error messages: - "Key does not exist: %s" - "Invalid channel: %<PRIu64>" - "Request array size must be 4 (request) or 3 (notification)" - "String cannot contain newlines" References #6150
* | functests: Test for “string cannot contain newline” set_lines errorZyX2017-04-11
|/ | | | Should make me able to determine whether they are lua bindings that contain a bug or set_lines.
* functests: Replace execute with either command or feed_commandZyX2017-04-09
| | | | | | | | | | Hope this will make people using feed_command less likely: this hides bugs. Already found at least two: 1. msgpackparse() will show internal error: hash_add() in case of duplicate keys, though it will still work correctly. Currently silenced. 2. ttimeoutlen was spelled incorrectly, resulting in option not being set when expected. Test was still functioning somehow though. Currently fixed.
* api: nvim_buf_set_lines(): Avoid invalid ml_get. #6019Matthew Malcomson2017-03-07
| | | | | | | | | | When the buffer that nvim_buf_set_lines() is changing is not in any vim window, fix_cursor() leads to calling ml_get_buf() with an invalid line number. The condition that fix_cursor() was called on was (buf == curbuf), but this is always true because of the call to switch_to_win_for_buf() earlier in the function. Instead this should be predicated on (save_curbuf.br_buf == NULL)
* *: Fix linter errorsZyX2017-02-23
|
* api: Make sure dict_set_var doesn’t edit read-only valuesZyX2017-02-23
| | | Fixes #6147
* buffer: Bind b:changedtick to b:['changedtick'], remove special casesZyX2017-02-23
|
* api/buffer: Add nvim_buf_get_changedtick methodZyX2017-02-23
|
* test/api: Specify handling of VimL errors, v:errmsg.Justin M. Keyes2016-10-24
| | | | TODO: Also spec behavior of Press-Enter prompt for these API functions.
* api: Establish API naming convention. (#5344)Justin M. Keyes2016-09-17
| | | | | | | | | | | | | | | | | | | | | old name: new name: -------------------------------------------------- nvim_name_to_color nvim_get_color_by_name nvim_get_current_buffer nvim_get_current_buf nvim_get_current_window nvim_get_current_win nvim_get_buffers nvim_list_bufs nvim_get_tabpages nvim_list_tabpages nvim_get_windows nvim_list_wins nvim_set_current_buffer nvim_set_current_buf nvim_set_current_window nvim_set_current_win nvim_change_directory nvim_set_current_dir nvim_tabpage_get_window nvim_tabpage_get_win nvim_tabpage_get_windows nvim_tabpage_list_wins nvim_win_get_buffer nvim_win_get_buf nvim_report_error nvim_err_writeln Helped-by: Björn Linse <bjorn.linse@gmail.com> Helped-by: ZyX <kp-pav@yandex.ru> Helped-by: James McCoy <jamessan@jamessan.com>
* api: make nvim[_obj]_set_var and _del_var not return the old valueBjörn Linse2016-09-15
|