bug: ordered_icons compares nil when marker conversion fails
Maintainer thường phản hồi trong vòng 6 ngày
Đánh giá
- Độ khó
- 2/5
- Thời gian dự kiến
- 1-3 giờ
- Mức phù hợp với người mới
- 86/100
Hướng nghiên cứu
Bắt đầu tại lua/render-markdown/settings.lua, ở callback mặc định bullet.ordered_icons, và chạy bản tái hiện Neovim headless được cung cấp. Thêm coverage hồi quy cho các giá trị marker rỗng và không phải số, đồng thời giữ nguyên hành vi đánh số hợp lệ; hoàn thành khi callback không còn phát sinh lỗi và các trường hợp hợp lệ hiện có vẫn không thay đổi.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Neovim version
NVIM v0.12.5 (LuaJIT 2.1.1788856981)
Neovim distribution / OS / terminal
LazyVim on macOS. The deterministic reproduction below uses headless Neovim; the terminal for the original editing error was not recorded.
Describe the bug
The default bullet.ordered_icons callback calls tonumber(...), then compares the result with 1 without checking for nil. If the supplied marker text cannot be converted to a number, rendering aborts with:
Error msg_show.lua_error vim.schedule callback:
.../render-markdown.nvim/lua/render-markdown/settings.lua:164: attempt to compare number with nil
stack traceback:
.../settings.lua:164: in function 'get_string'
.../render/markdown/bullet.lua:44: in function 'setup'
.../render/base.lua:20: in function 'execute'
.../render/markdown/list.lua:18: in function 'run'
.../render/base.lua:21: in function 'execute'
.../handler/markdown.lua:58: in function 'callback'
.../request/view.lua:76: in function 'callback'
.../request/view.lua:88: in function 'query'
.../request/view.lua:71: in function 'nodes'
.../handler/markdown.lua:55: in function 'parse'
.../core/handlers.lua:94: in function 'tree'
.../core/handlers.lua:51: in function 'run'
.../core/ui.lua:156: in function 'callback'
This was reported during a real editing session on 8.14.0 (640a3ec6d538bad17c328be373c7cad0293d9589). I have verified the unsafe conversion/comparison, but have not captured the original marker text or reproduced the sequence of editing/parser events that supplied it. An incomplete or stale marker is a hypothesis, not an established cause.
Deterministic callback reproduction
With the plugin on runtimepath, execute:
local ordered_icons = require('render-markdown.settings').bullet.default.ordered_icons
ordered_icons({ level = 1, index = 3, value = '' })
This raises the exact settings.lua:164 comparison error. value = '.', ')', or 'abc' also reproduces it. These are injected callback inputs, not a claim that standalone malformed Markdown necessarily produces an ordered-list parser node.
For example, with a fresh checkout:
nvim --headless -u NONE -i NONE \
--cmd 'set rtp+=/path/to/render-markdown.nvim' \
-c 'lua local f = require("render-markdown.settings").bullet.default.ordered_icons; local ok, result = pcall(f, { level = 1, index = 3, value = "" }); print(ok, result)' \
-c qa
Observed: false .../settings.lua:164: attempt to compare number with nil.
Expected behavior / proposed fix
A failed marker conversion should not abort rendering. Guard the comparison and reuse the callback's existing item-index fallback:
return ('%d.'):format(index and index > 1 and index or ctx.index)
Verified in headless Neovim: valid explicit markers greater than one retain their number; markers starting at zero or one retain the existing item-position numbering; unconvertible marker strings fall back to ctx.index without crashing. A regression test fails before this guard and passes afterward.
Plugin configuration at the time of the error
Custom overrides for this plugin (remaining options inherited from LazyVim):
opts = {
latex = { block = false },
anti_conceal = { ignore = { virtual_lines = false } },
}
There was no custom bullet.ordered_icons callback. A local override using the proposed guard is now in place.
Healthcheck output
Collected headlessly with the above overrides and installed parser/icon dependencies in an isolated checkout. This is a minimal configuration healthcheck, not a capture of the original live editor session:
==============================================================================
render-markdown: ✅
render-markdown.nvim [versions] ~
- ✅ OK neovim >= 0.11
- ✅ OK tree-sitter ABI: 15
- ✅ OK plugin: 8.14.0
render-markdown.nvim [configuration] ~
- ✅ OK valid
render-markdown.nvim [tree-sitter markdown] ~
- ✅ OK parser: installed
- ✅ OK ABI: 15
- ✅ OK highlights: ~/.local/share/nvim/site/queries/markdown/highlights.scm
- ✅ OK highlighter: enabled
render-markdown.nvim [tree-sitter markdown_inline] ~
- ✅ OK parser: installed
- ✅ OK ABI: 15
- ✅ OK highlights: ~/.local/share/nvim/site/queries/markdown_inline/highlights.scm
render-markdown.nvim [tree-sitter html] ~
- ✅ OK parser: installed
- ✅ OK ABI: 14
render-markdown.nvim [tree-sitter latex] ~
- ✅ OK parser: installed
- ✅ OK ABI: 15
render-markdown.nvim [tree-sitter yaml] ~
- ✅ OK parser: installed
- ✅ OK ABI: 15
render-markdown.nvim [icons] ~
- ✅ OK using: mini.icons
render-markdown.nvim [latex] ~
- ✅ OK using: { "utftex", "latex2text" }
render-markdown.nvim [conflicts] ~
- ✅ OK headlines: not installed
- ✅ OK markview: not installed
- ✅ OK obsidian: not installed
- ✅ OK snacks: not installed
Plugin error log
The original scheduled-callback traceback is included above; a separate plugin error-log capture is unavailable.
Additional verification
A fresh checkout of current main has the same default callback and commit as the installed 8.14.0 version. The callback reproduction does not require a Tree-sitter parser, so parsers were not updated as part of this diagnosis. This differs from #504, which involved the pre-8.0 callback signature in user configuration.
- Ngôn ngữ chính
- Lua
- Star
- 5.2k
- Fork
- 145
- Chỉ số merge pull request
- Không có pull request nào được merge trong 30 ngày
Chuẩn bị môi trường
Dự án này không cung cấp dev container, Dockerfile hay hướng dẫn đóng góp, nên bạn cần tự thiết lập môi trường: hãy bắt đầu từ README và xem hướng dẫn đóng góp lần đầu của chúng tôi để biết các bước chung.
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của MeanderingProgrammer/render-markdown.nvim
-
bug
Độ khó 4/5 1-2 ngày Mức phù hợp với người mới 55/100
MeanderingProgrammer/render-markdown.nvim#706 ·
Maintainer thường phản hồi trong vòng 6 ngày
-
enhancement
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 38/100
MeanderingProgrammer/render-markdown.nvim#685 ·
Maintainer thường phản hồi trong vòng 6 ngày
-
bug: Tables don't render correctly if the pipe at the end of line is missingCó thể đã có người làm @samholmes đã nhận 93 ngày trước. Đang mởbug
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 55/100
MeanderingProgrammer/render-markdown.nvim#673 · 2 bình luận ·
Maintainer thường phản hồi trong vòng 6 ngày
-
enhancement
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 48/100
MeanderingProgrammer/render-markdown.nvim#656 ·
Maintainer thường phản hồi trong vòng 6 ngày
Tất cả issue của MeanderingProgrammer/render-markdown.nvim
Issue tương tự
-
Enhancement
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 62/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
mogenson/PaperWM.spoon#178 ·
-
enhancement good first issue
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 85/100
-
ci: Verify install never runs examples_install or tests_install, so a clear they widen passesĐang mởseverity: low
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
luainkernel/lunatik#1876 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
bug ready ticket
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
Domktorymysli/vclu#5 ·