refactor: revert module namespace from canola back to oil
Problem: the canola rename creates unnecessary friction for users
migrating from stevearc/oil.nvim — every `require('oil')` call and
config reference must change.
Solution: revert all module paths, URL schemes, autocmd groups,
highlight groups, and filetype names back to `oil`. The repo stays
`canola.nvim` for identity; the code is a drop-in replacement.
This commit is contained in:
parent
9298b48c5d
commit
8dd67f91e8
68 changed files with 1622 additions and 1625 deletions
|
|
@ -1,5 +1,5 @@
|
|||
local canola = require('canola')
|
||||
local fs = require('canola.fs')
|
||||
local fs = require('oil.fs')
|
||||
local oil = require('oil')
|
||||
local test_util = require('spec.test_util')
|
||||
|
||||
describe('Alternate buffer', function()
|
||||
|
|
@ -9,27 +9,27 @@ describe('Alternate buffer', function()
|
|||
|
||||
it('sets previous buffer as alternate', function()
|
||||
vim.cmd.edit({ args = { 'foo' } })
|
||||
canola.open()
|
||||
test_util.wait_for_autocmd({ 'User', pattern = 'CanolaEnter' })
|
||||
oil.open()
|
||||
test_util.wait_for_autocmd({ 'User', pattern = 'OilEnter' })
|
||||
vim.cmd.edit({ args = { 'bar' } })
|
||||
assert.equals('foo', vim.fn.expand('#'))
|
||||
end)
|
||||
|
||||
it('sets previous buffer as alternate when editing url file', function()
|
||||
vim.cmd.edit({ args = { 'foo' } })
|
||||
canola.open()
|
||||
test_util.wait_for_autocmd({ 'User', pattern = 'CanolaEnter' })
|
||||
oil.open()
|
||||
test_util.wait_for_autocmd({ 'User', pattern = 'OilEnter' })
|
||||
local readme = fs.join(vim.fn.getcwd(), 'README.md')
|
||||
vim.cmd.edit({ args = { 'canola://' .. fs.os_to_posix_path(readme) } })
|
||||
vim.cmd.edit({ args = { 'oil://' .. fs.os_to_posix_path(readme) } })
|
||||
test_util.wait_for_autocmd('BufEnter')
|
||||
assert.equals(readme, vim.api.nvim_buf_get_name(0))
|
||||
assert.equals('foo', vim.fn.expand('#'))
|
||||
end)
|
||||
|
||||
it('sets previous buffer as alternate when editing canola://', function()
|
||||
it('sets previous buffer as alternate when editing oil://', function()
|
||||
vim.cmd.edit({ args = { 'foo' } })
|
||||
vim.cmd.edit({ args = { 'canola://' .. fs.os_to_posix_path(vim.fn.getcwd()) } })
|
||||
test_util.wait_for_autocmd({ 'User', pattern = 'CanolaEnter' })
|
||||
vim.cmd.edit({ args = { 'oil://' .. fs.os_to_posix_path(vim.fn.getcwd()) } })
|
||||
test_util.wait_for_autocmd({ 'User', pattern = 'OilEnter' })
|
||||
vim.cmd.edit({ args = { 'bar' } })
|
||||
assert.equals('foo', vim.fn.expand('#'))
|
||||
end)
|
||||
|
|
@ -37,8 +37,8 @@ describe('Alternate buffer', function()
|
|||
it('preserves alternate buffer if editing the same file', function()
|
||||
vim.cmd.edit({ args = { 'foo' } })
|
||||
vim.cmd.edit({ args = { 'bar' } })
|
||||
canola.open()
|
||||
test_util.wait_for_autocmd({ 'User', pattern = 'CanolaEnter' })
|
||||
oil.open()
|
||||
test_util.wait_for_autocmd({ 'User', pattern = 'OilEnter' })
|
||||
vim.cmd.edit({ args = { 'bar' } })
|
||||
assert.equals('foo', vim.fn.expand('#'))
|
||||
end)
|
||||
|
|
@ -46,71 +46,71 @@ describe('Alternate buffer', function()
|
|||
it('preserves alternate buffer if discarding changes', function()
|
||||
vim.cmd.edit({ args = { 'foo' } })
|
||||
vim.cmd.edit({ args = { 'bar' } })
|
||||
canola.open()
|
||||
test_util.wait_for_autocmd({ 'User', pattern = 'CanolaEnter' })
|
||||
canola.close()
|
||||
oil.open()
|
||||
test_util.wait_for_autocmd({ 'User', pattern = 'OilEnter' })
|
||||
oil.close()
|
||||
assert.equals('bar', vim.fn.expand('%'))
|
||||
assert.equals('foo', vim.fn.expand('#'))
|
||||
end)
|
||||
|
||||
it('sets previous buffer as alternate after multi-dir hops', function()
|
||||
vim.cmd.edit({ args = { 'foo' } })
|
||||
canola.open()
|
||||
test_util.wait_for_autocmd({ 'User', pattern = 'CanolaEnter' })
|
||||
canola.open()
|
||||
test_util.wait_for_autocmd({ 'User', pattern = 'CanolaEnter' })
|
||||
canola.open()
|
||||
test_util.wait_for_autocmd({ 'User', pattern = 'CanolaEnter' })
|
||||
canola.open()
|
||||
test_util.wait_for_autocmd({ 'User', pattern = 'CanolaEnter' })
|
||||
oil.open()
|
||||
test_util.wait_for_autocmd({ 'User', pattern = 'OilEnter' })
|
||||
oil.open()
|
||||
test_util.wait_for_autocmd({ 'User', pattern = 'OilEnter' })
|
||||
oil.open()
|
||||
test_util.wait_for_autocmd({ 'User', pattern = 'OilEnter' })
|
||||
oil.open()
|
||||
test_util.wait_for_autocmd({ 'User', pattern = 'OilEnter' })
|
||||
vim.cmd.edit({ args = { 'bar' } })
|
||||
assert.equals('foo', vim.fn.expand('#'))
|
||||
end)
|
||||
|
||||
it('sets previous buffer as alternate when inside canola buffer', function()
|
||||
it('sets previous buffer as alternate when inside oil buffer', function()
|
||||
vim.cmd.edit({ args = { 'foo' } })
|
||||
canola.open()
|
||||
test_util.wait_for_autocmd({ 'User', pattern = 'CanolaEnter' })
|
||||
oil.open()
|
||||
test_util.wait_for_autocmd({ 'User', pattern = 'OilEnter' })
|
||||
assert.equals('foo', vim.fn.expand('#'))
|
||||
vim.cmd.edit({ args = { 'bar' } })
|
||||
assert.equals('foo', vim.fn.expand('#'))
|
||||
canola.open()
|
||||
oil.open()
|
||||
assert.equals('bar', vim.fn.expand('#'))
|
||||
end)
|
||||
|
||||
it('preserves alternate when traversing canola dirs', function()
|
||||
it('preserves alternate when traversing oil dirs', function()
|
||||
vim.cmd.edit({ args = { 'foo' } })
|
||||
canola.open()
|
||||
test_util.wait_for_autocmd({ 'User', pattern = 'CanolaEnter' })
|
||||
oil.open()
|
||||
test_util.wait_for_autocmd({ 'User', pattern = 'OilEnter' })
|
||||
assert.equals('foo', vim.fn.expand('#'))
|
||||
vim.wait(1000, function()
|
||||
return canola.get_cursor_entry()
|
||||
return oil.get_cursor_entry()
|
||||
end, 10)
|
||||
vim.api.nvim_win_set_cursor(0, { 1, 1 })
|
||||
canola.select()
|
||||
test_util.wait_for_autocmd({ 'User', pattern = 'CanolaEnter' })
|
||||
oil.select()
|
||||
test_util.wait_for_autocmd({ 'User', pattern = 'OilEnter' })
|
||||
assert.equals('foo', vim.fn.expand('#'))
|
||||
end)
|
||||
|
||||
it('preserves alternate when opening preview', function()
|
||||
vim.cmd.edit({ args = { 'foo' } })
|
||||
canola.open()
|
||||
test_util.wait_for_autocmd({ 'User', pattern = 'CanolaEnter' })
|
||||
oil.open()
|
||||
test_util.wait_for_autocmd({ 'User', pattern = 'OilEnter' })
|
||||
assert.equals('foo', vim.fn.expand('#'))
|
||||
vim.wait(1000, function()
|
||||
return canola.get_cursor_entry()
|
||||
return oil.get_cursor_entry()
|
||||
end, 10)
|
||||
vim.api.nvim_win_set_cursor(0, { 1, 1 })
|
||||
canola.open_preview()
|
||||
test_util.wait_for_autocmd({ 'User', pattern = 'CanolaEnter' })
|
||||
oil.open_preview()
|
||||
test_util.wait_for_autocmd({ 'User', pattern = 'OilEnter' })
|
||||
assert.equals('foo', vim.fn.expand('#'))
|
||||
end)
|
||||
|
||||
describe('floating window', function()
|
||||
it('sets previous buffer as alternate', function()
|
||||
vim.cmd.edit({ args = { 'foo' } })
|
||||
canola.open_float()
|
||||
test_util.wait_for_autocmd({ 'User', pattern = 'CanolaEnter' })
|
||||
oil.open_float()
|
||||
test_util.wait_for_autocmd({ 'User', pattern = 'OilEnter' })
|
||||
vim.api.nvim_win_close(0, true)
|
||||
vim.cmd.edit({ args = { 'bar' } })
|
||||
assert.equals('foo', vim.fn.expand('#'))
|
||||
|
|
@ -119,8 +119,8 @@ describe('Alternate buffer', function()
|
|||
it('preserves alternate buffer if editing the same file', function()
|
||||
vim.cmd.edit({ args = { 'foo' } })
|
||||
vim.cmd.edit({ args = { 'bar' } })
|
||||
canola.open_float()
|
||||
test_util.wait_for_autocmd({ 'User', pattern = 'CanolaEnter' })
|
||||
oil.open_float()
|
||||
test_util.wait_for_autocmd({ 'User', pattern = 'OilEnter' })
|
||||
vim.api.nvim_win_close(0, true)
|
||||
vim.cmd.edit({ args = { 'bar' } })
|
||||
assert.equals('foo', vim.fn.expand('#'))
|
||||
|
|
@ -129,19 +129,19 @@ describe('Alternate buffer', function()
|
|||
it('preserves alternate buffer if discarding changes', function()
|
||||
vim.cmd.edit({ args = { 'foo' } })
|
||||
vim.cmd.edit({ args = { 'bar' } })
|
||||
canola.open_float()
|
||||
test_util.wait_for_autocmd({ 'User', pattern = 'CanolaEnter' })
|
||||
canola.close()
|
||||
oil.open_float()
|
||||
test_util.wait_for_autocmd({ 'User', pattern = 'OilEnter' })
|
||||
oil.close()
|
||||
assert.equals('foo', vim.fn.expand('#'))
|
||||
end)
|
||||
|
||||
it('preserves alternate when traversing to a new file', function()
|
||||
vim.cmd.edit({ args = { 'foo' } })
|
||||
canola.open_float()
|
||||
test_util.wait_for_autocmd({ 'User', pattern = 'CanolaEnter' })
|
||||
oil.open_float()
|
||||
test_util.wait_for_autocmd({ 'User', pattern = 'OilEnter' })
|
||||
assert.equals('foo', vim.fn.expand('#'))
|
||||
test_util.feedkeys({ '/LICENSE<CR>' }, 10)
|
||||
canola.select()
|
||||
oil.select()
|
||||
test_util.wait_for_autocmd('BufEnter')
|
||||
assert.equals('LICENSE', vim.fn.expand('%:.'))
|
||||
assert.equals('foo', vim.fn.expand('#'))
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
local canola = require('canola')
|
||||
local oil = require('oil')
|
||||
local test_util = require('spec.test_util')
|
||||
|
||||
describe('close', function()
|
||||
|
|
@ -10,35 +10,35 @@ describe('close', function()
|
|||
end)
|
||||
|
||||
it('does not close buffer from visual mode', function()
|
||||
canola.open()
|
||||
test_util.wait_for_autocmd({ 'User', pattern = 'CanolaEnter' })
|
||||
assert.equals('canola', vim.bo.filetype)
|
||||
oil.open()
|
||||
test_util.wait_for_autocmd({ 'User', pattern = 'OilEnter' })
|
||||
assert.equals('oil', vim.bo.filetype)
|
||||
test_util.feedkeys({ 'V' }, 10)
|
||||
canola.close()
|
||||
assert.equals('canola', vim.bo.filetype)
|
||||
oil.close()
|
||||
assert.equals('oil', vim.bo.filetype)
|
||||
test_util.feedkeys({ '<Esc>' }, 10)
|
||||
end)
|
||||
|
||||
it('does not close buffer from operator-pending mode', function()
|
||||
canola.open()
|
||||
test_util.wait_for_autocmd({ 'User', pattern = 'CanolaEnter' })
|
||||
assert.equals('canola', vim.bo.filetype)
|
||||
oil.open()
|
||||
test_util.wait_for_autocmd({ 'User', pattern = 'OilEnter' })
|
||||
assert.equals('oil', vim.bo.filetype)
|
||||
vim.api.nvim_feedkeys('d', 'n', false)
|
||||
vim.wait(20)
|
||||
local mode = vim.api.nvim_get_mode().mode
|
||||
if mode:match('^no') then
|
||||
canola.close()
|
||||
assert.equals('canola', vim.bo.filetype)
|
||||
oil.close()
|
||||
assert.equals('oil', vim.bo.filetype)
|
||||
end
|
||||
vim.api.nvim_feedkeys(vim.api.nvim_replace_termcodes('<Esc>', true, true, true), 'n', false)
|
||||
vim.wait(20)
|
||||
end)
|
||||
|
||||
it('closes buffer from normal mode', function()
|
||||
canola.open()
|
||||
test_util.wait_for_autocmd({ 'User', pattern = 'CanolaEnter' })
|
||||
assert.equals('canola', vim.bo.filetype)
|
||||
canola.close()
|
||||
assert.not_equals('canola', vim.bo.filetype)
|
||||
oil.open()
|
||||
test_util.wait_for_autocmd({ 'User', pattern = 'OilEnter' })
|
||||
assert.equals('oil', vim.bo.filetype)
|
||||
oil.close()
|
||||
assert.not_equals('oil', vim.bo.filetype)
|
||||
end)
|
||||
end)
|
||||
|
|
|
|||
|
|
@ -1,26 +1,26 @@
|
|||
local config = require('canola.config')
|
||||
local config = require('oil.config')
|
||||
|
||||
describe('config', function()
|
||||
after_each(function()
|
||||
vim.g.canola = nil
|
||||
vim.g.oil = nil
|
||||
end)
|
||||
|
||||
it('falls back to vim.g.canola when setup() is called with no args', function()
|
||||
vim.g.canola = { delete_to_trash = true, cleanup_delay_ms = 5000 }
|
||||
it('falls back to vim.g.oil when setup() is called with no args', function()
|
||||
vim.g.oil = { delete_to_trash = true, cleanup_delay_ms = 5000 }
|
||||
config.setup()
|
||||
assert.is_true(config.delete_to_trash)
|
||||
assert.equals(5000, config.cleanup_delay_ms)
|
||||
end)
|
||||
|
||||
it('uses defaults when neither opts nor vim.g.canola is set', function()
|
||||
vim.g.canola = nil
|
||||
it('uses defaults when neither opts nor vim.g.oil is set', function()
|
||||
vim.g.oil = nil
|
||||
config.setup()
|
||||
assert.is_false(config.delete_to_trash)
|
||||
assert.equals(2000, config.cleanup_delay_ms)
|
||||
end)
|
||||
|
||||
it('prefers explicit opts over vim.g.canola', function()
|
||||
vim.g.canola = { delete_to_trash = true }
|
||||
it('prefers explicit opts over vim.g.oil', function()
|
||||
vim.g.oil = { delete_to_trash = true }
|
||||
config.setup({ delete_to_trash = false })
|
||||
assert.is_false(config.delete_to_trash)
|
||||
end)
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
local TmpDir = require('spec.tmpdir')
|
||||
local files = require('canola.adapters.files')
|
||||
local files = require('oil.adapters.files')
|
||||
local test_util = require('spec.test_util')
|
||||
|
||||
describe('files adapter', function()
|
||||
|
|
@ -26,7 +26,7 @@ describe('files adapter', function()
|
|||
|
||||
it('Creates files', function()
|
||||
local err = test_util.await(files.perform_action, 2, {
|
||||
url = 'canola://' .. vim.fn.fnamemodify(tmpdir.path, ':p') .. 'a.txt',
|
||||
url = 'oil://' .. vim.fn.fnamemodify(tmpdir.path, ':p') .. 'a.txt',
|
||||
entry_type = 'file',
|
||||
type = 'create',
|
||||
})
|
||||
|
|
@ -38,7 +38,7 @@ describe('files adapter', function()
|
|||
|
||||
it('Creates directories', function()
|
||||
local err = test_util.await(files.perform_action, 2, {
|
||||
url = 'canola://' .. vim.fn.fnamemodify(tmpdir.path, ':p') .. 'a',
|
||||
url = 'oil://' .. vim.fn.fnamemodify(tmpdir.path, ':p') .. 'a',
|
||||
entry_type = 'directory',
|
||||
type = 'create',
|
||||
})
|
||||
|
|
@ -50,7 +50,7 @@ describe('files adapter', function()
|
|||
|
||||
it('Deletes files', function()
|
||||
tmpdir:create({ 'a.txt' })
|
||||
local url = 'canola://' .. vim.fn.fnamemodify(tmpdir.path, ':p') .. 'a.txt'
|
||||
local url = 'oil://' .. vim.fn.fnamemodify(tmpdir.path, ':p') .. 'a.txt'
|
||||
local err = test_util.await(files.perform_action, 2, {
|
||||
url = url,
|
||||
entry_type = 'file',
|
||||
|
|
@ -62,7 +62,7 @@ describe('files adapter', function()
|
|||
|
||||
it('Deletes directories', function()
|
||||
tmpdir:create({ 'a/' })
|
||||
local url = 'canola://' .. vim.fn.fnamemodify(tmpdir.path, ':p') .. 'a'
|
||||
local url = 'oil://' .. vim.fn.fnamemodify(tmpdir.path, ':p') .. 'a'
|
||||
local err = test_util.await(files.perform_action, 2, {
|
||||
url = url,
|
||||
entry_type = 'directory',
|
||||
|
|
@ -74,8 +74,8 @@ describe('files adapter', function()
|
|||
|
||||
it('Moves files', function()
|
||||
tmpdir:create({ 'a.txt' })
|
||||
local src_url = 'canola://' .. vim.fn.fnamemodify(tmpdir.path, ':p') .. 'a.txt'
|
||||
local dest_url = 'canola://' .. vim.fn.fnamemodify(tmpdir.path, ':p') .. 'b.txt'
|
||||
local src_url = 'oil://' .. vim.fn.fnamemodify(tmpdir.path, ':p') .. 'a.txt'
|
||||
local dest_url = 'oil://' .. vim.fn.fnamemodify(tmpdir.path, ':p') .. 'b.txt'
|
||||
local err = test_util.await(files.perform_action, 2, {
|
||||
src_url = src_url,
|
||||
dest_url = dest_url,
|
||||
|
|
@ -90,8 +90,8 @@ describe('files adapter', function()
|
|||
|
||||
it('Moves directories', function()
|
||||
tmpdir:create({ 'a/a.txt' })
|
||||
local src_url = 'canola://' .. vim.fn.fnamemodify(tmpdir.path, ':p') .. 'a'
|
||||
local dest_url = 'canola://' .. vim.fn.fnamemodify(tmpdir.path, ':p') .. 'b'
|
||||
local src_url = 'oil://' .. vim.fn.fnamemodify(tmpdir.path, ':p') .. 'a'
|
||||
local dest_url = 'oil://' .. vim.fn.fnamemodify(tmpdir.path, ':p') .. 'b'
|
||||
local err = test_util.await(files.perform_action, 2, {
|
||||
src_url = src_url,
|
||||
dest_url = dest_url,
|
||||
|
|
@ -107,8 +107,8 @@ describe('files adapter', function()
|
|||
|
||||
it('Copies files', function()
|
||||
tmpdir:create({ 'a.txt' })
|
||||
local src_url = 'canola://' .. vim.fn.fnamemodify(tmpdir.path, ':p') .. 'a.txt'
|
||||
local dest_url = 'canola://' .. vim.fn.fnamemodify(tmpdir.path, ':p') .. 'b.txt'
|
||||
local src_url = 'oil://' .. vim.fn.fnamemodify(tmpdir.path, ':p') .. 'a.txt'
|
||||
local dest_url = 'oil://' .. vim.fn.fnamemodify(tmpdir.path, ':p') .. 'b.txt'
|
||||
local err = test_util.await(files.perform_action, 2, {
|
||||
src_url = src_url,
|
||||
dest_url = dest_url,
|
||||
|
|
@ -124,8 +124,8 @@ describe('files adapter', function()
|
|||
|
||||
it('Recursively copies directories', function()
|
||||
tmpdir:create({ 'a/a.txt' })
|
||||
local src_url = 'canola://' .. vim.fn.fnamemodify(tmpdir.path, ':p') .. 'a'
|
||||
local dest_url = 'canola://' .. vim.fn.fnamemodify(tmpdir.path, ':p') .. 'b'
|
||||
local src_url = 'oil://' .. vim.fn.fnamemodify(tmpdir.path, ':p') .. 'a'
|
||||
local dest_url = 'oil://' .. vim.fn.fnamemodify(tmpdir.path, ':p') .. 'b'
|
||||
local err = test_util.await(files.perform_action, 2, {
|
||||
src_url = src_url,
|
||||
dest_url = dest_url,
|
||||
|
|
@ -141,22 +141,22 @@ describe('files adapter', function()
|
|||
})
|
||||
end)
|
||||
|
||||
it('Editing a new canola://path/ creates an canola buffer', function()
|
||||
local tmpdir_url = 'canola://' .. vim.fn.fnamemodify(tmpdir.path, ':p') .. '/'
|
||||
it('Editing a new oil://path/ creates an oil buffer', function()
|
||||
local tmpdir_url = 'oil://' .. vim.fn.fnamemodify(tmpdir.path, ':p') .. '/'
|
||||
vim.cmd.edit({ args = { tmpdir_url } })
|
||||
test_util.wait_canola_ready()
|
||||
local new_url = 'canola://' .. vim.fn.fnamemodify(tmpdir.path, ':p') .. 'newdir'
|
||||
test_util.wait_oil_ready()
|
||||
local new_url = 'oil://' .. vim.fn.fnamemodify(tmpdir.path, ':p') .. 'newdir'
|
||||
vim.cmd.edit({ args = { new_url } })
|
||||
test_util.wait_canola_ready()
|
||||
assert.equals('canola', vim.bo.filetype)
|
||||
test_util.wait_oil_ready()
|
||||
assert.equals('oil', vim.bo.filetype)
|
||||
assert.equals(new_url .. '/', vim.api.nvim_buf_get_name(0))
|
||||
end)
|
||||
|
||||
it('Editing a new canola://file.rb creates a normal buffer', function()
|
||||
local tmpdir_url = 'canola://' .. vim.fn.fnamemodify(tmpdir.path, ':p') .. '/'
|
||||
it('Editing a new oil://file.rb creates a normal buffer', function()
|
||||
local tmpdir_url = 'oil://' .. vim.fn.fnamemodify(tmpdir.path, ':p') .. '/'
|
||||
vim.cmd.edit({ args = { tmpdir_url } })
|
||||
test_util.wait_for_autocmd('BufReadPost')
|
||||
local new_url = 'canola://' .. vim.fn.fnamemodify(tmpdir.path, ':p') .. 'file.rb'
|
||||
local new_url = 'oil://' .. vim.fn.fnamemodify(tmpdir.path, ':p') .. 'file.rb'
|
||||
vim.cmd.edit({ args = { new_url } })
|
||||
test_util.wait_for_autocmd('BufReadPost')
|
||||
assert.equals('ruby', vim.bo.filetype)
|
||||
|
|
@ -165,9 +165,9 @@ describe('files adapter', function()
|
|||
end)
|
||||
|
||||
describe('cleanup_buffers_on_delete', function()
|
||||
local cache = require('canola.cache')
|
||||
local config = require('canola.config')
|
||||
local mutator = require('canola.mutator')
|
||||
local cache = require('oil.cache')
|
||||
local config = require('oil.config')
|
||||
local mutator = require('oil.mutator')
|
||||
|
||||
before_each(function()
|
||||
config.cleanup_buffers_on_delete = true
|
||||
|
|
@ -179,12 +179,12 @@ describe('files adapter', function()
|
|||
|
||||
it('wipes the buffer for a deleted file', function()
|
||||
tmpdir:create({ 'a.txt' })
|
||||
local dirurl = 'canola://' .. vim.fn.fnamemodify(tmpdir.path, ':p')
|
||||
local dirurl = 'oil://' .. vim.fn.fnamemodify(tmpdir.path, ':p')
|
||||
local filepath = vim.fn.fnamemodify(tmpdir.path, ':p') .. 'a.txt'
|
||||
cache.create_and_store_entry(dirurl, 'a.txt', 'file')
|
||||
vim.cmd.edit({ args = { filepath } })
|
||||
local bufnr = vim.api.nvim_get_current_buf()
|
||||
local url = 'canola://' .. filepath
|
||||
local url = 'oil://' .. filepath
|
||||
test_util.await(mutator.process_actions, 2, {
|
||||
{ type = 'delete', url = url, entry_type = 'file' },
|
||||
})
|
||||
|
|
@ -194,12 +194,12 @@ describe('files adapter', function()
|
|||
it('does not wipe the buffer when disabled', function()
|
||||
config.cleanup_buffers_on_delete = false
|
||||
tmpdir:create({ 'b.txt' })
|
||||
local dirurl = 'canola://' .. vim.fn.fnamemodify(tmpdir.path, ':p')
|
||||
local dirurl = 'oil://' .. vim.fn.fnamemodify(tmpdir.path, ':p')
|
||||
local filepath = vim.fn.fnamemodify(tmpdir.path, ':p') .. 'b.txt'
|
||||
cache.create_and_store_entry(dirurl, 'b.txt', 'file')
|
||||
vim.cmd.edit({ args = { filepath } })
|
||||
local bufnr = vim.api.nvim_get_current_buf()
|
||||
local url = 'canola://' .. filepath
|
||||
local url = 'oil://' .. filepath
|
||||
test_util.await(mutator.process_actions, 2, {
|
||||
{ type = 'delete', url = url, entry_type = 'file' },
|
||||
})
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
-- Manual test for minimizing/restoring progress window
|
||||
local Progress = require('canola.mutator.progress')
|
||||
local Progress = require('oil.mutator.progress')
|
||||
|
||||
local progress = Progress.new()
|
||||
|
||||
|
|
@ -13,7 +13,7 @@ for i = 1, 10, 1 do
|
|||
vim.defer_fn(function()
|
||||
progress:set_action({
|
||||
type = 'create',
|
||||
url = string.format('canola:///tmp/test_%d.txt', i),
|
||||
url = string.format('oil:///tmp/test_%d.txt', i),
|
||||
entry_type = 'file',
|
||||
}, i, 10)
|
||||
end, (i - 1) * 1000)
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
local fs = require('canola.fs')
|
||||
local fs = require('oil.fs')
|
||||
local test_util = require('spec.test_util')
|
||||
local util = require('canola.util')
|
||||
local util = require('oil.util')
|
||||
|
||||
describe('update_moved_buffers', function()
|
||||
after_each(function()
|
||||
|
|
@ -8,51 +8,51 @@ describe('update_moved_buffers', function()
|
|||
end)
|
||||
|
||||
it('Renames moved buffers', function()
|
||||
vim.cmd.edit({ args = { 'canola-test:///foo/bar.txt' } })
|
||||
util.update_moved_buffers('file', 'canola-test:///foo/bar.txt', 'canola-test:///foo/baz.txt')
|
||||
assert.equals('canola-test:///foo/baz.txt', vim.api.nvim_buf_get_name(0))
|
||||
vim.cmd.edit({ args = { 'oil-test:///foo/bar.txt' } })
|
||||
util.update_moved_buffers('file', 'oil-test:///foo/bar.txt', 'oil-test:///foo/baz.txt')
|
||||
assert.equals('oil-test:///foo/baz.txt', vim.api.nvim_buf_get_name(0))
|
||||
end)
|
||||
|
||||
it('Renames moved buffers when they are normal files', function()
|
||||
local tmpdir = fs.join(vim.loop.fs_realpath(vim.fn.stdpath('cache')), 'canola', 'test')
|
||||
local tmpdir = fs.join(vim.loop.fs_realpath(vim.fn.stdpath('cache')), 'oil', 'test')
|
||||
local testfile = fs.join(tmpdir, 'foo.txt')
|
||||
vim.cmd.edit({ args = { testfile } })
|
||||
util.update_moved_buffers(
|
||||
'file',
|
||||
'canola://' .. fs.os_to_posix_path(testfile),
|
||||
'canola://' .. fs.os_to_posix_path(fs.join(tmpdir, 'bar.txt'))
|
||||
'oil://' .. fs.os_to_posix_path(testfile),
|
||||
'oil://' .. fs.os_to_posix_path(fs.join(tmpdir, 'bar.txt'))
|
||||
)
|
||||
assert.equals(fs.join(tmpdir, 'bar.txt'), vim.api.nvim_buf_get_name(0))
|
||||
end)
|
||||
|
||||
it('Renames directories', function()
|
||||
vim.cmd.edit({ args = { 'canola-test:///foo/' } })
|
||||
util.update_moved_buffers('directory', 'canola-test:///foo/', 'canola-test:///bar/')
|
||||
assert.equals('canola-test:///bar/', vim.api.nvim_buf_get_name(0))
|
||||
vim.cmd.edit({ args = { 'oil-test:///foo/' } })
|
||||
util.update_moved_buffers('directory', 'oil-test:///foo/', 'oil-test:///bar/')
|
||||
assert.equals('oil-test:///bar/', vim.api.nvim_buf_get_name(0))
|
||||
end)
|
||||
|
||||
it('Renames subdirectories', function()
|
||||
vim.cmd.edit({ args = { 'canola-test:///foo/bar/' } })
|
||||
util.update_moved_buffers('directory', 'canola-test:///foo/', 'canola-test:///baz/')
|
||||
assert.equals('canola-test:///baz/bar/', vim.api.nvim_buf_get_name(0))
|
||||
vim.cmd.edit({ args = { 'oil-test:///foo/bar/' } })
|
||||
util.update_moved_buffers('directory', 'oil-test:///foo/', 'oil-test:///baz/')
|
||||
assert.equals('oil-test:///baz/bar/', vim.api.nvim_buf_get_name(0))
|
||||
end)
|
||||
|
||||
it('Renames subfiles', function()
|
||||
vim.cmd.edit({ args = { 'canola-test:///foo/bar.txt' } })
|
||||
util.update_moved_buffers('directory', 'canola-test:///foo/', 'canola-test:///baz/')
|
||||
assert.equals('canola-test:///baz/bar.txt', vim.api.nvim_buf_get_name(0))
|
||||
vim.cmd.edit({ args = { 'oil-test:///foo/bar.txt' } })
|
||||
util.update_moved_buffers('directory', 'oil-test:///foo/', 'oil-test:///baz/')
|
||||
assert.equals('oil-test:///baz/bar.txt', vim.api.nvim_buf_get_name(0))
|
||||
end)
|
||||
|
||||
it('Renames subfiles when they are normal files', function()
|
||||
local tmpdir = fs.join(vim.loop.fs_realpath(vim.fn.stdpath('cache')), 'canola', 'test')
|
||||
local tmpdir = fs.join(vim.loop.fs_realpath(vim.fn.stdpath('cache')), 'oil', 'test')
|
||||
local foo = fs.join(tmpdir, 'foo')
|
||||
local bar = fs.join(tmpdir, 'bar')
|
||||
local testfile = fs.join(foo, 'foo.txt')
|
||||
vim.cmd.edit({ args = { testfile } })
|
||||
util.update_moved_buffers(
|
||||
'directory',
|
||||
'canola://' .. fs.os_to_posix_path(foo),
|
||||
'canola://' .. fs.os_to_posix_path(bar)
|
||||
'oil://' .. fs.os_to_posix_path(foo),
|
||||
'oil://' .. fs.os_to_posix_path(bar)
|
||||
)
|
||||
assert.equals(fs.join(bar, 'foo.txt'), vim.api.nvim_buf_get_name(0))
|
||||
end)
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
local cache = require('canola.cache')
|
||||
local constants = require('canola.constants')
|
||||
local mutator = require('canola.mutator')
|
||||
local test_adapter = require('canola.adapters.test')
|
||||
local cache = require('oil.cache')
|
||||
local constants = require('oil.constants')
|
||||
local mutator = require('oil.mutator')
|
||||
local test_adapter = require('oil.adapters.test')
|
||||
local test_util = require('spec.test_util')
|
||||
|
||||
local FIELD_ID = constants.FIELD_ID
|
||||
|
|
@ -15,7 +15,7 @@ describe('mutator', function()
|
|||
|
||||
describe('build actions', function()
|
||||
it('empty diffs produce no actions', function()
|
||||
vim.cmd.edit({ args = { 'canola-test:///foo/' } })
|
||||
vim.cmd.edit({ args = { 'oil-test:///foo/' } })
|
||||
local bufnr = vim.api.nvim_get_current_buf()
|
||||
local actions = mutator.create_actions_from_diffs({
|
||||
[bufnr] = {},
|
||||
|
|
@ -24,7 +24,7 @@ describe('mutator', function()
|
|||
end)
|
||||
|
||||
it('constructs CREATE actions', function()
|
||||
vim.cmd.edit({ args = { 'canola-test:///foo/' } })
|
||||
vim.cmd.edit({ args = { 'oil-test:///foo/' } })
|
||||
local bufnr = vim.api.nvim_get_current_buf()
|
||||
local diffs = {
|
||||
{ type = 'new', name = 'a.txt', entry_type = 'file' },
|
||||
|
|
@ -36,14 +36,14 @@ describe('mutator', function()
|
|||
{
|
||||
type = 'create',
|
||||
entry_type = 'file',
|
||||
url = 'canola-test:///foo/a.txt',
|
||||
url = 'oil-test:///foo/a.txt',
|
||||
},
|
||||
}, actions)
|
||||
end)
|
||||
|
||||
it('constructs DELETE actions', function()
|
||||
local file = test_adapter.test_set('/foo/a.txt', 'file')
|
||||
vim.cmd.edit({ args = { 'canola-test:///foo/' } })
|
||||
vim.cmd.edit({ args = { 'oil-test:///foo/' } })
|
||||
local bufnr = vim.api.nvim_get_current_buf()
|
||||
local diffs = {
|
||||
{ type = 'delete', name = 'a.txt', id = file[FIELD_ID] },
|
||||
|
|
@ -55,14 +55,14 @@ describe('mutator', function()
|
|||
{
|
||||
type = 'delete',
|
||||
entry_type = 'file',
|
||||
url = 'canola-test:///foo/a.txt',
|
||||
url = 'oil-test:///foo/a.txt',
|
||||
},
|
||||
}, actions)
|
||||
end)
|
||||
|
||||
it('constructs COPY actions', function()
|
||||
local file = test_adapter.test_set('/foo/a.txt', 'file')
|
||||
vim.cmd.edit({ args = { 'canola-test:///foo/' } })
|
||||
vim.cmd.edit({ args = { 'oil-test:///foo/' } })
|
||||
local bufnr = vim.api.nvim_get_current_buf()
|
||||
local diffs = {
|
||||
{ type = 'new', name = 'b.txt', entry_type = 'file', id = file[FIELD_ID] },
|
||||
|
|
@ -74,15 +74,15 @@ describe('mutator', function()
|
|||
{
|
||||
type = 'copy',
|
||||
entry_type = 'file',
|
||||
src_url = 'canola-test:///foo/a.txt',
|
||||
dest_url = 'canola-test:///foo/b.txt',
|
||||
src_url = 'oil-test:///foo/a.txt',
|
||||
dest_url = 'oil-test:///foo/b.txt',
|
||||
},
|
||||
}, actions)
|
||||
end)
|
||||
|
||||
it('constructs MOVE actions', function()
|
||||
local file = test_adapter.test_set('/foo/a.txt', 'file')
|
||||
vim.cmd.edit({ args = { 'canola-test:///foo/' } })
|
||||
vim.cmd.edit({ args = { 'oil-test:///foo/' } })
|
||||
local bufnr = vim.api.nvim_get_current_buf()
|
||||
local diffs = {
|
||||
{ type = 'delete', name = 'a.txt', id = file[FIELD_ID] },
|
||||
|
|
@ -95,15 +95,15 @@ describe('mutator', function()
|
|||
{
|
||||
type = 'move',
|
||||
entry_type = 'file',
|
||||
src_url = 'canola-test:///foo/a.txt',
|
||||
dest_url = 'canola-test:///foo/b.txt',
|
||||
src_url = 'oil-test:///foo/a.txt',
|
||||
dest_url = 'oil-test:///foo/b.txt',
|
||||
},
|
||||
}, actions)
|
||||
end)
|
||||
|
||||
it('correctly orders MOVE + CREATE', function()
|
||||
local file = test_adapter.test_set('/a.txt', 'file')
|
||||
vim.cmd.edit({ args = { 'canola-test:///' } })
|
||||
vim.cmd.edit({ args = { 'oil-test:///' } })
|
||||
local bufnr = vim.api.nvim_get_current_buf()
|
||||
local diffs = {
|
||||
{ type = 'delete', name = 'a.txt', id = file[FIELD_ID] },
|
||||
|
|
@ -117,13 +117,13 @@ describe('mutator', function()
|
|||
{
|
||||
type = 'move',
|
||||
entry_type = 'file',
|
||||
src_url = 'canola-test:///a.txt',
|
||||
dest_url = 'canola-test:///b.txt',
|
||||
src_url = 'oil-test:///a.txt',
|
||||
dest_url = 'oil-test:///b.txt',
|
||||
},
|
||||
{
|
||||
type = 'create',
|
||||
entry_type = 'file',
|
||||
url = 'canola-test:///a.txt',
|
||||
url = 'oil-test:///a.txt',
|
||||
},
|
||||
}, actions)
|
||||
end)
|
||||
|
|
@ -131,7 +131,7 @@ describe('mutator', function()
|
|||
it('resolves MOVE loops', function()
|
||||
local afile = test_adapter.test_set('/a.txt', 'file')
|
||||
local bfile = test_adapter.test_set('/b.txt', 'file')
|
||||
vim.cmd.edit({ args = { 'canola-test:///' } })
|
||||
vim.cmd.edit({ args = { 'oil-test:///' } })
|
||||
local bufnr = vim.api.nvim_get_current_buf()
|
||||
local diffs = {
|
||||
{ type = 'delete', name = 'a.txt', id = afile[FIELD_ID] },
|
||||
|
|
@ -143,25 +143,25 @@ describe('mutator', function()
|
|||
local actions = mutator.create_actions_from_diffs({
|
||||
[bufnr] = diffs,
|
||||
})
|
||||
local tmp_url = 'canola-test:///a.txt__canola_tmp_510852'
|
||||
local tmp_url = 'oil-test:///a.txt__oil_tmp_510852'
|
||||
assert.are.same({
|
||||
{
|
||||
type = 'move',
|
||||
entry_type = 'file',
|
||||
src_url = 'canola-test:///a.txt',
|
||||
src_url = 'oil-test:///a.txt',
|
||||
dest_url = tmp_url,
|
||||
},
|
||||
{
|
||||
type = 'move',
|
||||
entry_type = 'file',
|
||||
src_url = 'canola-test:///b.txt',
|
||||
dest_url = 'canola-test:///a.txt',
|
||||
src_url = 'oil-test:///b.txt',
|
||||
dest_url = 'oil-test:///a.txt',
|
||||
},
|
||||
{
|
||||
type = 'move',
|
||||
entry_type = 'file',
|
||||
src_url = tmp_url,
|
||||
dest_url = 'canola-test:///b.txt',
|
||||
dest_url = 'oil-test:///b.txt',
|
||||
},
|
||||
}, actions)
|
||||
end)
|
||||
|
|
@ -171,11 +171,11 @@ describe('mutator', function()
|
|||
it('Creates files inside dir before move', function()
|
||||
local move = {
|
||||
type = 'move',
|
||||
src_url = 'canola-test:///a',
|
||||
dest_url = 'canola-test:///b',
|
||||
src_url = 'oil-test:///a',
|
||||
dest_url = 'oil-test:///b',
|
||||
entry_type = 'directory',
|
||||
}
|
||||
local create = { type = 'create', url = 'canola-test:///a/hi.txt', entry_type = 'file' }
|
||||
local create = { type = 'create', url = 'oil-test:///a/hi.txt', entry_type = 'file' }
|
||||
local actions = { move, create }
|
||||
local ordered_actions = mutator.enforce_action_order(actions)
|
||||
assert.are.same({ create, move }, ordered_actions)
|
||||
|
|
@ -184,11 +184,11 @@ describe('mutator', function()
|
|||
it('Moves file out of parent before deleting parent', function()
|
||||
local move = {
|
||||
type = 'move',
|
||||
src_url = 'canola-test:///a/b.txt',
|
||||
dest_url = 'canola-test:///b.txt',
|
||||
src_url = 'oil-test:///a/b.txt',
|
||||
dest_url = 'oil-test:///b.txt',
|
||||
entry_type = 'file',
|
||||
}
|
||||
local delete = { type = 'delete', url = 'canola-test:///a', entry_type = 'directory' }
|
||||
local delete = { type = 'delete', url = 'oil-test:///a', entry_type = 'directory' }
|
||||
local actions = { delete, move }
|
||||
local ordered_actions = mutator.enforce_action_order(actions)
|
||||
assert.are.same({ move, delete }, ordered_actions)
|
||||
|
|
@ -197,14 +197,14 @@ describe('mutator', function()
|
|||
it('Handles parent child move ordering', function()
|
||||
local move1 = {
|
||||
type = 'move',
|
||||
src_url = 'canola-test:///a/b',
|
||||
dest_url = 'canola-test:///b',
|
||||
src_url = 'oil-test:///a/b',
|
||||
dest_url = 'oil-test:///b',
|
||||
entry_type = 'directory',
|
||||
}
|
||||
local move2 = {
|
||||
type = 'move',
|
||||
src_url = 'canola-test:///a',
|
||||
dest_url = 'canola-test:///b/a',
|
||||
src_url = 'oil-test:///a',
|
||||
dest_url = 'oil-test:///b/a',
|
||||
entry_type = 'directory',
|
||||
}
|
||||
local actions = { move2, move1 }
|
||||
|
|
@ -215,13 +215,13 @@ describe('mutator', function()
|
|||
it('Handles a delete inside a moved folder', function()
|
||||
local del = {
|
||||
type = 'delete',
|
||||
url = 'canola-test:///a/b.txt',
|
||||
url = 'oil-test:///a/b.txt',
|
||||
entry_type = 'file',
|
||||
}
|
||||
local move = {
|
||||
type = 'move',
|
||||
src_url = 'canola-test:///a',
|
||||
dest_url = 'canola-test:///b',
|
||||
src_url = 'oil-test:///a',
|
||||
dest_url = 'oil-test:///b',
|
||||
entry_type = 'directory',
|
||||
}
|
||||
local actions = { move, del }
|
||||
|
|
@ -232,8 +232,8 @@ describe('mutator', function()
|
|||
it('Detects move directory loops', function()
|
||||
local move = {
|
||||
type = 'move',
|
||||
src_url = 'canola-test:///a',
|
||||
dest_url = 'canola-test:///a/b',
|
||||
src_url = 'oil-test:///a',
|
||||
dest_url = 'oil-test:///a/b',
|
||||
entry_type = 'directory',
|
||||
}
|
||||
assert.has_error(function()
|
||||
|
|
@ -244,8 +244,8 @@ describe('mutator', function()
|
|||
it('Detects copy directory loops', function()
|
||||
local move = {
|
||||
type = 'copy',
|
||||
src_url = 'canola-test:///a',
|
||||
dest_url = 'canola-test:///a/b',
|
||||
src_url = 'oil-test:///a',
|
||||
dest_url = 'oil-test:///a/b',
|
||||
entry_type = 'directory',
|
||||
}
|
||||
assert.has_error(function()
|
||||
|
|
@ -256,8 +256,8 @@ describe('mutator', function()
|
|||
it('Detects nested copy directory loops', function()
|
||||
local move = {
|
||||
type = 'copy',
|
||||
src_url = 'canola-test:///a',
|
||||
dest_url = 'canola-test:///a/b/a',
|
||||
src_url = 'oil-test:///a',
|
||||
dest_url = 'oil-test:///a/b/a',
|
||||
entry_type = 'directory',
|
||||
}
|
||||
assert.has_error(function()
|
||||
|
|
@ -267,10 +267,10 @@ describe('mutator', function()
|
|||
|
||||
describe('change', function()
|
||||
it('applies CHANGE after CREATE', function()
|
||||
local create = { type = 'create', url = 'canola-test:///a/hi.txt', entry_type = 'file' }
|
||||
local create = { type = 'create', url = 'oil-test:///a/hi.txt', entry_type = 'file' }
|
||||
local change = {
|
||||
type = 'change',
|
||||
url = 'canola-test:///a/hi.txt',
|
||||
url = 'oil-test:///a/hi.txt',
|
||||
entry_type = 'file',
|
||||
column = 'TEST',
|
||||
value = 'TEST',
|
||||
|
|
@ -283,13 +283,13 @@ describe('mutator', function()
|
|||
it('applies CHANGE after COPY src', function()
|
||||
local copy = {
|
||||
type = 'copy',
|
||||
src_url = 'canola-test:///a/hi.txt',
|
||||
dest_url = 'canola-test:///b.txt',
|
||||
src_url = 'oil-test:///a/hi.txt',
|
||||
dest_url = 'oil-test:///b.txt',
|
||||
entry_type = 'file',
|
||||
}
|
||||
local change = {
|
||||
type = 'change',
|
||||
url = 'canola-test:///a/hi.txt',
|
||||
url = 'oil-test:///a/hi.txt',
|
||||
entry_type = 'file',
|
||||
column = 'TEST',
|
||||
value = 'TEST',
|
||||
|
|
@ -302,13 +302,13 @@ describe('mutator', function()
|
|||
it('applies CHANGE after COPY dest', function()
|
||||
local copy = {
|
||||
type = 'copy',
|
||||
src_url = 'canola-test:///b.txt',
|
||||
dest_url = 'canola-test:///a/hi.txt',
|
||||
src_url = 'oil-test:///b.txt',
|
||||
dest_url = 'oil-test:///a/hi.txt',
|
||||
entry_type = 'file',
|
||||
}
|
||||
local change = {
|
||||
type = 'change',
|
||||
url = 'canola-test:///a/hi.txt',
|
||||
url = 'oil-test:///a/hi.txt',
|
||||
entry_type = 'file',
|
||||
column = 'TEST',
|
||||
value = 'TEST',
|
||||
|
|
@ -321,13 +321,13 @@ describe('mutator', function()
|
|||
it('applies CHANGE after MOVE dest', function()
|
||||
local move = {
|
||||
type = 'move',
|
||||
src_url = 'canola-test:///b.txt',
|
||||
dest_url = 'canola-test:///a/hi.txt',
|
||||
src_url = 'oil-test:///b.txt',
|
||||
dest_url = 'oil-test:///a/hi.txt',
|
||||
entry_type = 'file',
|
||||
}
|
||||
local change = {
|
||||
type = 'change',
|
||||
url = 'canola-test:///a/hi.txt',
|
||||
url = 'oil-test:///a/hi.txt',
|
||||
entry_type = 'file',
|
||||
column = 'TEST',
|
||||
value = 'TEST',
|
||||
|
|
@ -342,10 +342,10 @@ describe('mutator', function()
|
|||
describe('perform actions', function()
|
||||
it('creates new entries', function()
|
||||
local actions = {
|
||||
{ type = 'create', url = 'canola-test:///a.txt', entry_type = 'file' },
|
||||
{ type = 'create', url = 'oil-test:///a.txt', entry_type = 'file' },
|
||||
}
|
||||
test_util.await(mutator.process_actions, 2, actions)
|
||||
local files = cache.list_url('canola-test:///')
|
||||
local files = cache.list_url('oil-test:///')
|
||||
assert.are.same({
|
||||
['a.txt'] = {
|
||||
[FIELD_ID] = 1,
|
||||
|
|
@ -358,10 +358,10 @@ describe('mutator', function()
|
|||
it('deletes entries', function()
|
||||
local file = test_adapter.test_set('/a.txt', 'file')
|
||||
local actions = {
|
||||
{ type = 'delete', url = 'canola-test:///a.txt', entry_type = 'file' },
|
||||
{ type = 'delete', url = 'oil-test:///a.txt', entry_type = 'file' },
|
||||
}
|
||||
test_util.await(mutator.process_actions, 2, actions)
|
||||
local files = cache.list_url('canola-test:///')
|
||||
local files = cache.list_url('oil-test:///')
|
||||
assert.are.same({}, files)
|
||||
assert.is_nil(cache.get_entry_by_id(file[FIELD_ID]))
|
||||
assert.has_error(function()
|
||||
|
|
@ -374,13 +374,13 @@ describe('mutator', function()
|
|||
local actions = {
|
||||
{
|
||||
type = 'move',
|
||||
src_url = 'canola-test:///a.txt',
|
||||
dest_url = 'canola-test:///b.txt',
|
||||
src_url = 'oil-test:///a.txt',
|
||||
dest_url = 'oil-test:///b.txt',
|
||||
entry_type = 'file',
|
||||
},
|
||||
}
|
||||
test_util.await(mutator.process_actions, 2, actions)
|
||||
local files = cache.list_url('canola-test:///')
|
||||
local files = cache.list_url('oil-test:///')
|
||||
local new_entry = {
|
||||
[FIELD_ID] = file[FIELD_ID],
|
||||
[FIELD_TYPE] = 'file',
|
||||
|
|
@ -390,7 +390,7 @@ describe('mutator', function()
|
|||
['b.txt'] = new_entry,
|
||||
}, files)
|
||||
assert.are.same(new_entry, cache.get_entry_by_id(file[FIELD_ID]))
|
||||
assert.equals('canola-test:///', cache.get_parent_url(file[FIELD_ID]))
|
||||
assert.equals('oil-test:///', cache.get_parent_url(file[FIELD_ID]))
|
||||
end)
|
||||
|
||||
it('copies entries', function()
|
||||
|
|
@ -398,13 +398,13 @@ describe('mutator', function()
|
|||
local actions = {
|
||||
{
|
||||
type = 'copy',
|
||||
src_url = 'canola-test:///a.txt',
|
||||
dest_url = 'canola-test:///b.txt',
|
||||
src_url = 'oil-test:///a.txt',
|
||||
dest_url = 'oil-test:///b.txt',
|
||||
entry_type = 'file',
|
||||
},
|
||||
}
|
||||
test_util.await(mutator.process_actions, 2, actions)
|
||||
local files = cache.list_url('canola-test:///')
|
||||
local files = cache.list_url('oil-test:///')
|
||||
local new_entry = {
|
||||
[FIELD_ID] = file[FIELD_ID] + 1,
|
||||
[FIELD_TYPE] = 'file',
|
||||
|
|
|
|||
|
|
@ -1,9 +1,9 @@
|
|||
local constants = require('canola.constants')
|
||||
local parser = require('canola.mutator.parser')
|
||||
local test_adapter = require('canola.adapters.test')
|
||||
local constants = require('oil.constants')
|
||||
local parser = require('oil.mutator.parser')
|
||||
local test_adapter = require('oil.adapters.test')
|
||||
local test_util = require('spec.test_util')
|
||||
local util = require('canola.util')
|
||||
local view = require('canola.view')
|
||||
local util = require('oil.util')
|
||||
local view = require('oil.view')
|
||||
|
||||
local FIELD_ID = constants.FIELD_ID
|
||||
local FIELD_META = constants.FIELD_META
|
||||
|
|
@ -19,7 +19,7 @@ describe('parser', function()
|
|||
end)
|
||||
|
||||
it('detects new files', function()
|
||||
vim.cmd.edit({ args = { 'canola-test:///foo/' } })
|
||||
vim.cmd.edit({ args = { 'oil-test:///foo/' } })
|
||||
local bufnr = vim.api.nvim_get_current_buf()
|
||||
set_lines(bufnr, {
|
||||
'a.txt',
|
||||
|
|
@ -29,7 +29,7 @@ describe('parser', function()
|
|||
end)
|
||||
|
||||
it('detects new directories', function()
|
||||
vim.cmd.edit({ args = { 'canola-test:///foo/' } })
|
||||
vim.cmd.edit({ args = { 'oil-test:///foo/' } })
|
||||
local bufnr = vim.api.nvim_get_current_buf()
|
||||
set_lines(bufnr, {
|
||||
'foo/',
|
||||
|
|
@ -39,7 +39,7 @@ describe('parser', function()
|
|||
end)
|
||||
|
||||
it('detects new links', function()
|
||||
vim.cmd.edit({ args = { 'canola-test:///foo/' } })
|
||||
vim.cmd.edit({ args = { 'oil-test:///foo/' } })
|
||||
local bufnr = vim.api.nvim_get_current_buf()
|
||||
set_lines(bufnr, {
|
||||
'a.txt -> b.txt',
|
||||
|
|
@ -53,7 +53,7 @@ describe('parser', function()
|
|||
|
||||
it('detects deleted files', function()
|
||||
local file = test_adapter.test_set('/foo/a.txt', 'file')
|
||||
vim.cmd.edit({ args = { 'canola-test:///foo/' } })
|
||||
vim.cmd.edit({ args = { 'oil-test:///foo/' } })
|
||||
local bufnr = vim.api.nvim_get_current_buf()
|
||||
set_lines(bufnr, {})
|
||||
local diffs = parser.parse(bufnr)
|
||||
|
|
@ -64,7 +64,7 @@ describe('parser', function()
|
|||
|
||||
it('detects deleted directories', function()
|
||||
local dir = test_adapter.test_set('/foo/bar', 'directory')
|
||||
vim.cmd.edit({ args = { 'canola-test:///foo/' } })
|
||||
vim.cmd.edit({ args = { 'oil-test:///foo/' } })
|
||||
local bufnr = vim.api.nvim_get_current_buf()
|
||||
set_lines(bufnr, {})
|
||||
local diffs = parser.parse(bufnr)
|
||||
|
|
@ -76,7 +76,7 @@ describe('parser', function()
|
|||
it('detects deleted links', function()
|
||||
local file = test_adapter.test_set('/foo/a.txt', 'link')
|
||||
file[FIELD_META] = { link = 'b.txt' }
|
||||
vim.cmd.edit({ args = { 'canola-test:///foo/' } })
|
||||
vim.cmd.edit({ args = { 'oil-test:///foo/' } })
|
||||
local bufnr = vim.api.nvim_get_current_buf()
|
||||
set_lines(bufnr, {})
|
||||
local diffs = parser.parse(bufnr)
|
||||
|
|
@ -87,7 +87,7 @@ describe('parser', function()
|
|||
|
||||
it('ignores empty lines', function()
|
||||
local file = test_adapter.test_set('/foo/a.txt', 'file')
|
||||
vim.cmd.edit({ args = { 'canola-test:///foo/' } })
|
||||
vim.cmd.edit({ args = { 'oil-test:///foo/' } })
|
||||
local bufnr = vim.api.nvim_get_current_buf()
|
||||
local cols = view.format_entry_cols(file, {}, {}, test_adapter, false)
|
||||
local lines = util.render_table({ cols }, {})
|
||||
|
|
@ -99,7 +99,7 @@ describe('parser', function()
|
|||
end)
|
||||
|
||||
it('errors on missing filename', function()
|
||||
vim.cmd.edit({ args = { 'canola-test:///foo/' } })
|
||||
vim.cmd.edit({ args = { 'oil-test:///foo/' } })
|
||||
local bufnr = vim.api.nvim_get_current_buf()
|
||||
set_lines(bufnr, {
|
||||
'/008',
|
||||
|
|
@ -116,7 +116,7 @@ describe('parser', function()
|
|||
end)
|
||||
|
||||
it('errors on empty dirname', function()
|
||||
vim.cmd.edit({ args = { 'canola-test:///foo/' } })
|
||||
vim.cmd.edit({ args = { 'oil-test:///foo/' } })
|
||||
local bufnr = vim.api.nvim_get_current_buf()
|
||||
set_lines(bufnr, {
|
||||
'/008 /',
|
||||
|
|
@ -133,7 +133,7 @@ describe('parser', function()
|
|||
end)
|
||||
|
||||
it('errors on duplicate names', function()
|
||||
vim.cmd.edit({ args = { 'canola-test:///foo/' } })
|
||||
vim.cmd.edit({ args = { 'oil-test:///foo/' } })
|
||||
local bufnr = vim.api.nvim_get_current_buf()
|
||||
set_lines(bufnr, {
|
||||
'foo',
|
||||
|
|
@ -152,7 +152,7 @@ describe('parser', function()
|
|||
|
||||
it('errors on duplicate names for existing files', function()
|
||||
local file = test_adapter.test_set('/foo/a.txt', 'file')
|
||||
vim.cmd.edit({ args = { 'canola-test:///foo/' } })
|
||||
vim.cmd.edit({ args = { 'oil-test:///foo/' } })
|
||||
local bufnr = vim.api.nvim_get_current_buf()
|
||||
set_lines(bufnr, {
|
||||
'a.txt',
|
||||
|
|
@ -170,7 +170,7 @@ describe('parser', function()
|
|||
end)
|
||||
|
||||
it('ignores new dirs with empty name', function()
|
||||
vim.cmd.edit({ args = { 'canola-test:///foo/' } })
|
||||
vim.cmd.edit({ args = { 'oil-test:///foo/' } })
|
||||
local bufnr = vim.api.nvim_get_current_buf()
|
||||
set_lines(bufnr, {
|
||||
'/',
|
||||
|
|
@ -181,7 +181,7 @@ describe('parser', function()
|
|||
|
||||
it('parses a rename as a delete + new', function()
|
||||
local file = test_adapter.test_set('/foo/a.txt', 'file')
|
||||
vim.cmd.edit({ args = { 'canola-test:///foo/' } })
|
||||
vim.cmd.edit({ args = { 'oil-test:///foo/' } })
|
||||
local bufnr = vim.api.nvim_get_current_buf()
|
||||
set_lines(bufnr, {
|
||||
string.format('/%d b.txt', file[FIELD_ID]),
|
||||
|
|
@ -195,7 +195,7 @@ describe('parser', function()
|
|||
|
||||
it('detects a new trailing slash as a delete + create', function()
|
||||
local file = test_adapter.test_set('/foo', 'file')
|
||||
vim.cmd.edit({ args = { 'canola-test:///' } })
|
||||
vim.cmd.edit({ args = { 'oil-test:///' } })
|
||||
local bufnr = vim.api.nvim_get_current_buf()
|
||||
set_lines(bufnr, {
|
||||
string.format('/%d foo/', file[FIELD_ID]),
|
||||
|
|
@ -210,7 +210,7 @@ describe('parser', function()
|
|||
it('detects renamed files that conflict', function()
|
||||
local afile = test_adapter.test_set('/foo/a.txt', 'file')
|
||||
local bfile = test_adapter.test_set('/foo/b.txt', 'file')
|
||||
vim.cmd.edit({ args = { 'canola-test:///foo/' } })
|
||||
vim.cmd.edit({ args = { 'oil-test:///foo/' } })
|
||||
local bufnr = vim.api.nvim_get_current_buf()
|
||||
set_lines(bufnr, {
|
||||
string.format('/%d a.txt', bfile[FIELD_ID]),
|
||||
|
|
@ -238,7 +238,7 @@ describe('parser', function()
|
|||
it('views link targets with trailing slashes as the same', function()
|
||||
local file = test_adapter.test_set('/foo/mydir', 'link')
|
||||
file[FIELD_META] = { link = 'dir/' }
|
||||
vim.cmd.edit({ args = { 'canola-test:///foo/' } })
|
||||
vim.cmd.edit({ args = { 'oil-test:///foo/' } })
|
||||
local bufnr = vim.api.nvim_get_current_buf()
|
||||
set_lines(bufnr, {
|
||||
string.format('/%d mydir/ -> dir/', file[FIELD_ID]),
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
local pathutil = require('canola.pathutil')
|
||||
local pathutil = require('oil.pathutil')
|
||||
describe('pathutil', function()
|
||||
it('calculates parent path', function()
|
||||
local cases = {
|
||||
|
|
|
|||
|
|
@ -1,9 +1,9 @@
|
|||
local TmpDir = require('spec.tmpdir')
|
||||
local canola = require('canola')
|
||||
local oil = require('oil')
|
||||
local test_util = require('spec.test_util')
|
||||
local util = require('canola.util')
|
||||
local util = require('oil.util')
|
||||
|
||||
describe('canola preview', function()
|
||||
describe('oil preview', function()
|
||||
local tmpdir
|
||||
before_each(function()
|
||||
tmpdir = TmpDir.new()
|
||||
|
|
@ -17,8 +17,8 @@ describe('canola preview', function()
|
|||
|
||||
it('opens preview window', function()
|
||||
tmpdir:create({ 'a.txt' })
|
||||
test_util.canola_open(tmpdir.path)
|
||||
test_util.await(canola.open_preview, 2)
|
||||
test_util.oil_open(tmpdir.path)
|
||||
test_util.await(oil.open_preview, 2)
|
||||
local preview_win = util.get_preview_win()
|
||||
assert.not_nil(preview_win)
|
||||
assert(preview_win)
|
||||
|
|
@ -29,7 +29,7 @@ describe('canola preview', function()
|
|||
|
||||
it('opens preview window when open(preview={})', function()
|
||||
tmpdir:create({ 'a.txt' })
|
||||
test_util.canola_open(tmpdir.path, { preview = {} })
|
||||
test_util.oil_open(tmpdir.path, { preview = {} })
|
||||
local preview_win = util.get_preview_win()
|
||||
assert.not_nil(preview_win)
|
||||
assert(preview_win)
|
||||
|
|
|
|||
|
|
@ -1,8 +1,8 @@
|
|||
local TmpDir = require('spec.tmpdir')
|
||||
local actions = require('canola.actions')
|
||||
local canola = require('canola')
|
||||
local actions = require('oil.actions')
|
||||
local oil = require('oil')
|
||||
local test_util = require('spec.test_util')
|
||||
local view = require('canola.view')
|
||||
local view = require('oil.view')
|
||||
|
||||
describe('regression tests', function()
|
||||
local tmpdir
|
||||
|
|
@ -21,29 +21,29 @@ describe('regression tests', function()
|
|||
vim.cmd.edit({ args = { 'README.md' } })
|
||||
vim.cmd.vsplit()
|
||||
vim.cmd.edit({ args = { '%:p:h' } })
|
||||
assert.equals('canola', vim.bo.filetype)
|
||||
assert.equals('oil', vim.bo.filetype)
|
||||
vim.cmd.wincmd({ args = { 'p' } })
|
||||
assert.equals('markdown', vim.bo.filetype)
|
||||
vim.cmd.edit({ args = { '%:p:h' } })
|
||||
test_util.wait_for_autocmd({ 'User', pattern = 'CanolaEnter' })
|
||||
assert.equals('canola', vim.bo.filetype)
|
||||
test_util.wait_for_autocmd({ 'User', pattern = 'OilEnter' })
|
||||
assert.equals('oil', vim.bo.filetype)
|
||||
end)
|
||||
|
||||
it('places the cursor on correct entry when opening on file', function()
|
||||
vim.cmd.edit({ args = { '.' } })
|
||||
test_util.wait_for_autocmd({ 'User', pattern = 'CanolaEnter' })
|
||||
local entry = canola.get_cursor_entry()
|
||||
test_util.wait_for_autocmd({ 'User', pattern = 'OilEnter' })
|
||||
local entry = oil.get_cursor_entry()
|
||||
assert.not_nil(entry)
|
||||
assert.not_equals('README.md', entry and entry.name)
|
||||
vim.cmd.edit({ args = { 'README.md' } })
|
||||
view.delete_hidden_buffers()
|
||||
canola.open()
|
||||
test_util.wait_for_autocmd({ 'User', pattern = 'CanolaEnter' })
|
||||
entry = canola.get_cursor_entry()
|
||||
oil.open()
|
||||
test_util.wait_for_autocmd({ 'User', pattern = 'OilEnter' })
|
||||
entry = oil.get_cursor_entry()
|
||||
assert.equals('README.md', entry and entry.name)
|
||||
end)
|
||||
|
||||
it("doesn't close floating windows canola didn't open itself", function()
|
||||
it("doesn't close floating windows oil didn't open itself", function()
|
||||
local winid = vim.api.nvim_open_win(vim.fn.bufadd('README.md'), true, {
|
||||
relative = 'editor',
|
||||
row = 1,
|
||||
|
|
@ -51,21 +51,21 @@ describe('regression tests', function()
|
|||
width = 100,
|
||||
height = 100,
|
||||
})
|
||||
canola.open()
|
||||
oil.open()
|
||||
vim.wait(10)
|
||||
canola.close()
|
||||
oil.close()
|
||||
vim.wait(10)
|
||||
assert.equals(winid, vim.api.nvim_get_current_win())
|
||||
end)
|
||||
|
||||
it("doesn't close splits on canola.close", function()
|
||||
it("doesn't close splits on oil.close", function()
|
||||
vim.cmd.edit({ args = { 'README.md' } })
|
||||
vim.cmd.vsplit()
|
||||
local winid = vim.api.nvim_get_current_win()
|
||||
local bufnr = vim.api.nvim_get_current_buf()
|
||||
canola.open()
|
||||
oil.open()
|
||||
vim.wait(10)
|
||||
canola.close()
|
||||
oil.close()
|
||||
vim.wait(10)
|
||||
assert.equals(2, #vim.api.nvim_tabpage_list_wins(0))
|
||||
assert.equals(winid, vim.api.nvim_get_current_win())
|
||||
|
|
@ -73,24 +73,24 @@ describe('regression tests', function()
|
|||
end)
|
||||
|
||||
it('Returns to empty buffer on close', function()
|
||||
canola.open()
|
||||
test_util.wait_for_autocmd({ 'User', pattern = 'CanolaEnter' })
|
||||
canola.close()
|
||||
assert.not_equals('canola', vim.bo.filetype)
|
||||
oil.open()
|
||||
test_util.wait_for_autocmd({ 'User', pattern = 'OilEnter' })
|
||||
oil.close()
|
||||
assert.not_equals('oil', vim.bo.filetype)
|
||||
assert.equals('', vim.api.nvim_buf_get_name(0))
|
||||
end)
|
||||
|
||||
it('All buffers set nomodified after save', function()
|
||||
tmpdir:create({ 'a.txt' })
|
||||
vim.cmd.edit({ args = { 'canola://' .. vim.fn.fnamemodify(tmpdir.path, ':p') } })
|
||||
vim.cmd.edit({ args = { 'oil://' .. vim.fn.fnamemodify(tmpdir.path, ':p') } })
|
||||
local first_dir = vim.api.nvim_get_current_buf()
|
||||
test_util.wait_for_autocmd({ 'User', pattern = 'CanolaEnter' })
|
||||
test_util.wait_for_autocmd({ 'User', pattern = 'OilEnter' })
|
||||
test_util.feedkeys({ 'dd', 'itest/<esc>', '<CR>' }, 10)
|
||||
vim.wait(1000, function()
|
||||
return vim.bo.modifiable
|
||||
end, 10)
|
||||
test_util.feedkeys({ 'p' }, 10)
|
||||
canola.save({ confirm = false })
|
||||
oil.save({ confirm = false })
|
||||
vim.wait(1000, function()
|
||||
return vim.bo.modifiable
|
||||
end, 10)
|
||||
|
|
@ -102,11 +102,11 @@ describe('regression tests', function()
|
|||
|
||||
it("refreshing buffer doesn't lose track of it", function()
|
||||
vim.cmd.edit({ args = { '.' } })
|
||||
test_util.wait_for_autocmd({ 'User', pattern = 'CanolaEnter' })
|
||||
test_util.wait_for_autocmd({ 'User', pattern = 'OilEnter' })
|
||||
local bufnr = vim.api.nvim_get_current_buf()
|
||||
vim.cmd.edit({ bang = true })
|
||||
test_util.wait_for_autocmd({ 'User', pattern = 'CanolaEnter' })
|
||||
assert.are.same({ bufnr }, require('canola.view').get_all_buffers())
|
||||
test_util.wait_for_autocmd({ 'User', pattern = 'OilEnter' })
|
||||
assert.are.same({ bufnr }, require('oil.view').get_all_buffers())
|
||||
end)
|
||||
|
||||
it('can copy a file multiple times', function()
|
||||
|
|
@ -126,8 +126,8 @@ describe('regression tests', function()
|
|||
|
||||
it('can open files from floating window', function()
|
||||
tmpdir:create({ 'a.txt' })
|
||||
canola.open_float(tmpdir.path)
|
||||
test_util.wait_for_autocmd({ 'User', pattern = 'CanolaEnter' })
|
||||
oil.open_float(tmpdir.path)
|
||||
test_util.wait_for_autocmd({ 'User', pattern = 'OilEnter' })
|
||||
actions.select.callback()
|
||||
vim.wait(1000, function()
|
||||
return vim.fn.expand('%:t') == 'a.txt'
|
||||
|
|
|
|||
|
|
@ -1,52 +1,52 @@
|
|||
local canola = require('canola')
|
||||
local oil = require('oil')
|
||||
local test_util = require('spec.test_util')
|
||||
|
||||
describe('canola select', function()
|
||||
describe('oil select', function()
|
||||
after_each(function()
|
||||
test_util.reset_editor()
|
||||
end)
|
||||
|
||||
it('opens file under cursor', function()
|
||||
test_util.canola_open()
|
||||
test_util.oil_open()
|
||||
vim.cmd.normal({ args = { 'G' } })
|
||||
test_util.await(canola.select, 2)
|
||||
test_util.await(oil.select, 2)
|
||||
assert.equals(1, #vim.api.nvim_tabpage_list_wins(0))
|
||||
assert.not_equals('canola', vim.bo.filetype)
|
||||
assert.not_equals('oil', vim.bo.filetype)
|
||||
end)
|
||||
|
||||
it('opens file in new tab', function()
|
||||
test_util.canola_open()
|
||||
test_util.oil_open()
|
||||
local tabpage = vim.api.nvim_get_current_tabpage()
|
||||
test_util.await(canola.select, 2, { tab = true })
|
||||
test_util.await(oil.select, 2, { tab = true })
|
||||
assert.equals(2, #vim.api.nvim_list_tabpages())
|
||||
assert.equals(1, #vim.api.nvim_tabpage_list_wins(0))
|
||||
assert.not_equals(tabpage, vim.api.nvim_get_current_tabpage())
|
||||
end)
|
||||
|
||||
it('opens file in new split', function()
|
||||
test_util.canola_open()
|
||||
test_util.oil_open()
|
||||
local winid = vim.api.nvim_get_current_win()
|
||||
test_util.await(canola.select, 2, { vertical = true })
|
||||
test_util.await(oil.select, 2, { vertical = true })
|
||||
assert.equals(1, #vim.api.nvim_list_tabpages())
|
||||
assert.equals(2, #vim.api.nvim_tabpage_list_wins(0))
|
||||
assert.not_equals(winid, vim.api.nvim_get_current_win())
|
||||
end)
|
||||
|
||||
it('opens multiple files in new tabs', function()
|
||||
test_util.canola_open()
|
||||
test_util.oil_open()
|
||||
vim.api.nvim_feedkeys('Vj', 'x', true)
|
||||
local tabpage = vim.api.nvim_get_current_tabpage()
|
||||
test_util.await(canola.select, 2, { tab = true })
|
||||
test_util.await(oil.select, 2, { tab = true })
|
||||
assert.equals(3, #vim.api.nvim_list_tabpages())
|
||||
assert.equals(1, #vim.api.nvim_tabpage_list_wins(0))
|
||||
assert.not_equals(tabpage, vim.api.nvim_get_current_tabpage())
|
||||
end)
|
||||
|
||||
it('opens multiple files in new splits', function()
|
||||
test_util.canola_open()
|
||||
test_util.oil_open()
|
||||
vim.api.nvim_feedkeys('Vj', 'x', true)
|
||||
local winid = vim.api.nvim_get_current_win()
|
||||
test_util.await(canola.select, 2, { vertical = true })
|
||||
test_util.await(oil.select, 2, { vertical = true })
|
||||
assert.equals(1, #vim.api.nvim_list_tabpages())
|
||||
assert.equals(3, #vim.api.nvim_tabpage_list_wins(0))
|
||||
assert.not_equals(winid, vim.api.nvim_get_current_win())
|
||||
|
|
@ -56,20 +56,20 @@ describe('canola select', function()
|
|||
it('same window', function()
|
||||
vim.cmd.edit({ args = { 'foo' } })
|
||||
local bufnr = vim.api.nvim_get_current_buf()
|
||||
test_util.canola_open()
|
||||
test_util.oil_open()
|
||||
vim.cmd.normal({ args = { 'G' } })
|
||||
test_util.await(canola.select, 2, { close = true })
|
||||
test_util.await(oil.select, 2, { close = true })
|
||||
assert.equals(1, #vim.api.nvim_tabpage_list_wins(0))
|
||||
assert.not_equals(bufnr, vim.api.nvim_get_current_buf())
|
||||
assert.not_equals('canola', vim.bo.filetype)
|
||||
assert.not_equals('oil', vim.bo.filetype)
|
||||
end)
|
||||
|
||||
it('split', function()
|
||||
vim.cmd.edit({ args = { 'foo' } })
|
||||
local bufnr = vim.api.nvim_get_current_buf()
|
||||
local winid = vim.api.nvim_get_current_win()
|
||||
test_util.canola_open()
|
||||
test_util.await(canola.select, 2, { vertical = true, close = true })
|
||||
test_util.oil_open()
|
||||
test_util.await(oil.select, 2, { vertical = true, close = true })
|
||||
assert.equals(2, #vim.api.nvim_tabpage_list_wins(0))
|
||||
assert.equals(bufnr, vim.api.nvim_win_get_buf(winid))
|
||||
end)
|
||||
|
|
@ -78,8 +78,8 @@ describe('canola select', function()
|
|||
vim.cmd.edit({ args = { 'foo' } })
|
||||
local bufnr = vim.api.nvim_get_current_buf()
|
||||
local tabpage = vim.api.nvim_get_current_tabpage()
|
||||
test_util.canola_open()
|
||||
test_util.await(canola.select, 2, { tab = true, close = true })
|
||||
test_util.oil_open()
|
||||
test_util.await(oil.select, 2, { tab = true, close = true })
|
||||
assert.equals(1, #vim.api.nvim_tabpage_list_wins(0))
|
||||
assert.equals(2, #vim.api.nvim_list_tabpages())
|
||||
vim.api.nvim_set_current_tabpage(tabpage)
|
||||
|
|
|
|||
|
|
@ -1,13 +1,13 @@
|
|||
local cache = require('canola.cache')
|
||||
local test_adapter = require('canola.adapters.test')
|
||||
local util = require('canola.util')
|
||||
local cache = require('oil.cache')
|
||||
local test_adapter = require('oil.adapters.test')
|
||||
local util = require('oil.util')
|
||||
local M = {}
|
||||
|
||||
M.reset_editor = function()
|
||||
require('canola').setup({
|
||||
require('oil').setup({
|
||||
columms = {},
|
||||
adapters = {
|
||||
['canola-test://'] = 'test',
|
||||
['oil-test://'] = 'test',
|
||||
},
|
||||
prompt_save_on_select_new_entry = false,
|
||||
})
|
||||
|
|
@ -53,8 +53,8 @@ M.await_throwiferr = function(fn, nargs, ...)
|
|||
return throwiferr(M.await(fn, nargs, ...))
|
||||
end
|
||||
|
||||
M.canola_open = function(...)
|
||||
M.await(require('canola').open, 3, ...)
|
||||
M.oil_open = function(...)
|
||||
M.await(require('oil').open, 3, ...)
|
||||
end
|
||||
|
||||
M.wait_for_autocmd = function(autocmd)
|
||||
|
|
@ -81,7 +81,7 @@ M.wait_for_autocmd = function(autocmd)
|
|||
end
|
||||
end
|
||||
|
||||
M.wait_canola_ready = function()
|
||||
M.wait_oil_ready = function()
|
||||
local ready = false
|
||||
util.run_after_load(
|
||||
0,
|
||||
|
|
@ -93,7 +93,7 @@ M.wait_canola_ready = function()
|
|||
return ready
|
||||
end, 10)
|
||||
if not ready then
|
||||
error('wait_canola_ready timed out')
|
||||
error('wait_oil_ready timed out')
|
||||
end
|
||||
end
|
||||
|
||||
|
|
@ -113,34 +113,34 @@ M.feedkeys = function(actions, timestep)
|
|||
end
|
||||
|
||||
M.actions = {
|
||||
---Open canola and wait for it to finish rendering
|
||||
---Open oil and wait for it to finish rendering
|
||||
---@param args string[]
|
||||
open = function(args)
|
||||
vim.schedule(function()
|
||||
vim.cmd.Canola({ args = args })
|
||||
if vim.b.canola_ready then
|
||||
vim.cmd.Oil({ args = args })
|
||||
if vim.b.oil_ready then
|
||||
vim.api.nvim_exec_autocmds('User', {
|
||||
pattern = 'CanolaEnter',
|
||||
pattern = 'OilEnter',
|
||||
modeline = false,
|
||||
data = { buf = vim.api.nvim_get_current_buf() },
|
||||
})
|
||||
end
|
||||
end)
|
||||
M.wait_for_autocmd({ 'User', pattern = 'CanolaEnter' })
|
||||
M.wait_for_autocmd({ 'User', pattern = 'OilEnter' })
|
||||
end,
|
||||
|
||||
---Save all changes and wait for operation to complete
|
||||
save = function()
|
||||
vim.schedule_wrap(require('canola').save)({ confirm = false })
|
||||
M.wait_for_autocmd({ 'User', pattern = 'CanolaMutationComplete' })
|
||||
vim.schedule_wrap(require('oil').save)({ confirm = false })
|
||||
M.wait_for_autocmd({ 'User', pattern = 'OilMutationComplete' })
|
||||
end,
|
||||
|
||||
---@param bufnr? integer
|
||||
reload = function(bufnr)
|
||||
M.await(require('canola.view').render_buffer_async, 3, bufnr or 0)
|
||||
M.await(require('oil.view').render_buffer_async, 3, bufnr or 0)
|
||||
end,
|
||||
|
||||
---Move cursor to a file or directory in an canola buffer
|
||||
---Move cursor to a file or directory in an oil buffer
|
||||
---@param filename string
|
||||
focus = function(filename)
|
||||
local lines = vim.api.nvim_buf_get_lines(0, 0, -1, true)
|
||||
|
|
@ -155,13 +155,13 @@ M.actions = {
|
|||
end,
|
||||
}
|
||||
|
||||
---Get the raw list of filenames from an unmodified canola buffer
|
||||
---Get the raw list of filenames from an unmodified oil buffer
|
||||
---@param bufnr? integer
|
||||
---@return string[]
|
||||
M.parse_entries = function(bufnr)
|
||||
bufnr = bufnr or 0
|
||||
if vim.bo[bufnr].modified then
|
||||
error("parse_entries doesn't work on a modified canola buffer")
|
||||
error("parse_entries doesn't work on a modified oil buffer")
|
||||
end
|
||||
local lines = vim.api.nvim_buf_get_lines(bufnr, 0, -1, true)
|
||||
return vim.tbl_map(function(line)
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
local fs = require('canola.fs')
|
||||
local fs = require('oil.fs')
|
||||
local test_util = require('spec.test_util')
|
||||
|
||||
---@param path string
|
||||
|
|
@ -25,7 +25,7 @@ end
|
|||
local TmpDir = {}
|
||||
|
||||
TmpDir.new = function()
|
||||
local path, err = vim.loop.fs_mkdtemp('canola_test_XXXXXXXXX')
|
||||
local path, err = vim.loop.fs_mkdtemp('oil_test_XXXXXXXXX')
|
||||
if not path then
|
||||
error(err)
|
||||
end
|
||||
|
|
|
|||
|
|
@ -6,10 +6,10 @@ describe('freedesktop', function()
|
|||
local tmphome
|
||||
local home = vim.env.XDG_DATA_HOME
|
||||
before_each(function()
|
||||
require('canola.config').delete_to_trash = true
|
||||
require('oil.config').delete_to_trash = true
|
||||
tmpdir = TmpDir.new()
|
||||
tmphome = TmpDir.new()
|
||||
package.loaded['canola.adapters.trash'] = require('canola.adapters.trash.freedesktop')
|
||||
package.loaded['oil.adapters.trash'] = require('oil.adapters.trash.freedesktop')
|
||||
vim.env.XDG_DATA_HOME = tmphome.path
|
||||
end)
|
||||
after_each(function()
|
||||
|
|
@ -21,7 +21,7 @@ describe('freedesktop', function()
|
|||
tmphome:dispose()
|
||||
end
|
||||
test_util.reset_editor()
|
||||
package.loaded['canola.adapters.trash'] = nil
|
||||
package.loaded['oil.adapters.trash'] = nil
|
||||
end)
|
||||
|
||||
it('files can be moved to the trash', function()
|
||||
|
|
|
|||
|
|
@ -1,26 +1,26 @@
|
|||
local canola = require('canola')
|
||||
local util = require('canola.util')
|
||||
local oil = require('oil')
|
||||
local util = require('oil.util')
|
||||
describe('url', function()
|
||||
it('get_url_for_path', function()
|
||||
local cases = {
|
||||
{ '', 'canola://' .. util.addslash(vim.fn.getcwd()) },
|
||||
{ '', 'oil://' .. util.addslash(vim.fn.getcwd()) },
|
||||
{
|
||||
'term://~/canola.nvim//52953:/bin/sh',
|
||||
'canola://' .. vim.loop.os_homedir() .. '/canola.nvim/',
|
||||
'term://~/oil.nvim//52953:/bin/sh',
|
||||
'oil://' .. vim.loop.os_homedir() .. '/oil.nvim/',
|
||||
},
|
||||
{ '/foo/bar.txt', 'canola:///foo/', 'bar.txt' },
|
||||
{ 'canola:///foo/bar.txt', 'canola:///foo/', 'bar.txt' },
|
||||
{ 'canola:///', 'canola:///' },
|
||||
{ '/foo/bar.txt', 'oil:///foo/', 'bar.txt' },
|
||||
{ 'oil:///foo/bar.txt', 'oil:///foo/', 'bar.txt' },
|
||||
{ 'oil:///', 'oil:///' },
|
||||
{
|
||||
'canola-ssh://user@hostname:8888//bar.txt',
|
||||
'canola-ssh://user@hostname:8888//',
|
||||
'oil-ssh://user@hostname:8888//bar.txt',
|
||||
'oil-ssh://user@hostname:8888//',
|
||||
'bar.txt',
|
||||
},
|
||||
{ 'canola-ssh://user@hostname:8888//', 'canola-ssh://user@hostname:8888//' },
|
||||
{ 'oil-ssh://user@hostname:8888//', 'oil-ssh://user@hostname:8888//' },
|
||||
}
|
||||
for _, case in ipairs(cases) do
|
||||
local input, expected, expected_basename = unpack(case)
|
||||
local output, basename = canola.get_buffer_parent_url(input, true)
|
||||
local output, basename = oil.get_buffer_parent_url(input, true)
|
||||
assert.equals(expected, output, string.format('Parent url for path "%s" failed', input))
|
||||
assert.equals(
|
||||
expected_basename,
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
local util = require('canola.util')
|
||||
local util = require('oil.util')
|
||||
describe('util', function()
|
||||
it('url_escape', function()
|
||||
local cases = {
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
local canola = require('canola')
|
||||
local oil = require('oil')
|
||||
local test_util = require('spec.test_util')
|
||||
|
||||
describe('window options', function()
|
||||
|
|
@ -8,28 +8,28 @@ describe('window options', function()
|
|||
|
||||
it('Restores window options on close', function()
|
||||
vim.cmd.edit({ args = { 'README.md' } })
|
||||
test_util.canola_open()
|
||||
test_util.oil_open()
|
||||
assert.equals('no', vim.o.signcolumn)
|
||||
canola.close()
|
||||
oil.close()
|
||||
assert.equals('auto', vim.o.signcolumn)
|
||||
end)
|
||||
|
||||
it('Restores window options on edit', function()
|
||||
test_util.canola_open()
|
||||
test_util.oil_open()
|
||||
assert.equals('no', vim.o.signcolumn)
|
||||
vim.cmd.edit({ args = { 'README.md' } })
|
||||
assert.equals('auto', vim.o.signcolumn)
|
||||
end)
|
||||
|
||||
it('Restores window options on split <filename>', function()
|
||||
test_util.canola_open()
|
||||
test_util.oil_open()
|
||||
assert.equals('no', vim.o.signcolumn)
|
||||
vim.cmd.split({ args = { 'README.md' } })
|
||||
assert.equals('auto', vim.o.signcolumn)
|
||||
end)
|
||||
|
||||
it('Restores window options on split', function()
|
||||
test_util.canola_open()
|
||||
test_util.oil_open()
|
||||
assert.equals('no', vim.o.signcolumn)
|
||||
vim.cmd.split()
|
||||
vim.cmd.edit({ args = { 'README.md' } })
|
||||
|
|
@ -37,29 +37,29 @@ describe('window options', function()
|
|||
end)
|
||||
|
||||
it('Restores window options on tabnew <filename>', function()
|
||||
test_util.canola_open()
|
||||
test_util.oil_open()
|
||||
assert.equals('no', vim.o.signcolumn)
|
||||
vim.cmd.tabnew({ args = { 'README.md' } })
|
||||
assert.equals('auto', vim.o.signcolumn)
|
||||
end)
|
||||
|
||||
it('Restores window options on tabnew', function()
|
||||
test_util.canola_open()
|
||||
test_util.oil_open()
|
||||
assert.equals('no', vim.o.signcolumn)
|
||||
vim.cmd.tabnew()
|
||||
vim.cmd.edit({ args = { 'README.md' } })
|
||||
assert.equals('auto', vim.o.signcolumn)
|
||||
end)
|
||||
|
||||
it('Sets the window options when re-entering canola buffer', function()
|
||||
canola.open()
|
||||
test_util.wait_for_autocmd({ 'User', pattern = 'CanolaEnter' })
|
||||
assert.truthy(vim.w.canola_did_enter)
|
||||
it('Sets the window options when re-entering oil buffer', function()
|
||||
oil.open()
|
||||
test_util.wait_for_autocmd({ 'User', pattern = 'OilEnter' })
|
||||
assert.truthy(vim.w.oil_did_enter)
|
||||
vim.cmd.edit({ args = { 'README.md' } })
|
||||
assert.falsy(vim.w.canola_did_enter)
|
||||
canola.open()
|
||||
assert.truthy(vim.w.canola_did_enter)
|
||||
assert.falsy(vim.w.oil_did_enter)
|
||||
oil.open()
|
||||
assert.truthy(vim.w.oil_did_enter)
|
||||
vim.cmd.vsplit()
|
||||
assert.truthy(vim.w.canola_did_enter)
|
||||
assert.truthy(vim.w.oil_did_enter)
|
||||
end)
|
||||
end)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue