-
Notifications
You must be signed in to change notification settings - Fork 2
Open
Description
When the last line of a posting has no explicit amount and ends with a trailing space, the plugin crashes with a nil node error.
Reproduction
account Ausgaben:Transport
account Aktiva:Girokonto
commodity 1000.00 EUR
2025-01-08 This Posting has trailing space in line 3
Ausgaben:Transport EUR 49.00
Aktiva:Girokonto
2025-01-09 Monatskarte BVG
Ausgaben:Transport EUR 49.00
Aktiva:Girokonto
Line 3 has a trailing space. Opening this file crashes immediately. Removing the space or adding an explicit amount prevents the crash.
Error
"test.journal" 12L, 289B written
Error detected while processing BufWritePost Autocommands for "*.journal":
Error executing lua callback: /usr/share/nvim/runtime/lua/vim/treesitter.lua:219: attempt to index local 'node' (a nil value)
stack traceback:
/usr/share/nvim/runtime/lua/vim/treesitter.lua:219: in function 'get_node_text'
....local/share/nvim/lazy/ledger.nvim/lua/ledger/parser.lua:154: in function 'get_postings_from_source'
...local/share/nvim/lazy/ledger.nvim/lua/ledger/context.lua:70: in function 'add_file'
...ocal/share/nvim/lazy/ledger.nvim/lua/ledger/commands.lua:104: in function <...ocal/share/nvim/lazy/ledger.nvim/lua/ledger/commands.lua:100>
:InspectTree shows no ERROR nodes — tree-sitter parses the file fine. Looks like a missing nil check before get_node_text in parser.lua:154.
Environment
- Neovim v0.11.6, ledger.nvim v0.3.0, tree-sitter-ledger latest, Arch Linux
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels