neovim/runtime
Tristan Knight 230b0c7f02
feat(stdlib): overload vim.str_byteindex, vim.str_utfindex #30735
PROBLEM:
There are several limitations to vim.str_byteindex, vim.str_utfindex:
1. They throw given out-of-range indexes. An invalid (often user/lsp-provided)
   index doesn't feel exceptional and should be handled by the caller.
   `:help dev-error-patterns` suggests that `retval, errmsg` is the preferred
   way to handle this kind of failure.
2. They cannot accept an encoding. So LSP needs wrapper functions. #25272
3. The current signatures are not extensible.
    * Calling: The function currently uses a fairly opaque boolean value to
      indicate to identify the encoding.
    * Returns: The fact it can throw requires wrapping in pcall.
4. The current name doesn't follow suggestions in `:h dev-naming` and I think
   `get` would be suitable.

SOLUTION:
- Because these are performance-sensitive, don't introduce `opts`.
- Introduce an "overload" that accepts `encoding:string` and
  `strict_indexing:bool` params.

```lua
local col = vim.str_utfindex(line, encoding, [index, [no_out_of_range]])
```

Support the old versions by dispatching on the type of argument 2, and
deprecate that form.

```lua
vim.str_utfindex(line)                             -- (utf-32 length, utf-16 length), deprecated
vim.str_utfindex(line, index)                      -- (utf-32 index, utf-16 index), deprecated
vim.str_utfindex(line, 'utf-16')                   -- utf-16 length
vim.str_utfindex(line, 'utf-16', index)            -- utf-16 index
vim.str_utfindex(line, 'utf-16', math.huge)        -- error: index out of range
vim.str_utfindex(line, 'utf-16', math.huge, false) -- utf-16 length
```
2024-10-23 06:33:57 -07:00
..
autoload vim-patch:a7d4561: runtime(netrw): deprecate and remove netrwFileHandlers#Invoke() 2024-10-22 09:10:46 +02:00
colors fix(runtime): clean up one-off scripts 2024-10-15 20:50:21 +02:00
compiler vim-patch:5e48e97: runtime(compiler): check for compile_commands in build dirs for cppcheck 2024-10-18 01:00:01 +02:00
doc feat(stdlib): overload vim.str_byteindex, vim.str_utfindex #30735 2024-10-23 06:33:57 -07:00
ftplugin vim-patch:421ed14: runtime(typst): add folding to typst ftplugin 2024-10-22 09:10:46 +02:00
indent vim-patch:150b507: runtime(hcl,terraform): Add runtime files for HCL and Terraform (#30266) 2024-09-04 19:32:52 -05:00
keymap vim-patch:79a14c0: runtime(keymap): include Georgian keymap 2024-06-14 23:58:27 +02:00
lua feat(stdlib): overload vim.str_byteindex, vim.str_utfindex #30735 2024-10-23 06:33:57 -07:00
pack/dist/opt vim-patch:5753d99: runtime(nohlsearch): add missing loaded_hlsearch guard 2024-07-31 23:06:28 +02:00
plugin vim-patch:9.1.0694: matchparen is slow on a long line (#30134) 2024-08-25 06:07:43 +08:00
queries feat(defaults): pretty :help headings #30544 2024-09-27 08:53:30 -07:00
scripts fix(runtime): clean up one-off scripts 2024-10-15 20:50:21 +02:00
spell feat(runtime): import cleanadd.vim from Vim (#17699) 2022-03-13 04:52:45 +00:00
syntax vim-patch:f10db25: runtime(swayconfig): add flag for bindsym/bindcode to syntax script 2024-10-18 01:00:01 +02:00
tutor fix(tutor): incorrect lines marked as correct #29833 2024-08-16 10:35:13 -07:00
CMakeLists.txt fix(runtime): clean up one-off scripts 2024-10-15 20:50:21 +02:00
delmenu.vim vim-patch:e978b4534a5e (#24697) 2023-08-13 13:25:10 +01:00
filetype.lua refactor: use vim._with where possible 2024-06-28 19:58:31 +02:00
ftoff.vim vim-patch:e978b4534a5e (#24697) 2023-08-13 13:25:10 +01:00
ftplugin.vim vim-patch:e978b4534a5e (#24697) 2023-08-13 13:25:10 +01:00
ftplugof.vim vim-patch:e978b4534a5e (#24697) 2023-08-13 13:25:10 +01:00
indent.vim vim-patch:e978b4534a5e (#24697) 2023-08-13 13:25:10 +01:00
indoff.vim vim-patch:e978b4534a5e (#24697) 2023-08-13 13:25:10 +01:00
makemenu.vim vim-patch:9.1.0013: Modula2 filetype support lacking (#27020) 2024-01-16 17:45:57 +00:00
menu.vim vim-patch:a420547: runtime(misc): Use consistent "Vim script" spelling (#30805) 2024-10-14 09:27:29 +08:00
neovim.ico feat(windows): show icon in terminal titlebar, taskbar #20607 2022-10-13 05:48:12 -07:00
nvim.appdata.xml NVIM v0.10.0 2024-05-16 14:34:32 +02:00
nvim.desktop docs: misc (#29719) 2024-08-29 06:11:32 +08:00
nvim.png
optwin.vim vim-patch:9.1.0754: fixed order of items in insert-mode completion menu (#30619) 2024-10-03 06:45:01 +08:00
synmenu.vim vim-patch:9.1.0013: Modula2 filetype support lacking (#27020) 2024-01-16 17:45:57 +00:00
windows_icon.rc feat(win32): embed executable icon 2024-07-02 13:05:16 +02:00