Skip to content

Commit

Permalink
revert last 4 commits
Browse files Browse the repository at this point in the history
  • Loading branch information
armed committed Aug 14, 2023
1 parent 2e1e4fa commit 4e445b4
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 38 deletions.
40 changes: 24 additions & 16 deletions lua/nvim-paredit/api/barfing.lua
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,16 @@ function M.barf_forwards(opts)
return
end

local child = traversal.get_last_child_ignoring_comments(form, {
lang = lang,
})
local child
if opts.reversed then
child = traversal.get_first_child_ignoring_comments(form, {
lang = lang,
})
else
child = traversal.get_last_child_ignoring_comments(form, {
lang = lang,
})
end
if not child then
return
end
Expand Down Expand Up @@ -128,24 +135,14 @@ function M.barf_backwards(opts)
local buf = vim.api.nvim_get_current_buf()

local text = edges.left.text
local edge_len = 0
local range = edges.left.range
local is_separate_row = range[1] ~= end_pos[1]
if is_separate_row then
edge_len = string.len(text)
end
-- stylua: ignore
vim.api.nvim_buf_set_text(buf,
end_pos[1], end_pos[2] - edge_len,
end_pos[1], end_pos[2] - edge_len,
{text}
)
vim.api.nvim_buf_set_text(buf,
end_pos[1], end_pos[2],
end_pos[1], end_pos[2] + edge_len,
{}
end_pos[1], end_pos[2],
{ text }
)

local range = edges.left.range
-- stylua: ignore
vim.api.nvim_buf_set_text(
buf,
Expand All @@ -154,6 +151,17 @@ function M.barf_backwards(opts)
{}
)

indentation.handle_indentation({
type = "barf",
from = range,
to = { end_pos[1], end_pos[2], end_pos[1], end_pos[2] },
child = child,
parent = form,

indent_behaviour = opts.indent_behaviour or config.config.indent_behaviour,
lang = lang,
})

local cursor_behaviour = opts.cursor_behaviour or config.config.cursor_behaviour
if cursor_behaviour == "auto" or cursor_behaviour == "follow" then
local cursor_pos = vim.api.nvim_win_get_cursor(0)
Expand Down
34 changes: 12 additions & 22 deletions lua/nvim-paredit/api/slurping.lua
Original file line number Diff line number Diff line change
Expand Up @@ -67,38 +67,28 @@ local function slurp(opts)
)

local offset = 0
local edge_len = string.len(left_or_right_edge.text)
if opts.reversed and row == left_or_right_edge.range[1] then
offset = edge_len
offset = string.len(left_or_right_edge.text)
end


local token
if opts.reversed and offset == 0 then
token = string.rep(" ", edge_len)
elseif offset > 0 then
token = ""
end
-- stylua: ignore
vim.api.nvim_buf_set_text(
buf,
left_or_right_edge.range[1], left_or_right_edge.range[2] + offset,
left_or_right_edge.range[3], left_or_right_edge.range[4] + offset,
{token}
{}
)

if not opts.reversed then
indentation.handle_indentation({
type = "slurp",
from = left_or_right_edge.range,
to = { row, col, row, col },
child = sibling,
parent = form,
reversed = opts.reversed,
indent_behaviour = opts.indent_behaviour or config.config.indent_behaviour,
lang = lang,
})
end
indentation.handle_indentation({
type = "slurp",
from = left_or_right_edge.range,
to = { row, col, row, col },
child = sibling,
parent = form,

indent_behaviour = opts.indent_behaviour or config.config.indent_behaviour,
lang = lang,
})

local cursor_behaviour = opts.cursor_behaviour or config.config.cursor_behaviour
if cursor_behaviour == "follow" then
Expand Down

0 comments on commit 4e445b4

Please sign in to comment.