Skip to content

Generating unit test command not working #7740

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

tomaszgolebiowski
Copy link
Collaborator

This PR adds a class that attempts to normalize all the Uri with file paths that we get from the agent. Non-standard formatted uri causes inability to create file in editor (ex. file with unit tests). In addition, the editor does not support the creation of new files in memory by which the use of the prefix untitled in uri was incorrectly interpreted as a request to create a scratchpad file. This PR causes that if the agent request that a file needs to be created, it will be created as a project file (not a scratch file).

Test plan

  1. Open file with code
  2. Select code and open context menu
  3. Run Generate unit test command

@pkukielka
Copy link
Contributor

Please add more tests cases, e.g. for WSL, opening files which are not normal files (e.g. from JARs) etc.

val uri = CodyFileUri.parse(uriString)
val path = uri.toPath() ?: return null
if (!path.exists()) {
path.parent?.createDirectories()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What if path is relative?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For the test, can you also open untitled file in VSC and try to do some edit in it?

Tomasz Gołębiowski added 2 commits April 17, 2025 16:27
…th-norm

# Conflicts:
#	jetbrains/src/main/kotlin/com/sourcegraph/cody/config/actions/OpenCodySettingsEditorAction.kt
#	jetbrains/src/main/kotlin/com/sourcegraph/utils/CodyEditorUtil.kt
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants