Skip to content

Commit

Permalink
fix: get_auth was always returning nil
Browse files Browse the repository at this point in the history
  • Loading branch information
NTBBloodbath committed Jun 30, 2021
1 parent a6decd3 commit d6aeecb
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions lua/rest-nvim/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -200,14 +200,18 @@ end
-- @param query_line Line to set cursor position
local function get_auth(bufnr, query_line)
local auth = {}
local auth_not_empty = false
local is_auth_empty = true
-- Set stop at end of bufer
local stop_line = fn.line('$')

-- Iterate over all buffer lines
for _ = 1, stop_line do
-- Case-insensitive search
local start_line = fn.search('\\cAuthorization:', '', stop_line)
if start_line ~= 0 then
is_auth_empty = false
end

local end_line = start_line
local auth_line = api.nvim_buf_get_lines(
bufnr,
Expand All @@ -227,7 +231,7 @@ local function get_auth(bufnr, query_line)
end

go_to_line(bufnr, query_line)
if not auth_not_empty then
if is_auth_empty then
return nil
end
return auth
Expand Down

0 comments on commit d6aeecb

Please sign in to comment.