feat: Support Line Column in file pickers (#2791)

This implements a experimental interface for allowing prompts like this `file.txt:3:4`. It is already enabled on default for `find_files` and `git_files`.

Be wary of breaking changes for the interface if you plan to manually enable it.
This commit is contained in:
Dmitriy Kovalenko
2024-01-09 09:35:26 +01:00
committed by GitHub
parent 87e92ea31b
commit 0bf09d05ab
6 changed files with 117 additions and 6 deletions

View File

@@ -78,3 +78,48 @@ describe("is_uri", function()
end
end)
end)
describe("separates file path location", function()
local suites = {
{
input = "file.txt:12:4",
file = "file.txt",
row = 12,
col = 4,
},
{
input = "file.txt:12",
file = "file.txt",
row = 12,
col = 0,
},
{
input = "file:12:4",
file = "file",
row = 12,
col = 4,
},
{
input = "file:12:",
file = "file",
row = 12,
col = 0,
},
{
input = "file:",
file = "file",
row = 0,
col = 0,
},
}
for _, suite in ipairs(suites) do
it("separtates file path for " .. suite.input, function()
local file, row, col = utils.__separate_file_path_location(suite.input)
assert.are.equal(file, suite.file)
assert.are.equal(row, suite.row)
assert.are.equal(col, suite.col)
end)
end
end)