Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(ui/parser): remove unused variable, remove nil warnings #210

Merged
merged 2 commits into from
Sep 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion lua/kulala/parser/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -451,7 +451,7 @@ end

---Parse a request and return the request on itself, its headers and body
---@param start_request_linenr number|nil The line number where the request starts
---@return Request -- Table containing the request data
---@return Request|nil -- Table containing the request data or nil if parsing fails
function M.parse(start_request_linenr)
local res = {
metadata = {},
Expand Down Expand Up @@ -483,6 +483,11 @@ function M.parse(start_request_linenr)
document_variables, requests = M.get_document()
req = M.get_request_at(requests, start_request_linenr)
end

if req == nil then
return nil
end

Scripts.javascript.run("pre_request", req.scripts.pre_request)
local env = ENV_PARSER.get_env()

Expand Down
5 changes: 4 additions & 1 deletion lua/kulala/ui/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,6 @@ end
---Prints the parsed Request table into current buffer - uses nvim_put
local function print_http_spec(spec, curl)
local lines = {}
local idx = 1

table.insert(lines, "# " .. curl)

Expand All @@ -149,6 +148,10 @@ end

M.copy = function()
local result = PARSER.parse()
if result == nil then
Logger.error("No request found")
return
end
local cmd_table = {}
local skip_arg = false
for idx, v in ipairs(result.cmd) do
Expand Down