aboutsummaryrefslogtreecommitdiff
path: root/runtime/lua/vim/treesitter
diff options
context:
space:
mode:
Diffstat (limited to 'runtime/lua/vim/treesitter')
-rw-r--r--runtime/lua/vim/treesitter/_range.lua4
-rw-r--r--runtime/lua/vim/treesitter/language.lua10
2 files changed, 12 insertions, 2 deletions
diff --git a/runtime/lua/vim/treesitter/_range.lua b/runtime/lua/vim/treesitter/_range.lua
index b87542c20f..8decd3a1fd 100644
--- a/runtime/lua/vim/treesitter/_range.lua
+++ b/runtime/lua/vim/treesitter/_range.lua
@@ -61,7 +61,7 @@ function M.intercepts(r1, r2)
local off_1 = #r1 == 6 and 1 or 0
local off_2 = #r1 == 6 and 1 or 0
- local srow_1, scol_1, erow_1, ecol_1 = r1[1], r2[2], r1[3 + off_1], r1[4 + off_1]
+ local srow_1, scol_1, erow_1, ecol_1 = r1[1], r1[2], r1[3 + off_1], r1[4 + off_1]
local srow_2, scol_2, erow_2, ecol_2 = r2[1], r2[2], r2[3 + off_2], r2[4 + off_2]
-- r1 is above r2
@@ -85,7 +85,7 @@ function M.contains(r1, r2)
local off_1 = #r1 == 6 and 1 or 0
local off_2 = #r1 == 6 and 1 or 0
- local srow_1, scol_1, erow_1, ecol_1 = r1[1], r2[2], r1[3 + off_1], r1[4 + off_1]
+ local srow_1, scol_1, erow_1, ecol_1 = r1[1], r1[2], r1[3 + off_1], r1[4 + off_1]
local srow_2, scol_2, erow_2, ecol_2 = r2[1], r2[2], r2[3 + off_2], r2[4 + off_2]
-- start doesn't fit
diff --git a/runtime/lua/vim/treesitter/language.lua b/runtime/lua/vim/treesitter/language.lua
index 5bcc786e88..5f34d9cd56 100644
--- a/runtime/lua/vim/treesitter/language.lua
+++ b/runtime/lua/vim/treesitter/language.lua
@@ -60,6 +60,16 @@ function M.add(lang, opts)
filetype = { filetype, { 'string', 'table' }, true },
})
+ if filetype == '' then
+ error(string.format("'%s' is not a valid filetype", filetype))
+ elseif type(filetype) == 'table' then
+ for _, f in ipairs(filetype) do
+ if f == '' then
+ error(string.format("'%s' is not a valid filetype", filetype))
+ end
+ end
+ end
+
M.register(lang, filetype or lang)
if vim._ts_has_language(lang) then