From 36cbd164b04958fad1d22de872ca0eb1677d635c Mon Sep 17 00:00:00 2001 From: gbprod Date: Fri, 10 Nov 2023 17:01:12 +0100 Subject: [PATCH] wip --- lua/substitute.lua | 3 ++- lua/substitute/utils.lua | 2 +- spec/substitute/wrappers/linewise_spec.lua | 4 ++-- spec/substitute/wrappers/reindent_spec.lua | 8 ++++---- 4 files changed, 9 insertions(+), 8 deletions(-) diff --git a/lua/substitute.lua b/lua/substitute.lua index 9ff7de3..3615945 100644 --- a/lua/substitute.lua +++ b/lua/substitute.lua @@ -56,7 +56,8 @@ function substitute.operator_callback(vmode) end end - local wrapper = substitute.state.wrappers or doSubstitution + local wrapper = substitute.state.wrappers and require("substitute.wrappers").build(substitute.state.wrappers) + or doSubstitution wrapper(substitute.state, doSubstitution) diff --git a/lua/substitute/utils.lua b/lua/substitute/utils.lua index 1dd0b6d..8b752dd 100644 --- a/lua/substitute/utils.lua +++ b/lua/substitute/utils.lua @@ -134,7 +134,7 @@ function utils.text(bufnr, start, finish, vmode) local current_row_len = vim.fn.getline(row):len() local end_col = current_row_len > finish.col and utils.get_next_char_bytecol(finish.row, finish.col) - or current_row_len + or current_row_len if start.col > end_col then end_col = start.col end diff --git a/spec/substitute/wrappers/linewise_spec.lua b/spec/substitute/wrappers/linewise_spec.lua index f34ce3d..df18b3a 100644 --- a/spec/substitute/wrappers/linewise_spec.lua +++ b/spec/substitute/wrappers/linewise_spec.lua @@ -19,13 +19,13 @@ describe("Substitute linewise", function() vim.keymap.set({ "n", "x" }, "]s", function() require("substitute").operator({ - wrappers = require("substitute.wrappers").build({ "linewise" }), + wrappers = { "linewise" }, }) end, { noremap = true }) vim.keymap.set({ "n", "x" }, "]ss", function() require("substitute").line({ - wrappers = require("substitute.wrappers").build({ "linewise" }), + wrappers = { "linewise" }, }) end, { noremap = true }) diff --git a/spec/substitute/wrappers/reindent_spec.lua b/spec/substitute/wrappers/reindent_spec.lua index 59aa127..6098bf9 100644 --- a/spec/substitute/wrappers/reindent_spec.lua +++ b/spec/substitute/wrappers/reindent_spec.lua @@ -20,13 +20,13 @@ describe("Substitute reindent", function() vim.keymap.set({ "n", "x" }, "=s", function() require("substitute").operator({ - wrappers = require("substitute.wrappers").build({ "reindent" }), + wrappers = { "reindent" }, }) end, { noremap = true, buffer = buf }) vim.keymap.set({ "n", "x" }, "=ss", function() require("substitute").line({ - wrappers = require("substitute.wrappers").build({ "reindent" }), + wrappers = { "reindent" }, }) end, { noremap = true, buffer = buf }) @@ -83,13 +83,13 @@ describe("Substitute linewise and reindent", function() vim.keymap.set({ "n", "x" }, "=s", function() require("substitute").operator({ - wrappers = require("substitute.wrappers").build({ "linewise", "reindent" }), + wrappers = { "linewise", "reindent" }, }) end, { noremap = true, buffer = buf }) vim.keymap.set({ "n", "x" }, "=ss", function() require("substitute").line({ - wrappers = require("substitute.wrappers").build({ "linewise", "reindent" }), + wrappers = { "linewise", "reindent" }, }) end, { noremap = true, buffer = buf })