This commit is contained in:
@@ -1,4 +1,3 @@
|
||||
local Buffer = require 'u.buffer'
|
||||
local CodeWriter = require 'u.codewriter'
|
||||
local Range = require 'u.range'
|
||||
local vim_repeat = require 'u.repeat'
|
||||
@@ -69,8 +68,8 @@ local function do_surround(range, bounds)
|
||||
if range.mode == 'v' then
|
||||
range:replace(left .. range:text() .. right)
|
||||
elseif range.mode == 'V' then
|
||||
local buf = Buffer.current()
|
||||
local cw = CodeWriter.from_line(range.start:line(), buf.bufnr)
|
||||
local bufnr = vim.api.nvim_get_current_buf()
|
||||
local cw = CodeWriter.from_line(range.start:line(), bufnr)
|
||||
|
||||
-- write the left bound at the current indent level:
|
||||
cw:write(left)
|
||||
@@ -194,7 +193,6 @@ function M.setup()
|
||||
local txt_obj = vim_repeat.is_repeating() and CACHED_DELETE_FROM or vim.fn.getcharstr()
|
||||
CACHED_DELETE_FROM = txt_obj
|
||||
|
||||
local buf = Buffer.current()
|
||||
local irange = Range.from_motion('i' .. txt_obj)
|
||||
local arange = Range.from_motion('a' .. txt_obj)
|
||||
if arange == nil or irange == nil then return end
|
||||
@@ -216,11 +214,11 @@ function M.setup()
|
||||
-- `arange` as the final resulting range that holds the modified text
|
||||
|
||||
-- delete last line, if it is empty:
|
||||
local last = buf:line(arange.stop.lnum)
|
||||
local last = Range.from_line(bufnr, arange.stop.lnum)
|
||||
if last:text():match '^%s*$' then last:replace(nil) end
|
||||
|
||||
-- delete first line, if it is empty:
|
||||
local first = buf:line(arange.start.lnum)
|
||||
local first = Range.from_line(bufnr, arange.start.lnum)
|
||||
if first:text():match '^%s*$' then first:replace(nil) end
|
||||
else
|
||||
-- trim start:
|
||||
|
||||
Reference in New Issue
Block a user