Skip to content

Commit

Permalink
fix: error when run_request is run without { verbose = XXX }
Browse files Browse the repository at this point in the history
we should actually merge opts with a default dict so that we can reference keys without having to check if they exist (TODO)
  • Loading branch information
teto committed Dec 29, 2022
1 parent 867cde3 commit 25761da
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lua/rest-nvim/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ rest.run = function(verbose)
return
end

return rest.run_request(result, verbose)
return rest.run_request(result, { verbose = verbose })
end

-- run will retrieve the required request information from the current buffer
Expand Down Expand Up @@ -65,7 +65,7 @@ rest.run_request = function(req, opts)
raw = config.get("skip_ssl_verification") and vim.list_extend(result.raw, { "-k" })
or result.raw,
body = result.body,
dry_run = opts.verbose or false,
dry_run = opts.verbose,

This comment has been minimized.

Copy link
@rochacbruno

rochacbruno Dec 29, 2022

Contributor

@teto this is raising an error

5108: Error executing lua .../site/pack/packer/start/rest.nvim/lua/rest-nvim/init.lua:67: attempt to index local 'opts' (a nil value)                                                                                                      
stack traceback:
        .../site/pack/packer/start/rest.nvim/lua/rest-nvim/init.lua:67: in function 'run'
        [string ":lua"]:1: in main chunk

This comment has been minimized.

Copy link
@rochacbruno

rochacbruno Dec 29, 2022

Contributor

There is no default value for verbose

This comment has been minimized.

Copy link
@rochacbruno

rochacbruno Dec 29, 2022

Contributor

the problem was my mappings

  r = { "<cmd>lua require'rest-nvim'.run()<cr>", "Run" },

I am now passing false however I was not expecting this breaking change when I updated my Packer

Also I am seeing debug every time I open the editor

This comment has been minimized.

Copy link
@teto

teto Dec 29, 2022

Author Collaborator

the popup you see when opening the editor should have been fixed by #167.

Sorry for the breaking changes, I did not expect that many users to update and use it.
r = { "<cmd>lua require'rest-nvim'.run(false)<cr>", "Run" },
what we need is to merge opts with a default table {verbose = false } for instance so that the user doesn't need to pass a value. Do you want to contribute ?

This comment has been minimized.

Copy link
@rochacbruno

rochacbruno Dec 29, 2022

Contributor

@teto I can give a try, and I am using like that because for me there is no commands to map such as RestNvim run etc

This comment has been minimized.

Copy link
@rochacbruno

rochacbruno Dec 30, 2022

Contributor
bufnr = result.bufnr,
start_line = result.start_line,
end_line = result.end_line,
Expand Down

0 comments on commit 25761da

Please sign in to comment.