aboutsummaryrefslogtreecommitdiff
path: root/test/functional/shada/merging_spec.lua
diff options
context:
space:
mode:
authorJustin M. Keyes <justinkz@gmail.com>2024-01-03 02:09:18 +0100
committerJustin M. Keyes <justinkz@gmail.com>2024-01-03 02:09:29 +0100
commit04f2f864e270e772c6326cefdf24947f0130e492 (patch)
tree46f83f909b888a66c741032ab955afc6eab84292 /test/functional/shada/merging_spec.lua
parent59d117ec99b6037cb9fad5bbfb6d0b18f5012927 (diff)
downloadrneovim-04f2f864e270e772c6326cefdf24947f0130e492.tar.gz
rneovim-04f2f864e270e772c6326cefdf24947f0130e492.tar.bz2
rneovim-04f2f864e270e772c6326cefdf24947f0130e492.zip
refactor: format test/*
Diffstat (limited to 'test/functional/shada/merging_spec.lua')
-rw-r--r--test/functional/shada/merging_spec.lua653
1 files changed, 377 insertions, 276 deletions
diff --git a/test/functional/shada/merging_spec.lua b/test/functional/shada/merging_spec.lua
index dad7aa851d..7ca261eb11 100644
--- a/test/functional/shada/merging_spec.lua
+++ b/test/functional/shada/merging_spec.lua
@@ -1,8 +1,7 @@
-- ShaDa merging data support
local helpers = require('test.functional.helpers')(after_each)
local nvim_command, funcs, curbufmeths, eq =
- helpers.command, helpers.funcs,
- helpers.curbufmeths, helpers.eq
+ helpers.command, helpers.funcs, helpers.curbufmeths, helpers.eq
local exc_exec, exec_capture = helpers.exc_exec, helpers.exec_capture
local shada_helpers = require('test.functional.shada.helpers')
@@ -10,8 +9,7 @@ local reset, clear, get_shada_rw =
shada_helpers.reset, shada_helpers.clear, shada_helpers.get_shada_rw
local read_shada_file = shada_helpers.read_shada_file
-local wshada, sdrcmd, shada_fname =
- get_shada_rw('Xtest-functional-shada-merging.shada')
+local wshada, sdrcmd, shada_fname = get_shada_rw('Xtest-functional-shada-merging.shada')
local mock_file_path = '/a/b/'
if helpers.is_os('win') then
@@ -25,8 +23,7 @@ describe('ShaDa history merging code', function()
os.remove(shada_fname)
end)
- it('takes item with greater timestamp from Neovim instance when reading',
- function()
+ it('takes item with greater timestamp from Neovim instance when reading', function()
wshada('\004\001\009\147\000\196\002ab\196\001a')
eq(0, exc_exec(sdrcmd()))
wshada('\004\000\009\147\000\196\002ab\196\001b')
@@ -44,8 +41,7 @@ describe('ShaDa history merging code', function()
eq(1, found)
end)
- it('takes item with equal timestamp from Neovim instance when reading',
- function()
+ it('takes item with equal timestamp from Neovim instance when reading', function()
wshada('\004\000\009\147\000\196\002ab\196\001a')
eq(0, exc_exec(sdrcmd()))
wshada('\004\000\009\147\000\196\002ab\196\001b')
@@ -63,8 +59,7 @@ describe('ShaDa history merging code', function()
eq(1, found)
end)
- it('takes item with greater timestamp from ShaDa when reading',
- function()
+ it('takes item with greater timestamp from ShaDa when reading', function()
wshada('\004\000\009\147\000\196\002ab\196\001a')
eq(0, exc_exec(sdrcmd()))
wshada('\004\001\009\147\000\196\002ab\196\001b')
@@ -82,8 +77,7 @@ describe('ShaDa history merging code', function()
eq(1, found)
end)
- it('takes item with greater timestamp from Neovim instance when writing',
- function()
+ it('takes item with greater timestamp from Neovim instance when writing', function()
wshada('\004\001\009\147\000\196\002ab\196\001a')
eq(0, exc_exec(sdrcmd()))
wshada('\004\000\009\147\000\196\002ab\196\001b')
@@ -99,8 +93,7 @@ describe('ShaDa history merging code', function()
eq(1, found)
end)
- it('takes item with equal timestamp from Neovim instance when writing',
- function()
+ it('takes item with equal timestamp from Neovim instance when writing', function()
wshada('\004\000\009\147\000\196\002ab\196\001a')
eq(0, exc_exec(sdrcmd()))
wshada('\004\000\009\147\000\196\002ab\196\001b')
@@ -116,8 +109,7 @@ describe('ShaDa history merging code', function()
eq(1, found)
end)
- it('takes item with greater timestamp from ShaDa when writing',
- function()
+ it('takes item with greater timestamp from ShaDa when writing', function()
wshada('\004\000\009\147\000\196\002ab\196\001a')
eq(0, exc_exec(sdrcmd()))
wshada('\004\001\009\147\000\196\002ab\196\001b')
@@ -133,18 +125,18 @@ describe('ShaDa history merging code', function()
eq(1, found)
end)
- it('correctly reads history items with messed up timestamps',
- function()
- wshada('\004\010\009\147\000\196\002ab\196\001a'
- .. '\004\010\009\147\000\196\002ac\196\001a'
- .. '\004\005\009\147\000\196\002ad\196\001a'
- .. '\004\100\009\147\000\196\002ae\196\001a'
- .. '\004\090\009\147\000\196\002af\196\001a'
- )
+ it('correctly reads history items with messed up timestamps', function()
+ wshada(
+ '\004\010\009\147\000\196\002ab\196\001a'
+ .. '\004\010\009\147\000\196\002ac\196\001a'
+ .. '\004\005\009\147\000\196\002ad\196\001a'
+ .. '\004\100\009\147\000\196\002ae\196\001a'
+ .. '\004\090\009\147\000\196\002af\196\001a'
+ )
eq(0, exc_exec(sdrcmd()))
os.remove(shada_fname)
eq(0, exc_exec('wshada! ' .. shada_fname))
- local items = {'ad', 'ab', 'ac', 'af', 'ae'}
+ local items = { 'ad', 'ab', 'ac', 'af', 'ae' }
for i, v in ipairs(items) do
eq(v, funcs.histget(':', i))
end
@@ -159,16 +151,16 @@ describe('ShaDa history merging code', function()
eq(#items, found)
end)
- it('correctly reorders history items with messed up timestamps when writing',
- function()
- wshada('\004\010\009\147\000\196\002ab\196\001a'
- .. '\004\010\009\147\000\196\002ac\196\001a'
- .. '\004\005\009\147\000\196\002ad\196\001a'
- .. '\004\100\009\147\000\196\002ae\196\001a'
- .. '\004\090\009\147\000\196\002af\196\001a'
- )
+ it('correctly reorders history items with messed up timestamps when writing', function()
+ wshada(
+ '\004\010\009\147\000\196\002ab\196\001a'
+ .. '\004\010\009\147\000\196\002ac\196\001a'
+ .. '\004\005\009\147\000\196\002ad\196\001a'
+ .. '\004\100\009\147\000\196\002ae\196\001a'
+ .. '\004\090\009\147\000\196\002af\196\001a'
+ )
eq(0, exc_exec('wshada ' .. shada_fname))
- local items = {'ad', 'ab', 'ac', 'af', 'ae'}
+ local items = { 'ad', 'ab', 'ac', 'af', 'ae' }
local found = 0
for _, v in ipairs(read_shada_file(shada_fname)) do
if v.type == 4 and v.value[1] == 0 then
@@ -180,24 +172,24 @@ describe('ShaDa history merging code', function()
eq(#items, found)
end)
- it('correctly merges history items with duplicate mid entry when writing',
- function()
+ it('correctly merges history items with duplicate mid entry when writing', function()
-- Regression test: ShaDa code used to crash here.
-- Conditions:
-- 1. Entry which is duplicate to non-last entry.
-- 2. At least one more non-duplicate entry.
- wshada('\004\000\009\147\000\196\002ab\196\001a'
- .. '\004\001\009\147\000\196\002ac\196\001a'
- .. '\004\002\009\147\000\196\002ad\196\001a'
- .. '\004\003\009\147\000\196\002ac\196\001a'
- .. '\004\004\009\147\000\196\002af\196\001a'
- .. '\004\005\009\147\000\196\002ae\196\001a'
- .. '\004\006\009\147\000\196\002ag\196\001a'
- .. '\004\007\009\147\000\196\002ah\196\001a'
- .. '\004\008\009\147\000\196\002ai\196\001a'
- )
+ wshada(
+ '\004\000\009\147\000\196\002ab\196\001a'
+ .. '\004\001\009\147\000\196\002ac\196\001a'
+ .. '\004\002\009\147\000\196\002ad\196\001a'
+ .. '\004\003\009\147\000\196\002ac\196\001a'
+ .. '\004\004\009\147\000\196\002af\196\001a'
+ .. '\004\005\009\147\000\196\002ae\196\001a'
+ .. '\004\006\009\147\000\196\002ag\196\001a'
+ .. '\004\007\009\147\000\196\002ah\196\001a'
+ .. '\004\008\009\147\000\196\002ai\196\001a'
+ )
eq(0, exc_exec('wshada ' .. shada_fname))
- local items = {'ab', 'ad', 'ac', 'af', 'ae', 'ag', 'ah', 'ai'}
+ local items = { 'ab', 'ad', 'ac', 'af', 'ae', 'ag', 'ah', 'ai' }
local found = 0
for _, v in ipairs(read_shada_file(shada_fname)) do
if v.type == 4 and v.value[1] == 0 then
@@ -209,20 +201,20 @@ describe('ShaDa history merging code', function()
eq(#items, found)
end)
- it('correctly merges history items with duplicate adj entry when writing',
- function()
- wshada('\004\000\009\147\000\196\002ab\196\001a'
- .. '\004\001\009\147\000\196\002ac\196\001a'
- .. '\004\002\009\147\000\196\002ad\196\001a'
- .. '\004\003\009\147\000\196\002ad\196\001a'
- .. '\004\004\009\147\000\196\002af\196\001a'
- .. '\004\005\009\147\000\196\002ae\196\001a'
- .. '\004\006\009\147\000\196\002ag\196\001a'
- .. '\004\007\009\147\000\196\002ah\196\001a'
- .. '\004\008\009\147\000\196\002ai\196\001a'
- )
+ it('correctly merges history items with duplicate adj entry when writing', function()
+ wshada(
+ '\004\000\009\147\000\196\002ab\196\001a'
+ .. '\004\001\009\147\000\196\002ac\196\001a'
+ .. '\004\002\009\147\000\196\002ad\196\001a'
+ .. '\004\003\009\147\000\196\002ad\196\001a'
+ .. '\004\004\009\147\000\196\002af\196\001a'
+ .. '\004\005\009\147\000\196\002ae\196\001a'
+ .. '\004\006\009\147\000\196\002ag\196\001a'
+ .. '\004\007\009\147\000\196\002ah\196\001a'
+ .. '\004\008\009\147\000\196\002ai\196\001a'
+ )
eq(0, exc_exec('wshada ' .. shada_fname))
- local items = {'ab', 'ac', 'ad', 'af', 'ae', 'ag', 'ah', 'ai'}
+ local items = { 'ab', 'ac', 'ad', 'af', 'ae', 'ag', 'ah', 'ai' }
local found = 0
for _, v in ipairs(read_shada_file(shada_fname)) do
if v.type == 4 and v.value[1] == 0 then
@@ -242,8 +234,7 @@ describe('ShaDa search pattern support code', function()
os.remove(shada_fname)
end)
- it('uses last search pattern with gt timestamp from instance when reading',
- function()
+ it('uses last search pattern with gt timestamp from instance when reading', function()
wshada('\002\001\011\130\162sX\194\162sp\196\001-')
eq(0, exc_exec(sdrcmd()))
wshada('\002\000\011\130\162sX\194\162sp\196\001?')
@@ -251,8 +242,7 @@ describe('ShaDa search pattern support code', function()
eq('-', funcs.getreg('/'))
end)
- it('uses last search pattern with gt tstamp from file when reading with bang',
- function()
+ it('uses last search pattern with gt tstamp from file when reading with bang', function()
wshada('\002\001\011\130\162sX\194\162sp\196\001-')
eq(0, exc_exec(sdrcmd()))
wshada('\002\000\011\130\162sX\194\162sp\196\001?')
@@ -260,8 +250,7 @@ describe('ShaDa search pattern support code', function()
eq('?', funcs.getreg('/'))
end)
- it('uses last search pattern with eq timestamp from instance when reading',
- function()
+ it('uses last search pattern with eq timestamp from instance when reading', function()
wshada('\002\001\011\130\162sX\194\162sp\196\001-')
eq(0, exc_exec(sdrcmd()))
wshada('\002\001\011\130\162sX\194\162sp\196\001?')
@@ -269,8 +258,7 @@ describe('ShaDa search pattern support code', function()
eq('-', funcs.getreg('/'))
end)
- it('uses last search pattern with gt timestamp from file when reading',
- function()
+ it('uses last search pattern with gt timestamp from file when reading', function()
wshada('\002\001\011\130\162sX\194\162sp\196\001-')
eq(0, exc_exec(sdrcmd()))
wshada('\002\002\011\130\162sX\194\162sp\196\001?')
@@ -278,8 +266,7 @@ describe('ShaDa search pattern support code', function()
eq('?', funcs.getreg('/'))
end)
- it('uses last search pattern with gt timestamp from instance when writing',
- function()
+ it('uses last search pattern with gt timestamp from instance when writing', function()
wshada('\002\001\011\130\162sX\194\162sp\196\001-')
eq(0, exc_exec(sdrcmd()))
wshada('\002\000\011\130\162sX\194\162sp\196\001?')
@@ -294,8 +281,7 @@ describe('ShaDa search pattern support code', function()
eq(1, found)
end)
- it('uses last search pattern with eq timestamp from instance when writing',
- function()
+ it('uses last search pattern with eq timestamp from instance when writing', function()
wshada('\002\001\011\130\162sX\194\162sp\196\001-')
eq(0, exc_exec(sdrcmd()))
wshada('\002\001\011\130\162sX\194\162sp\196\001?')
@@ -310,8 +296,7 @@ describe('ShaDa search pattern support code', function()
eq(1, found)
end)
- it('uses last search pattern with gt timestamp from file when writing',
- function()
+ it('uses last search pattern with gt timestamp from file when writing', function()
wshada('\002\001\011\130\162sX\194\162sp\196\001-')
eq(0, exc_exec(sdrcmd()))
wshada('\002\002\011\130\162sX\194\162sp\196\001?')
@@ -326,8 +311,7 @@ describe('ShaDa search pattern support code', function()
eq(1, found)
end)
- it('uses last s/ pattern with gt timestamp from instance when reading',
- function()
+ it('uses last s/ pattern with gt timestamp from instance when reading', function()
wshada('\002\001\011\130\162ss\195\162sp\196\001-')
eq(0, exc_exec(sdrcmd()))
wshada('\002\000\011\130\162ss\195\162sp\196\001?')
@@ -335,8 +319,7 @@ describe('ShaDa search pattern support code', function()
eq('-', funcs.getreg('/'))
end)
- it('uses last s/ pattern with gt timestamp from file when reading with !',
- function()
+ it('uses last s/ pattern with gt timestamp from file when reading with !', function()
wshada('\002\001\011\130\162ss\195\162sp\196\001-')
eq(0, exc_exec(sdrcmd()))
wshada('\002\000\011\130\162ss\195\162sp\196\001?')
@@ -344,8 +327,7 @@ describe('ShaDa search pattern support code', function()
eq('?', funcs.getreg('/'))
end)
- it('uses last s/ pattern with eq timestamp from instance when reading',
- function()
+ it('uses last s/ pattern with eq timestamp from instance when reading', function()
wshada('\002\001\011\130\162ss\195\162sp\196\001-')
eq(0, exc_exec(sdrcmd()))
wshada('\002\001\011\130\162ss\195\162sp\196\001?')
@@ -353,8 +335,7 @@ describe('ShaDa search pattern support code', function()
eq('-', funcs.getreg('/'))
end)
- it('uses last s/ pattern with gt timestamp from file when reading',
- function()
+ it('uses last s/ pattern with gt timestamp from file when reading', function()
wshada('\002\001\011\130\162ss\195\162sp\196\001-')
eq(0, exc_exec(sdrcmd()))
wshada('\002\002\011\130\162ss\195\162sp\196\001?')
@@ -362,8 +343,7 @@ describe('ShaDa search pattern support code', function()
eq('?', funcs.getreg('/'))
end)
- it('uses last s/ pattern with gt timestamp from instance when writing',
- function()
+ it('uses last s/ pattern with gt timestamp from instance when writing', function()
wshada('\002\001\011\130\162ss\195\162sp\196\001-')
eq(0, exc_exec(sdrcmd()))
wshada('\002\000\011\130\162ss\195\162sp\196\001?')
@@ -378,8 +358,7 @@ describe('ShaDa search pattern support code', function()
eq(1, found)
end)
- it('uses last s/ pattern with eq timestamp from instance when writing',
- function()
+ it('uses last s/ pattern with eq timestamp from instance when writing', function()
wshada('\002\001\011\130\162ss\195\162sp\196\001-')
eq(0, exc_exec(sdrcmd()))
wshada('\002\001\011\130\162ss\195\162sp\196\001?')
@@ -394,8 +373,7 @@ describe('ShaDa search pattern support code', function()
eq(1, found)
end)
- it('uses last s/ pattern with gt timestamp from file when writing',
- function()
+ it('uses last s/ pattern with gt timestamp from file when writing', function()
wshada('\002\001\011\130\162ss\195\162sp\196\001-')
eq(0, exc_exec(sdrcmd()))
wshada('\002\002\011\130\162ss\195\162sp\196\001?')
@@ -418,8 +396,7 @@ describe('ShaDa replacement string support code', function()
os.remove(shada_fname)
end)
- it('uses last replacement with gt timestamp from instance when reading',
- function()
+ it('uses last replacement with gt timestamp from instance when reading', function()
wshada('\003\001\004\145\196\001-')
eq(0, exc_exec(sdrcmd()))
wshada('\003\000\004\145\196\001?')
@@ -429,8 +406,7 @@ describe('ShaDa replacement string support code', function()
nvim_command('bwipeout!')
end)
- it('uses last replacement with gt timestamp from file when reading with bang',
- function()
+ it('uses last replacement with gt timestamp from file when reading with bang', function()
wshada('\003\001\004\145\196\001-')
eq(0, exc_exec(sdrcmd()))
wshada('\003\000\004\145\196\001?')
@@ -440,8 +416,7 @@ describe('ShaDa replacement string support code', function()
nvim_command('bwipeout!')
end)
- it('uses last replacement with eq timestamp from instance when reading',
- function()
+ it('uses last replacement with eq timestamp from instance when reading', function()
wshada('\003\001\004\145\196\001-')
eq(0, exc_exec(sdrcmd()))
wshada('\003\001\004\145\196\001?')
@@ -451,8 +426,7 @@ describe('ShaDa replacement string support code', function()
nvim_command('bwipeout!')
end)
- it('uses last replacement with gt timestamp from file when reading',
- function()
+ it('uses last replacement with gt timestamp from file when reading', function()
wshada('\003\001\004\145\196\001-')
eq(0, exc_exec(sdrcmd()))
wshada('\003\002\004\145\196\001?')
@@ -462,8 +436,7 @@ describe('ShaDa replacement string support code', function()
nvim_command('bwipeout!')
end)
- it('uses last replacement with gt timestamp from instance when writing',
- function()
+ it('uses last replacement with gt timestamp from instance when writing', function()
wshada('\003\001\004\145\196\001-')
eq(0, exc_exec(sdrcmd()))
wshada('\003\000\004\145\196\001?')
@@ -477,8 +450,7 @@ describe('ShaDa replacement string support code', function()
eq(1, found)
end)
- it('uses last replacement with eq timestamp from instance when writing',
- function()
+ it('uses last replacement with eq timestamp from instance when writing', function()
wshada('\003\001\004\145\196\001-')
eq(0, exc_exec(sdrcmd()))
wshada('\003\001\004\145\196\001?')
@@ -492,8 +464,7 @@ describe('ShaDa replacement string support code', function()
eq(1, found)
end)
- it('uses last replacement with gt timestamp from file when writing',
- function()
+ it('uses last replacement with gt timestamp from file when writing', function()
wshada('\003\001\004\145\196\001-')
eq(0, exc_exec(sdrcmd()))
wshada('\003\002\004\145\196\001?')
@@ -515,8 +486,7 @@ describe('ShaDa marks support code', function()
os.remove(shada_fname)
end)
- it('uses last A mark with gt timestamp from instance when reading',
- function()
+ it('uses last A mark with gt timestamp from instance when reading', function()
wshada('\007\001\018\131\162mX\195\161f\196\006' .. mock_file_path .. '-\161nA')
eq(0, exc_exec(sdrcmd()))
wshada('\007\000\018\131\162mX\195\161f\196\006' .. mock_file_path .. '?\161nA')
@@ -538,12 +508,18 @@ describe('ShaDa marks support code', function()
found[name] = (found[name] or 0) + 1
end
end
- eq({['0']=1, ['1']=1}, found)
+ eq({ ['0'] = 1, ['1'] = 1 }, found)
end)
it('removes duplicates while merging', function()
- wshada('\007\001\014\130\161f\196\006' .. mock_file_path .. '-\161n9'
- .. '\007\001\014\130\161f\196\006' .. mock_file_path .. '-\161n9')
+ wshada(
+ '\007\001\014\130\161f\196\006'
+ .. mock_file_path
+ .. '-\161n9'
+ .. '\007\001\014\130\161f\196\006'
+ .. mock_file_path
+ .. '-\161n9'
+ )
eq(0, exc_exec(sdrcmd()))
eq(0, exc_exec('wshada ' .. shada_fname))
local found = 0
@@ -556,19 +532,42 @@ describe('ShaDa marks support code', function()
eq(1, found)
end)
- it('does not leak when no append is performed due to too many marks',
- function()
- wshada('\007\002\018\131\162mX\195\161f\196\006' .. mock_file_path .. 'a\161n0'
- .. '\007\002\018\131\162mX\195\161f\196\006' .. mock_file_path .. 'b\161n1'
- .. '\007\002\018\131\162mX\195\161f\196\006' .. mock_file_path .. 'c\161n2'
- .. '\007\002\018\131\162mX\195\161f\196\006' .. mock_file_path .. 'd\161n3'
- .. '\007\002\018\131\162mX\195\161f\196\006' .. mock_file_path .. 'e\161n4'
- .. '\007\002\018\131\162mX\195\161f\196\006' .. mock_file_path .. 'f\161n5'
- .. '\007\002\018\131\162mX\195\161f\196\006' .. mock_file_path .. 'g\161n6'
- .. '\007\002\018\131\162mX\195\161f\196\006' .. mock_file_path .. 'h\161n7'
- .. '\007\002\018\131\162mX\195\161f\196\006' .. mock_file_path .. 'i\161n8'
- .. '\007\002\018\131\162mX\195\161f\196\006' .. mock_file_path .. 'j\161n9'
- .. '\007\001\018\131\162mX\195\161f\196\006' .. mock_file_path .. 'k\161n9')
+ it('does not leak when no append is performed due to too many marks', function()
+ wshada(
+ '\007\002\018\131\162mX\195\161f\196\006'
+ .. mock_file_path
+ .. 'a\161n0'
+ .. '\007\002\018\131\162mX\195\161f\196\006'
+ .. mock_file_path
+ .. 'b\161n1'
+ .. '\007\002\018\131\162mX\195\161f\196\006'
+ .. mock_file_path
+ .. 'c\161n2'
+ .. '\007\002\018\131\162mX\195\161f\196\006'
+ .. mock_file_path
+ .. 'd\161n3'
+ .. '\007\002\018\131\162mX\195\161f\196\006'
+ .. mock_file_path
+ .. 'e\161n4'
+ .. '\007\002\018\131\162mX\195\161f\196\006'
+ .. mock_file_path
+ .. 'f\161n5'
+ .. '\007\002\018\131\162mX\195\161f\196\006'
+ .. mock_file_path
+ .. 'g\161n6'
+ .. '\007\002\018\131\162mX\195\161f\196\006'
+ .. mock_file_path
+ .. 'h\161n7'
+ .. '\007\002\018\131\162mX\195\161f\196\006'
+ .. mock_file_path
+ .. 'i\161n8'
+ .. '\007\002\018\131\162mX\195\161f\196\006'
+ .. mock_file_path
+ .. 'j\161n9'
+ .. '\007\001\018\131\162mX\195\161f\196\006'
+ .. mock_file_path
+ .. 'k\161n9'
+ )
eq(0, exc_exec(sdrcmd()))
eq(0, exc_exec('wshada ' .. shada_fname))
local found = {}
@@ -577,22 +576,45 @@ describe('ShaDa marks support code', function()
found[#found + 1] = v.value.f:sub(#v.value.f)
end
end
- eq({'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j'}, found)
- end)
-
- it('does not leak when last mark in file removes some of the earlier ones',
- function()
- wshada('\007\002\018\131\162mX\195\161f\196\006' .. mock_file_path .. 'a\161n0'
- .. '\007\002\018\131\162mX\195\161f\196\006' .. mock_file_path .. 'b\161n1'
- .. '\007\002\018\131\162mX\195\161f\196\006' .. mock_file_path .. 'c\161n2'
- .. '\007\002\018\131\162mX\195\161f\196\006' .. mock_file_path .. 'd\161n3'
- .. '\007\002\018\131\162mX\195\161f\196\006' .. mock_file_path .. 'e\161n4'
- .. '\007\002\018\131\162mX\195\161f\196\006' .. mock_file_path .. 'f\161n5'
- .. '\007\002\018\131\162mX\195\161f\196\006' .. mock_file_path .. 'g\161n6'
- .. '\007\002\018\131\162mX\195\161f\196\006' .. mock_file_path .. 'h\161n7'
- .. '\007\002\018\131\162mX\195\161f\196\006' .. mock_file_path .. 'i\161n8'
- .. '\007\002\018\131\162mX\195\161f\196\006' .. mock_file_path .. 'j\161n9'
- .. '\007\003\018\131\162mX\195\161f\196\006' .. mock_file_path .. 'k\161n9')
+ eq({ 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j' }, found)
+ end)
+
+ it('does not leak when last mark in file removes some of the earlier ones', function()
+ wshada(
+ '\007\002\018\131\162mX\195\161f\196\006'
+ .. mock_file_path
+ .. 'a\161n0'
+ .. '\007\002\018\131\162mX\195\161f\196\006'
+ .. mock_file_path
+ .. 'b\161n1'
+ .. '\007\002\018\131\162mX\195\161f\196\006'
+ .. mock_file_path
+ .. 'c\161n2'
+ .. '\007\002\018\131\162mX\195\161f\196\006'
+ .. mock_file_path
+ .. 'd\161n3'
+ .. '\007\002\018\131\162mX\195\161f\196\006'
+ .. mock_file_path
+ .. 'e\161n4'
+ .. '\007\002\018\131\162mX\195\161f\196\006'
+ .. mock_file_path
+ .. 'f\161n5'
+ .. '\007\002\018\131\162mX\195\161f\196\006'
+ .. mock_file_path
+ .. 'g\161n6'
+ .. '\007\002\018\131\162mX\195\161f\196\006'
+ .. mock_file_path
+ .. 'h\161n7'
+ .. '\007\002\018\131\162mX\195\161f\196\006'
+ .. mock_file_path
+ .. 'i\161n8'
+ .. '\007\002\018\131\162mX\195\161f\196\006'
+ .. mock_file_path
+ .. 'j\161n9'
+ .. '\007\003\018\131\162mX\195\161f\196\006'
+ .. mock_file_path
+ .. 'k\161n9'
+ )
eq(0, exc_exec(sdrcmd()))
eq(0, exc_exec('wshada ' .. shada_fname))
local found = {}
@@ -601,11 +623,10 @@ describe('ShaDa marks support code', function()
found[#found + 1] = v.value.f:sub(#v.value.f)
end
end
- eq({'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'k'}, found)
+ eq({ 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'k' }, found)
end)
- it('uses last A mark with gt timestamp from file when reading with !',
- function()
+ it('uses last A mark with gt timestamp from file when reading with !', function()
wshada('\007\001\018\131\162mX\195\161f\196\006' .. mock_file_path .. '-\161nA')
eq(0, exc_exec(sdrcmd()))
wshada('\007\000\018\131\162mX\195\161f\196\006' .. mock_file_path .. '?\161nA')
@@ -614,8 +635,7 @@ describe('ShaDa marks support code', function()
eq('?', funcs.fnamemodify(curbufmeths.get_name(), ':t'))
end)
- it('uses last A mark with eq timestamp from instance when reading',
- function()
+ it('uses last A mark with eq timestamp from instance when reading', function()
wshada('\007\001\018\131\162mX\195\161f\196\006' .. mock_file_path .. '-\161nA')
eq(0, exc_exec(sdrcmd()))
wshada('\007\001\018\131\162mX\195\161f\196\006' .. mock_file_path .. '?\161nA')
@@ -624,8 +644,7 @@ describe('ShaDa marks support code', function()
eq('-', funcs.fnamemodify(curbufmeths.get_name(), ':t'))
end)
- it('uses last A mark with gt timestamp from file when reading',
- function()
+ it('uses last A mark with gt timestamp from file when reading', function()
wshada('\007\001\018\131\162mX\195\161f\196\006' .. mock_file_path .. '-\161nA')
eq(0, exc_exec(sdrcmd()))
wshada('\007\002\018\131\162mX\195\161f\196\006' .. mock_file_path .. '?\161nA')
@@ -634,8 +653,7 @@ describe('ShaDa marks support code', function()
eq('?', funcs.fnamemodify(curbufmeths.get_name(), ':t'))
end)
- it('uses last A mark with gt timestamp from instance when writing',
- function()
+ it('uses last A mark with gt timestamp from instance when writing', function()
wshada('\007\001\018\131\162mX\195\161f\196\006' .. mock_file_path .. '-\161nA')
eq(0, exc_exec(sdrcmd()))
wshada('\007\000\018\131\162mX\195\161f\196\006' .. mock_file_path .. '?\161nA')
@@ -649,11 +667,10 @@ describe('ShaDa marks support code', function()
found[name] = (found[name] or 0) + 1
end
end
- eq({['0']=1, A=1}, found)
+ eq({ ['0'] = 1, A = 1 }, found)
end)
- it('uses last A mark with eq timestamp from instance when writing',
- function()
+ it('uses last A mark with eq timestamp from instance when writing', function()
wshada('\007\001\018\131\162mX\195\161f\196\006' .. mock_file_path .. '-\161nA')
eq(0, exc_exec(sdrcmd()))
wshada('\007\001\018\131\162mX\195\161f\196\006' .. mock_file_path .. '?\161nA')
@@ -667,7 +684,7 @@ describe('ShaDa marks support code', function()
found[name] = (found[name] or 0) + 1
end
end
- eq({['0']=1, A=1}, found)
+ eq({ ['0'] = 1, A = 1 }, found)
end)
it('uses last A mark with gt timestamp from file when writing', function()
@@ -686,13 +703,12 @@ describe('ShaDa marks support code', function()
found[name] = t
end
end
- eq({['0']={[mock_file_path .. '-']=1}, A={[mock_file_path .. '?']=1}}, found)
+ eq({ ['0'] = { [mock_file_path .. '-'] = 1 }, A = { [mock_file_path .. '?'] = 1 } }, found)
end)
- it('uses last a mark with gt timestamp from instance when reading',
- function()
+ it('uses last a mark with gt timestamp from instance when reading', function()
nvim_command('edit ' .. mock_file_path .. '-')
- funcs.setline(1, {'-', '?'})
+ funcs.setline(1, { '-', '?' })
wshada('\010\001\017\131\161l\001\161f\196\006' .. mock_file_path .. '-\161na')
eq(0, exc_exec(sdrcmd()))
wshada('\010\000\017\131\161l\002\161f\196\006' .. mock_file_path .. '-\161na')
@@ -701,10 +717,9 @@ describe('ShaDa marks support code', function()
eq('-', funcs.getline('.'))
end)
- it('uses last a mark with gt timestamp from file when reading with !',
- function()
+ it('uses last a mark with gt timestamp from file when reading with !', function()
nvim_command('edit ' .. mock_file_path .. '-')
- funcs.setline(1, {'-', '?'})
+ funcs.setline(1, { '-', '?' })
wshada('\010\001\017\131\161l\001\161f\196\006' .. mock_file_path .. '-\161na')
eq(0, exc_exec(sdrcmd()))
wshada('\010\000\017\131\161l\002\161f\196\006' .. mock_file_path .. '-\161na')
@@ -713,10 +728,9 @@ describe('ShaDa marks support code', function()
eq('?', funcs.getline('.'))
end)
- it('uses last a mark with eq timestamp from instance when reading',
- function()
+ it('uses last a mark with eq timestamp from instance when reading', function()
nvim_command('edit ' .. mock_file_path .. '-')
- funcs.setline(1, {'-', '?'})
+ funcs.setline(1, { '-', '?' })
wshada('\010\001\017\131\161l\001\161f\196\006' .. mock_file_path .. '-\161na')
eq(0, exc_exec(sdrcmd()))
wshada('\010\001\017\131\161l\002\161f\196\006' .. mock_file_path .. '-\161na')
@@ -725,10 +739,9 @@ describe('ShaDa marks support code', function()
eq('-', funcs.getline('.'))
end)
- it('uses last a mark with gt timestamp from file when reading',
- function()
+ it('uses last a mark with gt timestamp from file when reading', function()
nvim_command('edit ' .. mock_file_path .. '-')
- funcs.setline(1, {'-', '?'})
+ funcs.setline(1, { '-', '?' })
wshada('\010\001\017\131\161l\001\161f\196\006' .. mock_file_path .. '-\161na')
eq(0, exc_exec(sdrcmd()))
wshada('\010\002\017\131\161l\002\161f\196\006' .. mock_file_path .. '-\161na')
@@ -737,10 +750,9 @@ describe('ShaDa marks support code', function()
eq('?', funcs.getline('.'))
end)
- it('uses last a mark with gt timestamp from instance when writing',
- function()
+ it('uses last a mark with gt timestamp from instance when writing', function()
nvim_command('edit ' .. mock_file_path .. '-')
- funcs.setline(1, {'-', '?'})
+ funcs.setline(1, { '-', '?' })
wshada('\010\001\017\131\161l\001\161f\196\006' .. mock_file_path .. '-\161na')
eq(0, exc_exec(sdrcmd()))
wshada('\010\000\017\131\161l\002\161f\196\006' .. mock_file_path .. '-\161na')
@@ -749,7 +761,11 @@ describe('ShaDa marks support code', function()
eq(0, exc_exec('wshada ' .. shada_fname))
local found = 0
for _, v in ipairs(read_shada_file(shada_fname)) do
- if v.type == 10 and v.value.f == '' .. mock_file_path .. '-' and v.value.n == ('a'):byte() then
+ if
+ v.type == 10
+ and v.value.f == '' .. mock_file_path .. '-'
+ and v.value.n == ('a'):byte()
+ then
eq(true, v.value.l == 1 or v.value.l == nil)
found = found + 1
end
@@ -757,10 +773,9 @@ describe('ShaDa marks support code', function()
eq(1, found)
end)
- it('uses last a mark with eq timestamp from instance when writing',
- function()
+ it('uses last a mark with eq timestamp from instance when writing', function()
nvim_command('edit ' .. mock_file_path .. '-')
- funcs.setline(1, {'-', '?'})
+ funcs.setline(1, { '-', '?' })
wshada('\010\001\017\131\161l\001\161f\196\006' .. mock_file_path .. '-\161na')
eq(0, exc_exec(sdrcmd()))
wshada('\010\001\017\131\161l\002\161f\196\006' .. mock_file_path .. '-\161na')
@@ -769,7 +784,11 @@ describe('ShaDa marks support code', function()
eq(0, exc_exec('wshada ' .. shada_fname))
local found = 0
for _, v in ipairs(read_shada_file(shada_fname)) do
- if v.type == 10 and v.value.f == '' .. mock_file_path .. '-' and v.value.n == ('a'):byte() then
+ if
+ v.type == 10
+ and v.value.f == '' .. mock_file_path .. '-'
+ and v.value.n == ('a'):byte()
+ then
eq(true, v.value.l == 1 or v.value.l == nil)
found = found + 1
end
@@ -777,10 +796,9 @@ describe('ShaDa marks support code', function()
eq(1, found)
end)
- it('uses last a mark with gt timestamp from file when writing',
- function()
+ it('uses last a mark with gt timestamp from file when writing', function()
nvim_command('edit ' .. mock_file_path .. '-')
- funcs.setline(1, {'-', '?'})
+ funcs.setline(1, { '-', '?' })
wshada('\010\001\017\131\161l\001\161f\196\006' .. mock_file_path .. '-\161na')
eq(0, exc_exec(sdrcmd()))
wshada('\010\002\017\131\161l\002\161f\196\006' .. mock_file_path .. '-\161na')
@@ -789,7 +807,11 @@ describe('ShaDa marks support code', function()
eq(0, exc_exec('wshada ' .. shada_fname))
local found = 0
for _, v in ipairs(read_shada_file(shada_fname)) do
- if v.type == 10 and v.value.f == '' .. mock_file_path .. '-' and v.value.n == ('a'):byte() then
+ if
+ v.type == 10
+ and v.value.f == '' .. mock_file_path .. '-'
+ and v.value.n == ('a'):byte()
+ then
eq(2, v.value.l)
found = found + 1
end
@@ -805,8 +827,7 @@ describe('ShaDa registers support code', function()
os.remove(shada_fname)
end)
- it('uses last a register with gt timestamp from instance when reading',
- function()
+ it('uses last a register with gt timestamp from instance when reading', function()
wshada('\005\001\015\131\161na\162rX\194\162rc\145\196\001-')
eq(0, exc_exec(sdrcmd()))
wshada('\005\000\015\131\161na\162rX\194\162rc\145\196\001?')
@@ -814,8 +835,7 @@ describe('ShaDa registers support code', function()
eq('-', funcs.getreg('a'))
end)
- it('uses last a register with gt timestamp from file when reading with !',
- function()
+ it('uses last a register with gt timestamp from file when reading with !', function()
wshada('\005\001\015\131\161na\162rX\194\162rc\145\196\001-')
eq(0, exc_exec(sdrcmd()))
wshada('\005\000\015\131\161na\162rX\194\162rc\145\196\001?')
@@ -823,8 +843,7 @@ describe('ShaDa registers support code', function()
eq('?', funcs.getreg('a'))
end)
- it('uses last a register with eq timestamp from instance when reading',
- function()
+ it('uses last a register with eq timestamp from instance when reading', function()
wshada('\005\001\015\131\161na\162rX\194\162rc\145\196\001-')
eq(0, exc_exec(sdrcmd()))
wshada('\005\001\015\131\161na\162rX\194\162rc\145\196\001?')
@@ -832,8 +851,7 @@ describe('ShaDa registers support code', function()
eq('-', funcs.getreg('a'))
end)
- it('uses last a register with gt timestamp from file when reading',
- function()
+ it('uses last a register with gt timestamp from file when reading', function()
wshada('\005\001\015\131\161na\162rX\194\162rc\145\196\001-')
eq(0, exc_exec(sdrcmd()))
wshada('\005\002\015\131\161na\162rX\194\162rc\145\196\001?')
@@ -841,8 +859,7 @@ describe('ShaDa registers support code', function()
eq('?', funcs.getreg('a'))
end)
- it('uses last a register with gt timestamp from instance when writing',
- function()
+ it('uses last a register with gt timestamp from instance when writing', function()
wshada('\005\001\015\131\161na\162rX\194\162rc\145\196\001-')
eq(0, exc_exec(sdrcmd()))
wshada('\005\000\015\131\161na\162rX\194\162rc\145\196\001?')
@@ -851,15 +868,14 @@ describe('ShaDa registers support code', function()
local found = 0
for _, v in ipairs(read_shada_file(shada_fname)) do
if v.type == 5 and v.value.n == ('a'):byte() then
- eq({'-'}, v.value.rc)
+ eq({ '-' }, v.value.rc)
found = found + 1
end
end
eq(1, found)
end)
- it('uses last a register with eq timestamp from instance when writing',
- function()
+ it('uses last a register with eq timestamp from instance when writing', function()
wshada('\005\001\015\131\161na\162rX\194\162rc\145\196\001-')
eq(0, exc_exec(sdrcmd()))
wshada('\005\001\015\131\161na\162rX\194\162rc\145\196\001?')
@@ -868,15 +884,14 @@ describe('ShaDa registers support code', function()
local found = 0
for _, v in ipairs(read_shada_file(shada_fname)) do
if v.type == 5 and v.value.n == ('a'):byte() then
- eq({'-'}, v.value.rc)
+ eq({ '-' }, v.value.rc)
found = found + 1
end
end
eq(1, found)
end)
- it('uses last a register with gt timestamp from file when writing',
- function()
+ it('uses last a register with gt timestamp from file when writing', function()
wshada('\005\001\015\131\161na\162rX\194\162rc\145\196\001-')
eq(0, exc_exec(sdrcmd()))
wshada('\005\002\015\131\161na\162rX\194\162rc\145\196\001?')
@@ -885,7 +900,7 @@ describe('ShaDa registers support code', function()
local found = 0
for _, v in ipairs(read_shada_file(shada_fname)) do
if v.type == 5 and v.value.n == ('a'):byte() then
- eq({'?'}, v.value.rc)
+ eq({ '?' }, v.value.rc)
found = found + 1
end
end
@@ -901,39 +916,84 @@ describe('ShaDa jumps support code', function()
end)
it('merges jumps when reading', function()
- wshada('\008\001\018\131\162mX\195\161f\196\006' .. mock_file_path .. 'c\161l\002'
- .. '\008\004\018\131\162mX\195\161f\196\006' .. mock_file_path .. 'd\161l\002'
- .. '\008\007\018\131\162mX\195\161f\196\006' .. mock_file_path .. 'e\161l\002')
- eq(0, exc_exec(sdrcmd()))
- wshada('\008\001\018\131\162mX\195\161f\196\006' .. mock_file_path .. 'c\161l\002'
- .. '\008\004\018\131\162mX\195\161f\196\006' .. mock_file_path .. 'd\161l\003'
- .. '\008\007\018\131\162mX\195\161f\196\006' .. mock_file_path .. 'f\161l\002')
+ wshada(
+ '\008\001\018\131\162mX\195\161f\196\006'
+ .. mock_file_path
+ .. 'c\161l\002'
+ .. '\008\004\018\131\162mX\195\161f\196\006'
+ .. mock_file_path
+ .. 'd\161l\002'
+ .. '\008\007\018\131\162mX\195\161f\196\006'
+ .. mock_file_path
+ .. 'e\161l\002'
+ )
+ eq(0, exc_exec(sdrcmd()))
+ wshada(
+ '\008\001\018\131\162mX\195\161f\196\006'
+ .. mock_file_path
+ .. 'c\161l\002'
+ .. '\008\004\018\131\162mX\195\161f\196\006'
+ .. mock_file_path
+ .. 'd\161l\003'
+ .. '\008\007\018\131\162mX\195\161f\196\006'
+ .. mock_file_path
+ .. 'f\161l\002'
+ )
eq(0, exc_exec(sdrcmd()))
eq('', curbufmeths.get_name())
- eq( ' jump line col file/text\n'
- .. ' 5 2 0 ' .. mock_file_path .. 'c\n'
- .. ' 4 2 0 ' .. mock_file_path .. 'd\n'
- .. ' 3 3 0 ' .. mock_file_path .. 'd\n'
- .. ' 2 2 0 ' .. mock_file_path .. 'e\n'
- .. ' 1 2 0 ' .. mock_file_path .. 'f\n'
- .. '>', exec_capture('jumps'))
+ eq(
+ ' jump line col file/text\n'
+ .. ' 5 2 0 '
+ .. mock_file_path
+ .. 'c\n'
+ .. ' 4 2 0 '
+ .. mock_file_path
+ .. 'd\n'
+ .. ' 3 3 0 '
+ .. mock_file_path
+ .. 'd\n'
+ .. ' 2 2 0 '
+ .. mock_file_path
+ .. 'e\n'
+ .. ' 1 2 0 '
+ .. mock_file_path
+ .. 'f\n'
+ .. '>',
+ exec_capture('jumps')
+ )
end)
it('merges jumps when writing', function()
- wshada('\008\001\018\131\162mX\195\161f\196\006' .. mock_file_path .. 'c\161l\002'
- .. '\008\004\018\131\162mX\195\161f\196\006' .. mock_file_path .. 'd\161l\002'
- .. '\008\007\018\131\162mX\195\161f\196\006' .. mock_file_path .. 'e\161l\002')
- eq(0, exc_exec(sdrcmd()))
- wshada('\008\001\018\131\162mX\195\161f\196\006' .. mock_file_path .. 'c\161l\002'
- .. '\008\004\018\131\162mX\195\161f\196\006' .. mock_file_path .. 'd\161l\003'
- .. '\008\007\018\131\162mX\195\161f\196\006' .. mock_file_path .. 'f\161l\002')
+ wshada(
+ '\008\001\018\131\162mX\195\161f\196\006'
+ .. mock_file_path
+ .. 'c\161l\002'
+ .. '\008\004\018\131\162mX\195\161f\196\006'
+ .. mock_file_path
+ .. 'd\161l\002'
+ .. '\008\007\018\131\162mX\195\161f\196\006'
+ .. mock_file_path
+ .. 'e\161l\002'
+ )
+ eq(0, exc_exec(sdrcmd()))
+ wshada(
+ '\008\001\018\131\162mX\195\161f\196\006'
+ .. mock_file_path
+ .. 'c\161l\002'
+ .. '\008\004\018\131\162mX\195\161f\196\006'
+ .. mock_file_path
+ .. 'd\161l\003'
+ .. '\008\007\018\131\162mX\195\161f\196\006'
+ .. mock_file_path
+ .. 'f\161l\002'
+ )
eq(0, exc_exec('wshada ' .. shada_fname))
local jumps = {
- {file='' .. mock_file_path .. 'c', line=2},
- {file='' .. mock_file_path .. 'd', line=2},
- {file='' .. mock_file_path .. 'd', line=3},
- {file='' .. mock_file_path .. 'e', line=2},
- {file='' .. mock_file_path .. 'f', line=2},
+ { file = '' .. mock_file_path .. 'c', line = 2 },
+ { file = '' .. mock_file_path .. 'd', line = 2 },
+ { file = '' .. mock_file_path .. 'd', line = 3 },
+ { file = '' .. mock_file_path .. 'e', line = 2 },
+ { file = '' .. mock_file_path .. 'f', line = 2 },
}
local found = 0
for _, v in ipairs(read_shada_file(shada_fname)) do
@@ -949,25 +1009,28 @@ describe('ShaDa jumps support code', function()
it('merges JUMPLISTSIZE jumps when writing', function()
local jumps = {}
local shada = ''
- for i = 1,100 do
- shada = shada .. ('\008%c\018\131\162mX\195\161f\196\006' .. mock_file_path .. 'c\161l%c'
- ):format(i, i)
- jumps[i] = {file='' .. mock_file_path .. 'c', line=i}
+ for i = 1, 100 do
+ shada = shada
+ .. ('\008%c\018\131\162mX\195\161f\196\006' .. mock_file_path .. 'c\161l%c'):format(i, i)
+ jumps[i] = { file = '' .. mock_file_path .. 'c', line = i }
end
wshada(shada)
eq(0, exc_exec(sdrcmd()))
shada = ''
- for i = 1,101 do
+ for i = 1, 101 do
local t = i * 2
- shada = shada .. (
- '\008\204%c\019\131\162mX\195\161f\196\006' .. mock_file_path .. 'c\161l\204%c'
- ):format(t, t)
- jumps[(t > #jumps + 1) and (#jumps + 1) or t] = {file='' .. mock_file_path .. 'c', line=t}
+ shada = shada
+ .. ('\008\204%c\019\131\162mX\195\161f\196\006' .. mock_file_path .. 'c\161l\204%c'):format(
+ t,
+ t
+ )
+ jumps[(t > #jumps + 1) and (#jumps + 1) or t] =
+ { file = '' .. mock_file_path .. 'c', line = t }
end
wshada(shada)
eq(0, exc_exec('wshada ' .. shada_fname))
local shift = #jumps - 100
- for i = 1,100 do
+ for i = 1, 100 do
jumps[i] = jumps[i + shift]
end
local found = 0
@@ -992,40 +1055,75 @@ describe('ShaDa changes support code', function()
it('merges changes when reading', function()
nvim_command('edit ' .. mock_file_path .. 'c')
nvim_command('keepjumps call setline(1, range(7))')
- wshada('\011\001\018\131\162mX\195\161f\196\006' .. mock_file_path .. 'c\161l\001'
- .. '\011\004\018\131\162mX\195\161f\196\006' .. mock_file_path .. 'c\161l\002'
- .. '\011\007\018\131\162mX\195\161f\196\006' .. mock_file_path .. 'c\161l\003')
- eq(0, exc_exec(sdrcmd()))
- wshada('\011\001\018\131\162mX\194\161f\196\006' .. mock_file_path .. 'c\161l\001'
- .. '\011\004\018\131\162mX\195\161f\196\006' .. mock_file_path .. 'c\161l\005'
- .. '\011\008\018\131\162mX\195\161f\196\006' .. mock_file_path .. 'c\161l\004')
- eq(0, exc_exec(sdrcmd()))
- eq( 'change line col text\n'
- .. ' 5 1 0 0\n'
- .. ' 4 2 0 1\n'
- .. ' 3 5 0 4\n'
- .. ' 2 3 0 2\n'
- .. ' 1 4 0 3\n'
- .. '>', exec_capture('changes'))
+ wshada(
+ '\011\001\018\131\162mX\195\161f\196\006'
+ .. mock_file_path
+ .. 'c\161l\001'
+ .. '\011\004\018\131\162mX\195\161f\196\006'
+ .. mock_file_path
+ .. 'c\161l\002'
+ .. '\011\007\018\131\162mX\195\161f\196\006'
+ .. mock_file_path
+ .. 'c\161l\003'
+ )
+ eq(0, exc_exec(sdrcmd()))
+ wshada(
+ '\011\001\018\131\162mX\194\161f\196\006'
+ .. mock_file_path
+ .. 'c\161l\001'
+ .. '\011\004\018\131\162mX\195\161f\196\006'
+ .. mock_file_path
+ .. 'c\161l\005'
+ .. '\011\008\018\131\162mX\195\161f\196\006'
+ .. mock_file_path
+ .. 'c\161l\004'
+ )
+ eq(0, exc_exec(sdrcmd()))
+ eq(
+ 'change line col text\n'
+ .. ' 5 1 0 0\n'
+ .. ' 4 2 0 1\n'
+ .. ' 3 5 0 4\n'
+ .. ' 2 3 0 2\n'
+ .. ' 1 4 0 3\n'
+ .. '>',
+ exec_capture('changes')
+ )
end)
it('merges changes when writing', function()
nvim_command('edit ' .. mock_file_path .. 'c')
nvim_command('keepjumps call setline(1, range(7))')
- wshada('\011\001\018\131\162mX\195\161f\196\006' .. mock_file_path .. 'c\161l\001'
- .. '\011\004\018\131\162mX\195\161f\196\006' .. mock_file_path .. 'c\161l\002'
- .. '\011\007\018\131\162mX\195\161f\196\006' .. mock_file_path .. 'c\161l\003')
- eq(0, exc_exec(sdrcmd()))
- wshada('\011\001\018\131\162mX\194\161f\196\006' .. mock_file_path .. 'c\161l\001'
- .. '\011\004\018\131\162mX\195\161f\196\006' .. mock_file_path .. 'c\161l\005'
- .. '\011\008\018\131\162mX\195\161f\196\006' .. mock_file_path .. 'c\161l\004')
+ wshada(
+ '\011\001\018\131\162mX\195\161f\196\006'
+ .. mock_file_path
+ .. 'c\161l\001'
+ .. '\011\004\018\131\162mX\195\161f\196\006'
+ .. mock_file_path
+ .. 'c\161l\002'
+ .. '\011\007\018\131\162mX\195\161f\196\006'
+ .. mock_file_path
+ .. 'c\161l\003'
+ )
+ eq(0, exc_exec(sdrcmd()))
+ wshada(
+ '\011\001\018\131\162mX\194\161f\196\006'
+ .. mock_file_path
+ .. 'c\161l\001'
+ .. '\011\004\018\131\162mX\195\161f\196\006'
+ .. mock_file_path
+ .. 'c\161l\005'
+ .. '\011\008\018\131\162mX\195\161f\196\006'
+ .. mock_file_path
+ .. 'c\161l\004'
+ )
eq(0, exc_exec('wshada ' .. shada_fname))
local changes = {
- {line=1},
- {line=2},
- {line=5},
- {line=3},
- {line=4},
+ { line = 1 },
+ { line = 2 },
+ { line = 5 },
+ { line = 3 },
+ { line = 4 },
}
local found = 0
for _, v in ipairs(read_shada_file(shada_fname)) do
@@ -1042,25 +1140,27 @@ describe('ShaDa changes support code', function()
nvim_command('keepjumps call setline(1, range(202))')
local changes = {}
local shada = ''
- for i = 1,100 do
- shada = shada .. ('\011%c\018\131\162mX\195\161f\196\006' .. mock_file_path .. 'c\161l%c'
- ):format(i, i)
- changes[i] = {line=i}
+ for i = 1, 100 do
+ shada = shada
+ .. ('\011%c\018\131\162mX\195\161f\196\006' .. mock_file_path .. 'c\161l%c'):format(i, i)
+ changes[i] = { line = i }
end
wshada(shada)
eq(0, exc_exec(sdrcmd()))
shada = ''
- for i = 1,101 do
+ for i = 1, 101 do
local t = i * 2
- shada = shada .. (
- '\011\204%c\019\131\162mX\195\161f\196\006' .. mock_file_path .. 'c\161l\204%c'
- ):format(t, t)
- changes[(t > #changes + 1) and (#changes + 1) or t] = {line=t}
+ shada = shada
+ .. ('\011\204%c\019\131\162mX\195\161f\196\006' .. mock_file_path .. 'c\161l\204%c'):format(
+ t,
+ t
+ )
+ changes[(t > #changes + 1) and (#changes + 1) or t] = { line = t }
end
wshada(shada)
eq(0, exc_exec('wshada ' .. shada_fname))
local shift = #changes - 100
- for i = 1,100 do
+ for i = 1, 100 do
changes[i] = changes[i + shift]
end
local found = 0
@@ -1073,36 +1173,37 @@ describe('ShaDa changes support code', function()
eq(found, 100)
end)
- it('merges JUMPLISTSIZE changes when writing, with new items between old',
- function()
+ it('merges JUMPLISTSIZE changes when writing, with new items between old', function()
nvim_command('edit ' .. mock_file_path .. 'c')
nvim_command('keepjumps call setline(1, range(202))')
local shada = ''
- for i = 1,101 do
+ for i = 1, 101 do
local t = i * 2
- shada = shada .. (
- '\011\204%c\019\131\162mX\195\161f\196\006' .. mock_file_path .. 'c\161l\204%c'
- ):format(t, t)
+ shada = shada
+ .. ('\011\204%c\019\131\162mX\195\161f\196\006' .. mock_file_path .. 'c\161l\204%c'):format(
+ t,
+ t
+ )
end
wshada(shada)
eq(0, exc_exec(sdrcmd()))
shada = ''
- for i = 1,100 do
- shada = shada .. ('\011%c\018\131\162mX\195\161f\196\006' .. mock_file_path .. 'c\161l%c'
- ):format(i, i)
+ for i = 1, 100 do
+ shada = shada
+ .. ('\011%c\018\131\162mX\195\161f\196\006' .. mock_file_path .. 'c\161l%c'):format(i, i)
end
local changes = {}
for i = 1, 100 do
- changes[i] = {line=i}
+ changes[i] = { line = i }
end
for i = 1, 101 do
local t = i * 2
- changes[(t > #changes + 1) and (#changes + 1) or t] = {line=t}
+ changes[(t > #changes + 1) and (#changes + 1) or t] = { line = t }
end
wshada(shada)
eq(0, exc_exec('wshada ' .. shada_fname))
local shift = #changes - 100
- for i = 1,100 do
+ for i = 1, 100 do
changes[i] = changes[i + shift]
end
local found = 0