summaryrefslogtreecommitdiffstatshomepage
path: root/test/functional/terminal/parser_spec.lua
AgeCommit message (Collapse)AuthorFiles
2026-04-23fix(terminal): memory leak in pending TermRequest StringBuilder #39333Barrett Ruth1
Problem: Destroying a terminal with pending `TermRequest` events leaks memory. Solution: Make `emit_termrequest` the sole owner of its `pending_send` allocation.
2026-04-15test: replace busted with local harnessLewis Russell1
Replace the busted-based Lua test runner with a repo-local harness. The new harness runs spec files directly under `nvim -ll`, ships its own reporter and lightweight `luassert` shim, and keeps the helper/preload flow used by the functional and unit test suites. Keep the file boundary model shallow and busted-like by restoring `_G`, `package.loaded`, `package.preload`, `arg`, and the process environment between files, without carrying extra reset APIs or custom assertion machinery. Update the build and test entrypoints to use the new runner, add black-box coverage for the harness itself, and drop the bundled busted/luacheck dependency path. AI-assisted: Codex
2026-03-12docs: use "ev" convention in event-handlersJustin M. Keyes1
Problem: In autocmd examples, using "args" as the event-object name is vague and may be confused with a user-command. Solution: Use "ev" as the conventional event-object name.
2025-12-29feat(terminal): include sequence terminator in TermRequest event (#37152)Kyle1
Problem: Terminals should respond with the terminator (either BEL or ST) used in the query so that clients can reliably parse the responses. The `TermRequest` autocmd used to handle background color requests in the terminal does not have access to the original sequence terminator, so it always uses BEL. #37018 Solution: Update vterm parsing to include the terminator type, then forward this data into the emitted `TermRequest` events for OSC/DCS/APC sequences. Update the foreground/background `TermRequest` callback to use the same terminator as the original request. Details: I didn't add the terminator to the `TermResponse` event. However, I assume the `TermResponse` event doesn't care about the terminator because the sequence is already parsed. I also didn't update any of the functions in `src/nvim/vterm/state.c` that write out responses. It looked like those all pretty much used ST, and it would be a much larger set of changes. In that same file, there's also logic for 8 bit ST sequences, but from what I can tell, 8 bit doesn't really work (see `:h xterm-8bit`), so I didn't use the 8 bit ST at all.
2025-05-29fix(terminal): skip setting `string_initial` to false on no-op (#34176)Gabriel Ford1
Problem: Currently undefined behavior can occur when `string_fragment()` is called with `OSC_COMMAND`. This is because when the state changes to `OSC_COMMAND`, `string_initial` is set to true. Then in some cases, directly after this `string_initial` will be set back to false before the on_osc callback is called, this leads to `term_settermprop()` never initializing the title. Solution: In all of the no-op cases in `string_fragment()` currently, we continue to the end of the function where `vt->parser.string_initial` is set to false. This change returns in the no-op cases instead since in these cases the string has not yet been terminated and sent to the callback. Note: This change also adds a test with a byte sequence from the file in #34028 that caused nvim to crash. This byte sequences is the shortest sequence I could trim down from that file that still would trigger the crash. There are also two other tests I added which validate that setting the title with OSC-0 and OSC-2 still works. Fixes: #34028
2024-08-19fix(terminal): handle C0 characters in OSC terminator (#30090)Gregory Anders1
When a C0 character is present in an OSC terminator (i.e. after the ESC but before a \ (0x5c) or printable character), vterm executes the control character and resets the current string fragment. If the C0 character is the final byte in the sequence, the string fragment has a zero length. However, because the VT parser is still in the "escape" state, vterm attempts to subtract 1 from the string length (to account for the escape character). When the string fragment is empty, this causes an underflow in the unsigned size variable, resulting in a buffer overflow. The fix is simple: explicitly check if the string length is non-zero before subtracting.