Skip to content

Commit

Permalink
refactor: clean up
Browse files Browse the repository at this point in the history
  • Loading branch information
bennypowers committed May 27, 2024
1 parent e6c4939 commit 8a428f0
Showing 1 changed file with 6 additions and 9 deletions.
15 changes: 6 additions & 9 deletions lua/regexplainer.lua
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@ local utils = require 'regexplainer.utils'
local Buffers = require 'regexplainer.buffers'
local defer = require 'regexplainer.utils.defer'

local get_node_text = vim.treesitter.get_node_text or vim.treesitter.query.get_node_text
local get_node_text = vim.treesitter.get_node_text
local extend = vim.tbl_deep_extend
local buf_delete = vim.api.nvim_buf_delete
local ag = vim.api.nvim_create_augroup
local au = vim.api.nvim_create_autocmd

Expand Down Expand Up @@ -102,14 +103,10 @@ local function show_for_real(options)
renderer = require'regexplainer.renderers.debug'
end

Buffers.render(buffer,
renderer,
components,
options,
{
full_regexp_text = get_node_text(node, scratchnr),
})
vim.api.nvim_buf_delete(scratchnr, { force = true })
local state = { full_regexp_text = get_node_text(node, scratchnr) }

Buffers.render(buffer, renderer, components, options, state)
buf_delete(scratchnr, { force = true })
else
Buffers.hide_all()
end
Expand Down

0 comments on commit 8a428f0

Please sign in to comment.