Skip to content

Commit f9c65cd

Browse files
committed
fix: filetype modeline detection after the recent changes
last line ist most likly just a empty line so if thats true we take n - 1
1 parent 1cdbea8 commit f9c65cd

2 files changed

Lines changed: 6 additions & 3 deletions

File tree

lua/plenary/filetype.lua

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,10 @@ filetype.detect_from_modeline = function(filepath)
135135
return ""
136136
end
137137
local lines = vim.split(tail, "\n")
138-
return filetype._parse_modeline(lines[#lines])
138+
local idx = lines[#lines] ~= "" and #lines or #lines - 1
139+
if idx >= 1 then
140+
return filetype._parse_modeline(lines[idx])
141+
end
139142
end
140143

141144
filetype.detect_from_shebang = function(filepath)

lua/plenary/path.lua

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -835,7 +835,7 @@ end
835835
function Path:iter()
836836
local data = self:readlines()
837837
local i = 0
838-
local n = table.getn(data)
838+
local n = #data
839839
return function()
840840
i = i + 1
841841
if i <= n then
@@ -861,7 +861,7 @@ function Path:readbyterange(offset, length)
861861
offset = stat.size + offset
862862
end
863863

864-
data = ""
864+
local data = ""
865865
while #data < length do
866866
local read_chunk = assert(uv.fs_read(fd, length - #data, offset))
867867
if #read_chunk == 0 then

0 commit comments

Comments
 (0)