Skip to content

Commit 6f713d5

Browse files
committed
modify only current buffer
1 parent a04fccd commit 6f713d5

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

.gitignore

+2
Original file line numberDiff line numberDiff line change
@@ -39,3 +39,5 @@ luac.out
3939
*.x86_64
4040
*.hex
4141

42+
tests/dec_test.txt
43+
tests/enc_test.txt

lua/html-entities.lua

+6-4
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@ function he.setup()
1717
end
1818

1919
function he.encode()
20-
local buf = vim.api.nvim_buf_get_lines(0, 0, -1, false)
20+
local bufIndex = vim.api.nvim_get_current_buf()
21+
local buf = vim.api.nvim_buf_get_lines(bufIndex, 0, -1, false)
2122

2223
local encodedBuf = {}
2324
local eob = 0
@@ -32,11 +33,12 @@ function he.encode()
3233
eob = n
3334
end
3435
--update the buffer
35-
vim.api.nvim_buf_set_lines(0, 0, eob, false, encodedBuf)
36+
vim.api.nvim_buf_set_lines(bufIndex, 0, eob, false, encodedBuf)
3637
end
3738

3839
function he.decode()
39-
local buf = vim.api.nvim_buf_get_lines(0, 0, -1, false)
40+
local bufIndex = vim.api.nvim_get_current_buf()
41+
local buf = vim.api.nvim_buf_get_lines(bufIndex, 0, -1, false)
4042

4143
local decodedBuf = {}
4244
local eob = 0
@@ -51,7 +53,7 @@ function he.decode()
5153
eob = n
5254
end
5355
--update the buffer
54-
vim.api.nvim_buf_set_lines(0, 0, eob, false, decodedBuf)
56+
vim.api.nvim_buf_set_lines(bufIndex, 0, eob, false, decodedBuf)
5557
end
5658

5759
he.options = nil

0 commit comments

Comments
 (0)