[typescript] Better paths matching for move to existing file quickpick#181231
[typescript] Better paths matching for move to existing file quickpick#181231mjbvz merged 6 commits intomicrosoft:mainfrom
Conversation
mjbvz
left a comment
There was a problem hiding this comment.
Thanks for looking into this. Looks like a nice addition but a few things look into before this can be merged
| const filename = Utils.basename(uri); | ||
|
|
||
| let description; | ||
| const filterQuery = ['./', '../'].find(str => quickPick.value.startsWith(str)); |
There was a problem hiding this comment.
On windows, paths will use \ instead. If possible though, it would be nice to support letting users type either ../ or ..\ on windows to access parent directories
There was a problem hiding this comment.
Yes, of course it is possible, not a big deal. Just didn't add support for it in the first place as never had to use \ in VS Code
| const quickPick = vscode.window.createQuickPick(); | ||
| const body = response.body; | ||
| const updateItems = () => { | ||
| const destinationItems = body.files.map((file): DestinationItem | undefined => { |
There was a problem hiding this comment.
This should be optimized to not compute anything if the user has not typed ./ or ../ to start the path
extensions/typescript-language-features/src/languageFeatures/refactor.ts
Outdated
Show resolved
Hide resolved
extensions/typescript-language-features/src/languageFeatures/refactor.ts
Show resolved
Hide resolved
use coalesce
|
By the way last time I tried it in insiders, I did see move to file code action (TS server didn't see interactive arg). Does it work on your end? Update: I see it also works in latest insiders, my bad |
It's an improvement for #178535.
Moving statements to a sibling file is pretty common. In my case, I have nested file structure (5-6 levels deep) and it's hard to do this with current quickpick implementation, so I added simple filtering for
./and../values. Now it can be done much faster than with a native file picker.Summarized:
matchOnDescriptionshowQuickPicktocreateQuickPickAPI to implement relative path logic