fix(pickers): when no lnum given, don't set entry.lnum (#2865)

Fixes couple of regressions from #2791 when no line number info is given
in the prompt (eg. `file.txt` rather than `file.txt:10`).

Both issues stemming from the fact that when no line number info is
given, the `entry.lnum` was set to `0`. `entry.lnum` is 1-index.
- Sending results to quickfix would send faulty results (closes #2864)
- Will no open the file on the correct (previous) line number

For this, setting the lnum to 1 is still undesirable since this
overwrites the lnum priority handling in the `select` action.
This commit is contained in:
James Trew
2024-01-11 22:35:52 -05:00
committed by GitHub
parent b3ff5f3320
commit d8129bf9f0
2 changed files with 5 additions and 4 deletions

View File

@@ -569,7 +569,10 @@ end
--- Takes the path and parses optional cursor location `$file:$line:$column`
--- If line or column not present `0` returned.
--- @param path string
---@param path string
---@return string path
---@return integer? lnum
---@return integer? col
utils.__separate_file_path_location = function(path)
local location_numbers = {}
for i = #path, 1, -1 do
@@ -600,7 +603,7 @@ utils.__separate_file_path_location = function(path)
return path, location_numbers[1], 0
end
return path, 0, 0
return path, nil, nil
end
return utils

View File

@@ -108,8 +108,6 @@ describe("separates file path location", function()
{
input = "file:",
file = "file",
row = 0,
col = 0,
},
}