From a8f1f05fae1d0b74dd07d61a1f8eb023a67a3af4 Mon Sep 17 00:00:00 2001 From: Tobias Schmitz Date: Thu, 25 Jul 2024 20:56:03 +0200 Subject: [PATCH] fix(toml): parsing section with trailing whitespace (#143) --- lua/crates/toml.lua | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lua/crates/toml.lua b/lua/crates/toml.lua index 0ea7eb7..634a795 100644 --- a/lua/crates/toml.lua +++ b/lua/crates/toml.lua @@ -583,7 +583,7 @@ function M.parse_crates(buf) local line_nr = i - 1 ---@type string, string - local section_start, section_text, section_end = line:match("^%s*()%[(.+)()%s*$") + local section_start, section_text, section_end = line:match("^%s*()%[([^%s]+)()%s*$") if section_text then if dep_section then -- close line span @@ -597,7 +597,7 @@ function M.parse_crates(buf) end local header_col = Span.new(section_start - 1, section_end - 1) - if section_text and section_text:sub(-1) == ']' then + if section_text and section_text:sub(-1) == "]" then section_text = section_text:sub(1, -2) end