diff options
| author | Alexey Dubinin <dubininalexey@gmail.com> | 2016-09-28 17:49:39 +0300 |
|---|---|---|
| committer | Alexey Dubinin <dubininalexey@gmail.com> | 2016-09-28 17:49:39 +0300 |
| commit | 5d593abfb8107d818373f7931c42c1bf33dd0f16 (patch) | |
| tree | 2d3a69cf671772840c8ec3da05df760b388a6913 /vis.lua | |
| parent | 53d25772d8d1e55a167553e9b429b23016a1e2ec (diff) | |
| download | vis-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.lua | 6 |
1 files changed, 3 insertions, 3 deletions
@@ -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 |
