--@action Lines column --@version 1.0.0 --@author TheFile.Ninja --@id lines-column --@description A Lines column for source code and text files. Put it in Scripts\Extensions\, then choose Lines in a pane's header menu under Script columns. --@tags columns, code --@requires none -- Extension scripts run in a sandbox of their own: they read, never write or -- ask. The app asks for the rows on screen, 64 at a time, and keeps each -- value until the file changes. columns.register{ id = "line_count", header = "Lines", type = "number", width = 70, extensions = { "txt", "md", "log", "csv", "lua", "rs", "py", "js", "ts", "tsx", "cs", "c", "h", "cpp", "hpp", "go", "java", "kt", "swift", "rb", "php", "sql", "html", "css", "scss", "xml", "json", "toml", "yaml", "yml", "ini", "ps1", "sh", "bat", "cmd" }, max_size = 2 * 1024 * 1024, -- bigger files stay blank timeout_ms = 3000, value = function(items) local out = {} for i, it in ipairs(items) do local text = fs.read_text(it.full_path) if text then local _, n = text:gsub("\n", "") if #text > 0 and text:sub(-1) ~= "\n" then n = n + 1 end -- a last line without its line break out[i] = n end end return out end, }