aboutsummaryrefslogtreecommitdiff
path: root/vis.lua
diff options
context:
space:
mode:
authorAlexey Dubinin <dubininalexey@gmail.com>2016-09-28 17:49:39 +0300
committerAlexey Dubinin <dubininalexey@gmail.com>2016-09-28 17:49:39 +0300
commit5d593abfb8107d818373f7931c42c1bf33dd0f16 (patch)
tree2d3a69cf671772840c8ec3da05df760b388a6913 /vis.lua
parent53d25772d8d1e55a167553e9b429b23016a1e2ec (diff)
downloadvis-5d593abfb8107d818373f7931c42c1bf33dd0f16.tar.gz
vis-5d593abfb8107d818373f7931c42c1bf33dd0f16.tar.xz
Replace win.file.lines with win.file:content for better performance
Diffstat (limited to 'vis.lua')
-rw-r--r--vis.lua6
1 files changed, 3 insertions, 3 deletions
diff --git a/vis.lua b/vis.lua
index 8c90fe5..76d4e2e 100644
--- a/vis.lua
+++ b/vis.lua
@@ -193,7 +193,7 @@ vis.ftdetect.filetypes = {
-- array of filetype detecting functions (win, filename, shebang, app) -> string
vis.ftdetect.customdetectors = {
function(win)
- if win.file.lines[1] ~= nil and win.file.lines[1]:sub(1, 5) == '<?xml' then
+ if win.file:content(0, 5) == '<?xml' then
return 'xml'
end
end,
@@ -221,8 +221,8 @@ vis.filetype_detect = function(win)
-- find out via shebang which application would run our file
local shebang
local app
- if win.file.lines[1] ~= nil and win.file.lines[1]:sub(1, 2) == '#!' then
- shebang = win.file.lines[1]:gsub('^#!%s*', '')
+ if win.file:content(0, 2) == '#!' then
+ shebang = win.file:content(0, 256):gsub('^#!%s*', ''):gsub('\n.*$', '')
app = shebang:gsub('^/usr/bin/env%s*', ''):gsub('%s.*$', ''):gsub('^.*/', '')
if #app == 0 then
app = nil