sourcegraph / cody

Type less, code more: Cody is an AI code assistant that uses advanced search and codebase context to help you write and fix code.
https://cody.dev
Apache License 2.0
2.59k stars 275 forks source link

editor: support all uri schemes for getTextEditorContentForFile #4629

Closed keegancsmith closed 3 months ago

keegancsmith commented 3 months ago

We already have a uri passed in and I am unsure why we converted that into a uri which was just the filepath. I am assuming it was due to code evolution.

In particular this makes it so that cody can understand context from unsaved files.

Test Plan: create a new unsaved file with the word "hello world" in it. Start a cody chat and ask cody about the file. Expect cody mentions hello world in the response. Before this change we got an error.

Fixes https://linear.app/sourcegraph/issue/CODY-2469/a-new-chat-with-an-unsaved-buffer-as-context-shows-an-error

keegancsmith commented 3 months ago

Note: I skimmed over all uses of vscode.Uri.file and couldn't find any other example we did this. All other examples seem to be on actual file paths or on "fake" files like when we need a uri for terminal output.

sqs commented 3 months ago

agreed, there is no reason for this old behavior