-
Notifications
You must be signed in to change notification settings - Fork 240
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
Edit: Add further code actions for editing and documenting code #1724
Conversation
5279070
to
b73235a
Compare
4ca05bf
to
60f800b
Compare
8772cfa
to
eb05429
Compare
567e763
to
c20632c
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The "edit" action most worked as expected, but the results show that the LLM has a poor understanding of the surrounding code. The UX is awesome. I'd love to use it with a smarter model and better context. Noob q: what model do we use for quick actions?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Love the new actions! Especially "document" and "generate" ones. Going to use them locally and report issues in Slack 🙌
public static readonly providedCodeActionKinds = [vscode.CodeActionKind.RefactorRewrite] | ||
|
||
public provideCodeActions(document: vscode.TextDocument, range: vscode.Range): vscode.CodeAction[] { | ||
const [documentableNode] = execQueryWrapper(document, range.start, 'getDocumentableNode') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Noice!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@umpox, let me know if you noticed any confusing parts about our tree-sitter setup 🙂
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is super cool! Can we add it as an option for the commands/custom commands? Think it'd be helpful with the /explain and /test commands!!!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@valerybugakov The tests are great and the SDK is super easy to use and build from.
I found it helpful to take the contents from a page at https://learnxinyminutes.com/ and then put it into this playground when writing the queries. Covers quite a lot of cases.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@abeatrix Maybe, do you have any ideas? I think we could possibly use this with the scope expansion too, e.g. expanding to nearest function etc if we want more control over different scenarios.
I think we don't make this available for custom commands yet, it's quite hard to write these queries so not sure if anyone will want to integrate them with a custom command. Possibly there's future work to integrate pre-written ones though, like useNearestFunctionAsSelection
or something
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I found it helpful to take the contents from a page at https://learnxinyminutes.com/
TIL, thanks for sharing! I've been asking GPT-4 to generate a file with all syntax constructs, but using the website you shared is a bit more reliable 😛
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Found some issues with the code actions, but love the idea in general! Curious to know why we need a different prompt and action for the Documentation Code Action instead of using the existing one?
Document Code Lens
Break the code and the undo button does not work
Screen.Recording.2023-11-17.at.6.24.07.AM.mov
Undo button always remove the last line that it did not line
Issue unrelated to this PR but related to the feature 😅
Screen.Recording.2023-11-17.at.6.21.29.AM.mov
Retry Code Lens breaks the code before applying new changes
Screen.Recording.2023-11-17.at.6.15.04.AM.mov
vscode/src/code-actions/edit.ts
Outdated
selection?: vscode.Selection | ||
): vscode.CodeAction { | ||
const action = new vscode.CodeAction(displayText, vscode.CodeActionKind.RefactorRewrite) | ||
const source = 'code-action' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What do you think about adding the type of action to the end of source, e.g. code-action:generate
, code-action:edit
so we can create a dashboard for each code action usages?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep good idea
@abeatrix Thanks for reporting the "undo" bugs! I took a look and everything you mentioned was related to weird "undo" logic we had. The problem was that we were incorrectly using the For fixups we do care about appending or prepending, so I've updated this logic to support expanding the range if there is a partial overlap ( This also has the benefit of improving the diff highlighting for the /doc output, as previously we mostly ignored this. |
Thanks for working on this! Confirmed the following are fixed
Screen.Recording.2023-11-22.at.8.31.22.AM.movThere are some issues with the Screen.Recording.2023-11-22.at.8.37.37.AM.mov |
@abeatrix Can't replicate the issue with the line being removed 🤔 Please could you output the logs if you see it again? The only things I can think are:
Going to update this with |
PTO & following up on LLM response reliability in #1790
Description
This PR:
Document Code Action
Only shows when on a documentable symbol. Determined via Tree Sitter
CodeActionDocument.mov
Edit Code Action
Only shows when there is an active selection
CodeActionEdit.mov
Generate Code Action
Only shows when there is no selection and the current line is empty.
CodeActionGenerate.mov
Test plan
Trigger code actions on: