Skip to content
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

Template label for pasting the currently opened file/selection #100

Open
shalak opened this issue May 1, 2023 · 8 comments
Open

Template label for pasting the currently opened file/selection #100

shalak opened this issue May 1, 2023 · 8 comments
Labels
enhancement New feature or request

Comments

@shalak
Copy link
Contributor

shalak commented May 1, 2023

It would be a nice improvement to be able to type something like this in chat:

My project gradle file look like {{this}}. How can I fix <blah, blah, blah>

The {{this}} placeholder would be replaced on-the-fly with the content of currently focused file in IDE, or currently selected part of code (if any).

I only chose {{}} format because o templating used in CodeGPT settings window, for better UX, we could go with !this format.

@shalak shalak changed the title Template label for pasting the currently opened file Template label for pasting the currently opened file/selection May 1, 2023
@carlrobertoh
Copy link
Owner

It would be a nice improvement! I think the placeholder needs to be configurable in the settings.

@shalak
Copy link
Contributor Author

shalak commented May 2, 2023

Would be great to have another placeholder (something like sub-label), that would produce a path to the file - e.g. !this:path and !this+path that would produce:

```
/path/to/file:
<file content>
```

(including the markdown code-block marks)

And we could go even further - to paste all files opened in current tab, e.g.

Prompting:

I have the following structure:
!all+path
write unit tests for all of them

would result in:

I have the following file structure:
```
/path/to/file1:
<content of file1>

/path/to/file2:
<content of file2>
```
write unit tests for all of them

I frequently find myself doing just that.

@carlrobertoh
Copy link
Owner

I ditched the placeholders idea and went with simple Select and Ask logic.

Please re-open the ticket if you would like to discuss further steps.

@shalak
Copy link
Contributor Author

shalak commented Jun 6, 2023

I'm not sure I follow - the string selected code is the placeholder?

@carlrobertoh
Copy link
Owner

carlrobertoh commented Jun 6, 2023

No placeholder is used, you need to simply highlight a code block in the main editor and ask the question, highlighted code is included in the prompt automatically.

However, I actually think having some proper placeholders will give the user better prompt customization.

Reopening the ticket.

@shalak
Copy link
Contributor Author

shalak commented Jun 6, 2023

I see. I'm struggling to find the exact prompt being sent. Is it simple <question_typed_in_chat>\n<selected_code> or is there something more complicated?

@carlrobertoh
Copy link
Owner

Yes, the highlighted text is added after the user's prompt. You can see that if you reopen the chat tab.

@carlrobertoh carlrobertoh reopened this Jun 6, 2023
@carlrobertoh carlrobertoh added the enhancement New feature or request label Jun 27, 2023
@user753
Copy link

user753 commented Nov 25, 2023

Something like {{file:path/to/file}} would be very useful. It would simply insert the content of the file into this placeholder.

For example, it could be used in actions like this: Write tests for the selected code {{selectedCode}}, using {{file:path/to/good-test-example}} as an example.

In my experience, the example improves the quality of the code.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants