Skip to content

Adds Various code actions to make refactoring a bit easier #853

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 35 commits into
base: master
Choose a base branch
from

Conversation

DaviD4Chirino
Copy link

@DaviD4Chirino DaviD4Chirino commented Apr 25, 2025

  • Adds export this variable (adds @export to the start of a variable, adds ranged export to numbers if you want and you can select multiple variables to export)
  • Highlight any code to export as a separated function
  • Highlight any code to export as a local variable

I want add more refactoring, and export options, but right now its good to go and most importantly, for you guys to give me pointers (as its the second extension I've made)

(I closed the other one because i missed some semicolons and i felt ashamed)

@DaviD4Chirino DaviD4Chirino changed the title Extract code as a variable Adds Various code actions to make refactoring a bit easier Apr 25, 2025
@DaviD4Chirino DaviD4Chirino reopened this Apr 25, 2025
@DaelonSuzuka
Copy link
Collaborator

Interesting idea, I'm not opposed to this.

I do have feedback, would you prefer me opening review items or just editing the PR myself?

@DaelonSuzuka DaelonSuzuka marked this pull request as draft April 26, 2025 15:17
@DaviD4Chirino
Copy link
Author

I do have feedback, would you prefer me opening review items or just editing the PR myself?

Please open review items, as I want to learn this whole process

@DaelonSuzuka
Copy link
Collaborator

@DaviD4Chirino I wrote some review comments just based on reading the diff. I'll have more feedback once I clone this branch and play with the features a bit.

@DaviD4Chirino DaviD4Chirino marked this pull request as ready for review May 1, 2025 23:22
@DaelonSuzuka DaelonSuzuka self-assigned this May 9, 2025
@DaviD4Chirino
Copy link
Author

So uh, my computer broke and i have no idea when i could get it working again, feel free to modify this pull as much as you like, i also had made the two most important code actions i wanted to make, extract function and extract variable. If theres minors error i could still not catch i apologise but i am unable to keep up for at least a month while i fix this shitty computer,

I think its good enough for a pull but thats for you to decide

@DaelonSuzuka
Copy link
Collaborator

Yikes, I hope you're back online soon!

Yeah I'll see what I can do. Thanks for doing the legwork!

@DaviD4Chirino
Copy link
Author

Hey man, i got a laptop in meantime, have you worked on the code? what do you think? Also sorry about leaving you the work i can get back on it now if that's ok.

Also its chatting in the pull request good manners? Is there a discord or something we could talk? I'm fine with this but i wanna make sure i'm leaving messages in the proper manner.

@DaelonSuzuka
Copy link
Collaborator

DaelonSuzuka commented May 30, 2025

Yeah I'm available on discord @ daelon if you want to talk directly, that's usually easier than PR comments.

I'm in my 3rd week of a new job so I'm a bit swamped and have not had time to work on this yet. I definitely plan to once things settle down a bit.

@DaelonSuzuka
Copy link
Collaborator

Okay, I made a couple minor edits to fix linter complaints, and found two problems:

Not detecting tabs vs spaces correctly:
Code_CT7Fcm9iLi

Not re-inserting leading indentation to match the extracted selection:
Code_GtPaPnZ0sf

@DaelonSuzuka
Copy link
Collaborator

Additionally, how hard would it be to do this workflow instead of the command palette prompt?

Code_sNdM8k2tRO

@DaviD4Chirino
Copy link
Author

ncMwIr84Di.mp4

So i made it work, and now that i can do that i could go back and improve extract variables code actions, but i thought it was better to finish this.

Also theres a couple things i want to point out,

  1. I want to make it so it automatically detects necessary arguments and asks for them automatically
  2. While i fixed the tabstring function to use the documents previous indentation as opposed of the whole editor indentation settings, the extracted function will most likely have a way too much indentation that i tried to fix but could not do. Its probably my skill but the way i see is to just reconstruct the indentation

I could tackle these thing but i wanted your input

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants