Skip to content

Open editors when applying text edits via code actions#925

Merged
dzhou121 merged 2 commits intolapce:masterfrom
MinusGix:focus-file
Aug 4, 2022
Merged

Open editors when applying text edits via code actions#925
dzhou121 merged 2 commits intolapce:masterfrom
MinusGix:focus-file

Conversation

@MinusGix
Copy link
Copy Markdown
Member

@MinusGix MinusGix commented Aug 4, 2022

This makes so when applying edits via code actions it will open files that it references.
Previously, we would just ignore edits that reference other files, which was incorrect.
One example where this occurs is:

  • Create a new file in a rust project
  • Ctrl+. inside that new file gives code actions to add mod filename; to the lib.rs/main.rs file so that it is recognized as part of the rust project.
  • Previously this would simply do nothing. With the PR, it will open the file if it isn't already open (because we need the file to apply the edit!) and apply the edit, letting the user save with the edits if they wish.

The first commit switches to using a structure for InitBufferContent, since they were sharing literally all fields (and I was going to be adding yet another). It also moves the behavior function onto the structure, since it is obviously related to it.

The second commit adds a callback parameter which is executed when the buffer is finally loaded. It is called immediately if the file is already open, otherwise given to the InitBufferContent structure and called when it finished. This then lets us just wait until the buffer is loaded and editor is opened, and then applies the edits.

@MinusGix MinusGix added the A-editor Area: editor, modal editing label Aug 4, 2022
@MinusGix MinusGix force-pushed the focus-file branch 2 times, most recently from 7b90727 to a8de24e Compare August 4, 2022 05:29
@dzhou121 dzhou121 merged commit c42333d into lapce:master Aug 4, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-editor Area: editor, modal editing

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants