Skip to content

Commit

Permalink
fix: filePath -> uri (#241)
Browse files Browse the repository at this point in the history
Closes #224
  • Loading branch information
tjdevries committed May 24, 2024
1 parent 720e001 commit 437b2f5
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 24 deletions.
4 changes: 2 additions & 2 deletions lua/sg/cody/protocol.lua
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ proto.get_text_document = function(bufnr, opts)
end

local text_document = {
filePath = name,
uri = name,
}

if opts.content then
Expand Down Expand Up @@ -93,7 +93,7 @@ proto.did_close = function(bufnr)
end

local doc = proto.get_text_document(bufnr, { content = false })
if not doc.filePath then
if not doc.uri then
return
end

Expand Down
2 changes: 1 addition & 1 deletion lua/sg/cody/rpc.lua
Original file line number Diff line number Diff line change
Expand Up @@ -370,7 +370,7 @@ M.execute = {}
M.execute.autocomplete = function(file, line, character, callback)
return M.request(
"autocomplete/execute",
{ filePath = file, position = { line = line, character = character } },
{ uri = file, position = { line = line, character = character } },
callback
)
end
Expand Down
19 changes: 3 additions & 16 deletions lua/sg/types.lua
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ local M = {}
---@class CodyServerCapabilities

---@class CodyTextDocument
---@field filePath string
---@field uri string
---@field content string?
---@field selection cody.Range?

Expand Down Expand Up @@ -171,23 +171,10 @@ M.CodySpeaker = { human = "human", assistant = "assistant" }
---@field error? cody.ChatError

---@class CodyChatMessageData
--- TODO

---@class cody.PreciseContext
--[[
export interface PreciseContext {
symbol: {
fuzzyName?: string
}
hoverText: string[]
definitionSnippet: string
filePath: string
range?: {
startLine: number
startCharacter: number
endLine: number
endCharacter: number
}
} ]]
--- TODO

---@class CodyChatUpdateMessageInProgressNoti: cody.ChatMessage
---@field text string?
Expand Down
10 changes: 5 additions & 5 deletions lua/tests/cody_lifecycle_spec.lua
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ describe("Cody Lifecycle", function()
end, vim.api.nvim_list_bufs()))
)
)
assert(string.find(opened.params.filePath, "README.md"), "Did not send correct filename")
assert(string.find(opened.params.uri, "README.md"), "Did not send correct filename")

local readme_bufnr = vim.api.nvim_get_current_buf()

Expand All @@ -59,7 +59,7 @@ describe("Cody Lifecycle", function()
end)[1]

assert(deleted, "Did not close readme")
assert(string.find(deleted.params.filePath, "README.md"), "Did not close correct filename")
assert(string.find(deleted.params.uri, "README.md"), "Did not close correct filename")

-- Update the buffer
vim.wait(10)
Expand All @@ -71,7 +71,7 @@ describe("Cody Lifecycle", function()
local changed = filter_msg(function(msg)
return msg.type == "notify"
and msg.method == "textDocument/didChange"
and string.find(msg.params.filePath, "Cargo.toml")
and string.find(msg.params.uri, "Cargo.toml")
end)[1]

return changed ~= nil
Expand All @@ -81,14 +81,14 @@ describe("Cody Lifecycle", function()
local changed = filter_msg(function(msg)
return msg.type == "notify"
and msg.method == "textDocument/didChange"
and string.find(msg.params.filePath, "Cargo.toml")
and string.find(msg.params.uri, "Cargo.toml")
end)[1]

assert(changed, "Did not receive didChange notification: " .. vim.inspect(rpc.messages))

eq({ "inserted" }, vim.api.nvim_buf_get_lines(0, 0, 1, false))
assert(
string.find(changed.params.filePath, "Cargo.toml"),
string.find(changed.params.uri, "Cargo.toml"),
"Did not update correct filename: " .. vim.inspect(changed)
)
end)
Expand Down

0 comments on commit 437b2f5

Please sign in to comment.