aboutsummaryrefslogtreecommitdiff
path: root/runtime/lua/vim/_comment.lua
diff options
context:
space:
mode:
authorLewis Russell <lewis6991@gmail.com>2025-06-05 11:31:51 +0100
committerLewis Russell <me@lewisr.dev>2025-06-06 15:36:48 +0100
commit3b6084ddf4f0d49fb0e5d135919c9daacea2a46d (patch)
treec46454da48ec05e345c953f4e172e52dff8bef52 /runtime/lua/vim/_comment.lua
parent4c333fdbb7bee299f36624b429f5c065470e421d (diff)
downloadrneovim-3b6084ddf4f0d49fb0e5d135919c9daacea2a46d.tar.gz
rneovim-3b6084ddf4f0d49fb0e5d135919c9daacea2a46d.tar.bz2
rneovim-3b6084ddf4f0d49fb0e5d135919c9daacea2a46d.zip
fix: type fixes
Type fixes caught by emmylua
Diffstat (limited to 'runtime/lua/vim/_comment.lua')
-rw-r--r--runtime/lua/vim/_comment.lua8
1 files changed, 5 insertions, 3 deletions
diff --git a/runtime/lua/vim/_comment.lua b/runtime/lua/vim/_comment.lua
index c8f7b13659..378d0e2584 100644
--- a/runtime/lua/vim/_comment.lua
+++ b/runtime/lua/vim/_comment.lua
@@ -3,7 +3,7 @@
---@field right string Right part of comment
--- Get 'commentstring' at cursor
----@param ref_position integer[]
+---@param ref_position [integer,integer]
---@return string
local function get_commentstring(ref_position)
local buf_cs = vim.bo.commentstring
@@ -62,7 +62,7 @@ local function get_commentstring(ref_position)
end
--- Compute comment parts from 'commentstring'
----@param ref_position integer[]
+---@param ref_position [integer,integer]
---@return vim._comment.Parts
local function get_comment_parts(ref_position)
local cs = get_commentstring(ref_position)
@@ -78,6 +78,7 @@ local function get_comment_parts(ref_position)
-- Structure of 'commentstring': <left part> <%s> <right part>
local left, right = cs:match('^(.-)%%s(.-)$')
+ assert(left and right)
return { left = left, right = right }
end
@@ -112,6 +113,7 @@ local function get_lines_info(lines, parts)
for _, l in ipairs(lines) do
-- Update lines indent: minimum of all indents except blank lines
local _, indent_width_cur, indent_cur = l:find('^(%s*)')
+ assert(indent_width_cur and indent_cur)
-- Ignore blank lines completely when making a decision
if indent_width_cur < l:len() then
@@ -188,7 +190,7 @@ end
--- Comment/uncomment buffer range
---@param line_start integer
---@param line_end integer
----@param ref_position? integer[]
+---@param ref_position? [integer, integer]
local function toggle_lines(line_start, line_end, ref_position)
ref_position = ref_position or { line_start, 0 }
local parts = get_comment_parts(ref_position)