diff options
author | mitchell <70453897+orbitalquark@users.noreply.github.com> | 2022-02-23 10:51:58 -0500 |
---|---|---|
committer | mitchell <70453897+orbitalquark@users.noreply.github.com> | 2022-02-23 10:51:58 -0500 |
commit | 6dc247b44324846f5645152d5a01edcf11702aee (patch) | |
tree | 6aa9b08a572896367b2dc6cd08b7b7a5d65d1bd1 | |
parent | e2f595093ba1a4c67935ad90d5974aa6f23a64cd (diff) |
Fixed bug in `ui.goto_file()` when specifying preferred view.
-rw-r--r-- | core/ui.lua | 2 | ||||
-rw-r--r-- | test/test.lua | 10 |
2 files changed, 6 insertions, 6 deletions
diff --git a/core/ui.lua b/core/ui.lua index 286f03b5..8a57a160 100644 --- a/core/ui.lua +++ b/core/ui.lua @@ -272,7 +272,7 @@ function ui.goto_file(filename, split, preferred_view, sloppy) if #_VIEWS == 1 and split and not (view.buffer.filename or ''):find(patt) then view:split() else - local other_view = _VIEWS[preferred_view] + local other_view = preferred_view for _, view in ipairs(_VIEWS) do local view_filename = view.buffer.filename or '' if view_filename:find(patt) then diff --git a/test/test.lua b/test/test.lua index 13870de8..206efe23 100644 --- a/test/test.lua +++ b/test/test.lua @@ -1043,10 +1043,10 @@ function test_ui_switch_buffer_interactive() end function test_ui_goto_file() - local dir1_file1 = _HOME .. '/core/ui/dir1/file1' - local dir1_file2 = _HOME .. '/core/ui/dir1/file2' - local dir2_file1 = _HOME .. '/core/ui/dir2/file1' - local dir2_file2 = _HOME .. '/core/ui/dir2/file2' + local dir1_file1 = _HOME .. '/test/ui/dir1/file1' + local dir1_file2 = _HOME .. '/test/ui/dir1/file2' + local dir2_file1 = _HOME .. '/test/ui/dir2/file1' + local dir2_file2 = _HOME .. '/test/ui/dir2/file2' ui.goto_file(dir1_file1) -- current view assert_equal(#_VIEWS, 1) assert_equal(buffer.filename, dir1_file1) @@ -1063,7 +1063,7 @@ function test_ui_goto_file() ui.goto_file(dir2_file1) -- should go back to first view assert_equal(buffer.filename, dir2_file1) assert_equal(_VIEWS[2].buffer.filename, dir1_file2) - ui.goto_file(dir2_file2, false, _VIEWS[1]) -- should go to second view + ui.goto_file(dir2_file2, false, _VIEWS[2]) -- should go to second view assert_equal(#_VIEWS, 2) assert_equal(buffer.filename, dir2_file2) assert_equal(_VIEWS[1].buffer.filename, dir2_file1) |