NodeRequirer icon indicating copy to clipboard operation
NodeRequirer copied to clipboard

Support fixing require statements after moving a file

Open ganemone opened this issue 10 years ago • 1 comments

Really annoying to go through all the code and update this. This would be a cool addition.

ganemone avatar Feb 26 '15 21:02 ganemone

Note that what we could implement inside NodeRequirer would be fairly limited without being too complex.

The ideal would be to have a node based cli command that can move files and reformat references. ;) And it looks like node-mv already does that.

But here are some extra ideas we can do:

Option A) Allow Ctrl+Shift+I to discover when the cursor is placed over an existing require(...), use part of its value to pre-fill the quick panel, and make sure that we only update the require(...).

Option B) Implement Node Move / Node Rename sidebar context menu items (next to the ones that SideBarEnhancements have) that simply reformats the relative requires for the current file.

Option C) Implement Node Move / Node Rename sidebar context menu items that use node-mv when it's installed.

I'm in favour of A and one of B or C, with caveats. B is simple but doesn't solve broken references from other files. C should do proper moves, however if the user has unsaved buffers for files that are modified those will conflict.

An alternate idea might be to intercept SideBarEnhancements' side_bar_rename and side_bar_move commands when in a node based project, re-implements the text input, then pops up a "Would you like to reformat references using node-mv?" question to decide whether to call node-mv or pass the rename/move back to SideBarEnhancements.

dantman avatar Feb 26 '15 22:02 dantman