better Range:highlight(..) handling

This commit is contained in:
2024-10-14 17:48:14 -06:00
parent 03c5500966
commit 8bbb2ba9c8
5 changed files with 38 additions and 17 deletions

View File

@@ -1,5 +1,5 @@
local Buffer = require 'tt.buffer'
local withbuf = require '__tt_test_tools'
local withbuf = loadfile './spec/withbuf.lua'()
describe('Buffer', function()
it('should replace all lines', function()

View File

@@ -1,5 +1,5 @@
local Pos = require 'tt.pos'
local withbuf = require '__tt_test_tools'
local withbuf = loadfile './spec/withbuf.lua'()
describe('Pos', function()
it('get a char from a given position', function()

View File

@@ -1,6 +1,6 @@
local Range = require 'tt.range'
local Pos = require 'tt.pos'
local withbuf = require '__tt_test_tools'
local withbuf = loadfile './spec/withbuf.lua'()
describe('Range', function()
it('get text in buffer', function()

10
spec/withbuf.lua Normal file
View File

@@ -0,0 +1,10 @@
local function withbuf(lines, f)
vim.opt_global.swapfile = false
vim.cmd.new()
vim.api.nvim_buf_set_lines(0, 0, -1, false, lines)
local ok, result = pcall(f)
vim.cmd.bdelete { bang = true }
if not ok then error(result) end
end
return withbuf