fix: incorrect filepath (#865)
This commit is contained in:
parent
3051bfdf24
commit
0b1cd5509e
1
.github/workflows/ci.yaml
vendored
1
.github/workflows/ci.yaml
vendored
@ -19,6 +19,7 @@ jobs:
|
|||||||
with:
|
with:
|
||||||
crate: stylua
|
crate: stylua
|
||||||
features: lua54
|
features: lua54
|
||||||
|
- run: stylua --version
|
||||||
- run: stylua --check ./lua/ ./plugin/
|
- run: stylua --check ./lua/ ./plugin/
|
||||||
luacheck:
|
luacheck:
|
||||||
name: Lint Lua
|
name: Lint Lua
|
||||||
|
@ -173,6 +173,13 @@ local function transform_result_content(original_content, result_content, code_l
|
|||||||
local i = 1
|
local i = 1
|
||||||
while i <= #result_lines do
|
while i <= #result_lines do
|
||||||
local line_content = result_lines[i]
|
local line_content = result_lines[i]
|
||||||
|
if line_content:match("<FILEPATH>.+</FILEPATH>") then
|
||||||
|
local filepath = line_content:match("<FILEPATH>(.+)</FILEPATH>")
|
||||||
|
if filepath then
|
||||||
|
table.insert(transformed_lines, string.format("Filepath: %s", filepath))
|
||||||
|
goto continue
|
||||||
|
end
|
||||||
|
end
|
||||||
if line_content == "<SEARCH>" then
|
if line_content == "<SEARCH>" then
|
||||||
is_searching = true
|
is_searching = true
|
||||||
local next_line = result_lines[i + 1]
|
local next_line = result_lines[i + 1]
|
||||||
@ -355,6 +362,8 @@ local function extract_code_snippets_map(response_content)
|
|||||||
if line:match("^%s*```") then
|
if line:match("^%s*```") then
|
||||||
if in_code_block then
|
if in_code_block then
|
||||||
if start_line ~= nil and end_line ~= nil then
|
if start_line ~= nil and end_line ~= nil then
|
||||||
|
local filepath = lines[start_line_in_response_buf - 2]
|
||||||
|
if filepath:match("^[Ff]ilepath:") then filepath = filepath:match("^[Ff]ilepath:%s*(.+)") end
|
||||||
local snippet = {
|
local snippet = {
|
||||||
range = { start_line, end_line },
|
range = { start_line, end_line },
|
||||||
content = table.concat(current_snippet, "\n"),
|
content = table.concat(current_snippet, "\n"),
|
||||||
@ -362,7 +371,7 @@ local function extract_code_snippets_map(response_content)
|
|||||||
explanation = explanation,
|
explanation = explanation,
|
||||||
start_line_in_response_buf = start_line_in_response_buf,
|
start_line_in_response_buf = start_line_in_response_buf,
|
||||||
end_line_in_response_buf = idx,
|
end_line_in_response_buf = idx,
|
||||||
filepath = lines[start_line_in_response_buf - 2],
|
filepath = filepath,
|
||||||
}
|
}
|
||||||
table.insert(snippets, snippet)
|
table.insert(snippets, snippet)
|
||||||
end
|
end
|
||||||
@ -558,6 +567,7 @@ function Sidebar:apply(current_cursor)
|
|||||||
end
|
end
|
||||||
|
|
||||||
vim.defer_fn(function()
|
vim.defer_fn(function()
|
||||||
|
api.nvim_set_current_win(self.code.winid)
|
||||||
for filepath, snippets in pairs(selected_snippets_map) do
|
for filepath, snippets in pairs(selected_snippets_map) do
|
||||||
local bufnr = Utils.get_or_create_buffer_with_filepath(filepath)
|
local bufnr = Utils.get_or_create_buffer_with_filepath(filepath)
|
||||||
insert_conflict_contents(bufnr, snippets)
|
insert_conflict_contents(bufnr, snippets)
|
||||||
|
@ -45,7 +45,7 @@ ONLY EVER RETURN CODE IN A *SEARCH/REPLACE BLOCK*!
|
|||||||
|
|
||||||
Here are the *SEARCH/REPLACE* blocks:
|
Here are the *SEARCH/REPLACE* blocks:
|
||||||
|
|
||||||
mathweb/flask/app.py
|
<FILEPATH>mathweb/flask/app.py</FILEPATH>
|
||||||
<SEARCH>
|
<SEARCH>
|
||||||
from flask import Flask
|
from flask import Flask
|
||||||
</SEARCH>
|
</SEARCH>
|
||||||
@ -68,7 +68,7 @@ def factorial(n):
|
|||||||
<REPLACE>
|
<REPLACE>
|
||||||
</REPLACE>
|
</REPLACE>
|
||||||
|
|
||||||
mathweb/flask/app.py
|
<FILEPATH>mathweb/flask/app.py</FILEPATH>
|
||||||
<SEARCH>
|
<SEARCH>
|
||||||
return str(factorial(n))
|
return str(factorial(n))
|
||||||
</SEARCH>
|
</SEARCH>
|
||||||
@ -86,7 +86,7 @@ mathweb/flask/app.py
|
|||||||
|
|
||||||
Here are the *SEARCH/REPLACE* blocks:
|
Here are the *SEARCH/REPLACE* blocks:
|
||||||
|
|
||||||
hello.py
|
<FILEPATH>hello.py</FILEPATH>
|
||||||
<SEARCH>
|
<SEARCH>
|
||||||
</SEARCH>
|
</SEARCH>
|
||||||
<REPLACE>
|
<REPLACE>
|
||||||
@ -96,7 +96,7 @@ def hello():
|
|||||||
print("hello")
|
print("hello")
|
||||||
</REPLACE>
|
</REPLACE>
|
||||||
|
|
||||||
main.py
|
<FILEPATH>main.py</FILEPATH>
|
||||||
<SEARCH>
|
<SEARCH>
|
||||||
def hello():
|
def hello():
|
||||||
"print a greeting"
|
"print a greeting"
|
||||||
|
@ -272,7 +272,9 @@ end
|
|||||||
---@param msg string|string[]
|
---@param msg string|string[]
|
||||||
---@param opts? LazyNotifyOpts
|
---@param opts? LazyNotifyOpts
|
||||||
function M.notify(msg, opts)
|
function M.notify(msg, opts)
|
||||||
if vim.in_fast_event() then return vim.schedule(function() M.notify(msg, opts) end) end
|
if vim.in_fast_event() then
|
||||||
|
return vim.schedule(function() M.notify(msg, opts) end)
|
||||||
|
end
|
||||||
|
|
||||||
opts = opts or {}
|
opts = opts or {}
|
||||||
if type(msg) == "table" then
|
if type(msg) == "table" then
|
||||||
|
Loading…
x
Reference in New Issue
Block a user