mirror of
https://github.com/ThePrimeagen/harpoon.git
synced 2025-07-13 17:40:25 +00:00
updated formatting
This commit is contained in:
parent
323027715f
commit
730dc0c0d2
@ -22,7 +22,6 @@ local function close_menu(force_save)
|
||||
Harpoon_cmd_bufh = nil
|
||||
end
|
||||
|
||||
|
||||
local function create_window()
|
||||
log.trace("_create_window()")
|
||||
local config = harpoon.get_menu_config()
|
||||
@ -55,19 +54,19 @@ local function create_window()
|
||||
end
|
||||
|
||||
local function is_white_space(str)
|
||||
local white_space_chars = {
|
||||
[" "] = true,
|
||||
["\t"] = true,
|
||||
["\r"] = true,
|
||||
["\f"] = true,
|
||||
["\v"] = true
|
||||
}
|
||||
for i = 1, string.len(str) do
|
||||
if white_space_chars[string.sub(str, i, i)] == nil then
|
||||
return false
|
||||
local white_space_chars = {
|
||||
[" "] = true,
|
||||
["\t"] = true,
|
||||
["\r"] = true,
|
||||
["\f"] = true,
|
||||
["\v"] = true,
|
||||
}
|
||||
for i = 1, string.len(str) do
|
||||
if white_space_chars[string.sub(str, i, i)] == nil then
|
||||
return false
|
||||
end
|
||||
end
|
||||
end
|
||||
return true
|
||||
return true
|
||||
end
|
||||
|
||||
local function get_menu_items()
|
||||
@ -76,9 +75,9 @@ local function get_menu_items()
|
||||
local indices = {}
|
||||
|
||||
for _, line in pairs(lines) do
|
||||
if not is_white_space(line) then
|
||||
table.insert(indices, line)
|
||||
end
|
||||
if not is_white_space(line) then
|
||||
table.insert(indices, line)
|
||||
end
|
||||
end
|
||||
|
||||
return indices
|
||||
@ -86,7 +85,10 @@ end
|
||||
|
||||
M.toggle_quick_menu = function()
|
||||
log.trace("toggle_quick_menu()")
|
||||
if Harpoon_cmd_win_id ~= nil and vim.api.nvim_win_is_valid(Harpoon_cmd_win_id) then
|
||||
if
|
||||
Harpoon_cmd_win_id ~= nil
|
||||
and vim.api.nvim_win_is_valid(Harpoon_cmd_win_id)
|
||||
then
|
||||
close_menu()
|
||||
return
|
||||
end
|
||||
|
@ -58,10 +58,9 @@ local function get_first_empty_slot()
|
||||
return idx
|
||||
end
|
||||
end
|
||||
return M.get_length() + 1;
|
||||
return M.get_length() + 1
|
||||
end
|
||||
|
||||
|
||||
M.gotoTerminal = function(idx)
|
||||
log.trace("gotoTerminal(): Terminal:", idx)
|
||||
local term_handle = find_terminal(idx)
|
||||
@ -112,7 +111,7 @@ end
|
||||
|
||||
M.add_cmd = function(cmd)
|
||||
log.trace("add_cmd()")
|
||||
local found_idx = get_first_empty_slot();
|
||||
local found_idx = get_first_empty_slot()
|
||||
harpoon.get_term_config().cmds[found_idx] = cmd
|
||||
M.emit_changed()
|
||||
end
|
||||
@ -128,14 +127,14 @@ M.rm_cmd = function(idx)
|
||||
end
|
||||
|
||||
M.set_cmd_list = function(new_list)
|
||||
log.trace("set_cmd_list(): New list:", new_list)
|
||||
for k in pairs(harpoon.get_term_config().cmds) do
|
||||
harpoon.get_term_config().cmds[k] = nil
|
||||
end
|
||||
for k, v in pairs(new_list) do
|
||||
harpoon.get_term_config().cmds[k] = v
|
||||
end
|
||||
M.emit_changed()
|
||||
log.trace("set_cmd_list(): New list:", new_list)
|
||||
for k in pairs(harpoon.get_term_config().cmds) do
|
||||
harpoon.get_term_config().cmds[k] = nil
|
||||
end
|
||||
for k, v in pairs(new_list) do
|
||||
harpoon.get_term_config().cmds[k] = v
|
||||
end
|
||||
M.emit_changed()
|
||||
end
|
||||
|
||||
return M
|
||||
|
@ -3,7 +3,7 @@ local term = require("harpoon.term")
|
||||
|
||||
local function assert_table_equals(tbl1, tbl2)
|
||||
if #tbl1 ~= #tbl2 then
|
||||
assert(false, ""..#tbl1.." != "..#tbl2)
|
||||
assert(false, "" .. #tbl1 .. " != " .. #tbl2)
|
||||
end
|
||||
for i = 1, #tbl1 do
|
||||
if tbl1[i] ~= tbl2[i] then
|
||||
@ -21,7 +21,7 @@ describe("basic functionalities", function()
|
||||
cmds = {}
|
||||
harpoon.get_term_config = function()
|
||||
return {
|
||||
cmds = cmds
|
||||
cmds = cmds,
|
||||
}
|
||||
end
|
||||
term.emit_changed = function()
|
||||
@ -32,7 +32,7 @@ describe("basic functionalities", function()
|
||||
it("add_cmd for empty", function()
|
||||
term.add_cmd("cmake ..")
|
||||
local expected_result = {
|
||||
"cmake .."
|
||||
"cmake ..",
|
||||
}
|
||||
assert_table_equals(harpoon.get_term_config().cmds, expected_result)
|
||||
assert.equals(emitted, true)
|
||||
@ -131,10 +131,10 @@ describe("basic functionalities", function()
|
||||
term.add_cmd("cmake ..")
|
||||
term.add_cmd("make")
|
||||
term.add_cmd("ninja")
|
||||
term.set_cmd_list({"make uninstall", "make install",})
|
||||
term.set_cmd_list({ "make uninstall", "make install" })
|
||||
local expected_result = {
|
||||
"make uninstall",
|
||||
"make install",
|
||||
"make uninstall",
|
||||
"make install",
|
||||
}
|
||||
assert_table_equals(expected_result, harpoon.get_term_config().cmds)
|
||||
end)
|
||||
|
Loading…
x
Reference in New Issue
Block a user