aboutsummaryrefslogtreecommitdiff
path: root/plugins/align_carets.lua
diff options
context:
space:
mode:
authorGuldoman <giulio.lettieri@gmail.com>2022-11-02 08:10:57 +0100
committerGitHub <noreply@github.com>2022-11-02 08:10:57 +0100
commit9bf5649c7df6bbd746956e9a96b616f61a59fa9b (patch)
tree725e2d12dc826f8ebe73807a705371cb4c5af4d9 /plugins/align_carets.lua
parent49139e03398c9d0ecb347267a4882a4eb3f7ee23 (diff)
downloadlite-xl-plugins-9bf5649c7df6bbd746956e9a96b616f61a59fa9b.tar.gz
lite-xl-plugins-9bf5649c7df6bbd746956e9a96b616f61a59fa9b.zip
Use new `command.add` syntax (#136)
Diffstat (limited to 'plugins/align_carets.lua')
-rw-r--r--plugins/align_carets.lua9
1 files changed, 4 insertions, 5 deletions
diff --git a/plugins/align_carets.lua b/plugins/align_carets.lua
index 2a1db2a..d9e76a7 100644
--- a/plugins/align_carets.lua
+++ b/plugins/align_carets.lua
@@ -31,18 +31,17 @@ local function has_selections()
if not check_doc() then return false end
local selections, has_multilines = doc_get_selection_status(core.active_view.doc)
-- we want this to be true if there are only single lines selections
- return selections and not has_multilines
+ return selections and not has_multilines, core.active_view.doc
end
local function has_no_selections()
if not check_doc() then return false end
- return not doc_get_selection_status(core.active_view.doc)
+ return not doc_get_selection_status(core.active_view.doc), core.active_view.doc
end
-local function align(right)
- local doc = core.active_view.doc
+local function align(doc, right)
local max_col = 0
local done = { }
@@ -76,5 +75,5 @@ command.add(has_no_selections, {
command.add(has_selections, {
["doc:left-align-selections"] = align,
- ["doc:right-align-selections"] = function() align(true) end,
+ ["doc:right-align-selections"] = function(doc) align(doc, true) end,
})