fix: reopens files that were opened when dragging and dropping files or folders#1704
fix: reopens files that were opened when dragging and dropping files or folders#1704tarikutk wants to merge 6 commits into
Conversation
611c04f to
5d54593
Compare
5d54593 to
802bd3b
Compare
There was a problem hiding this comment.
Pull Request Overview
This PR fixes file reopening behavior when dragging and dropping files or folders in the Content Navigator. It ensures that previously opened files are reopened at their new locations after a move operation, and prevents VSCode from incorrectly opening folders as files.
Key Changes:
- Modified the
moveTohandling logic to track closed files as an array instead of a boolean - Added a new
calculateNewFileUrimethod to compute new URIs for files that were moved - Implemented logic to reopen all previously opened files after a successful move operation
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
82a3dc9 to
af2da9a
Compare
|
Hey @tarikutk . Is there a github issue associated with this PR? Or rather, what issue is this solving? |
| isContainer as getIsContainer, | ||
| } from "./utils"; | ||
|
|
||
| const SAS_FILE_SEPARATOR = "~fs~"; |
There was a problem hiding this comment.
Fwiw, this is sas server specific. Anything that is specific to connection type should happen in the adapter if possible.
There was a problem hiding this comment.
okay. I updated that. I am importing from the adapter instead.
yes @scottdover, there is a GitHub issue associated with it. I attached the link now in the PR message. it is #1478. |
|
Sorry for the delay in getting back to this one. At a high level, this is how the code is structured w/r/t file access.
Your implementation has itc ( |
8d2e0f0 to
49b6eeb
Compare
|
I updated @scottdover . |
|
the commit for itcServerAdapter is something which I was not able to test. and the last one is just to fix typescript issues. please let me know if itcServerAdapter works and if the fix for typescript breaks things. I will revert those if needed. Thanks |
| item: ContentItem, | ||
| targetParentFolderUri: string, | ||
| ) => Promise<Uri | undefined>; | ||
| calculateNewFileUri?: ( |
There was a problem hiding this comment.
Should this be optional? It should if this isn't an issue that affects SAS content. If it does impact sas content, I would expect to see changes in RestContentAdapter as well
Also, super nitpicky, but these functions for this type are all alphabetized. Will you alphabetize this new function?
There was a problem hiding this comment.
yes. I think it should be optional. restContentAdapter is not calling it at all because closeFileIfOpen is returning true rather than array of closed files for restContentAdapter.
| } | ||
| } | ||
|
|
||
| public calculateNewFileUri( |
There was a problem hiding this comment.
It feels like there's a lot of duplication between this and the rest server adapter implementation. From what I could tell, the three pieces that are unique for this function and the other are:
- How directory separators are determined
- how to extractPathFromUri
- how to generateNewFilePath (basically, lines 352-371 here, 482-505 in the other file)
With that in mind, I'm wondering if this method can look more like this...
const extractPathFromUri = (uri: string) => {
/* process things */
return '';
};
const getDirectorySeparator = (basePath: string) => {
/*
use getDirectorySeparator in ItcServerAdapter, or return
the separator for rest
*/
};
const generateNewFilePath = (
oldBasePath: string,
closedFilePath: string,
newItemUri: Uri
) => {
/* Do specific calculation for ITC or REST */
};
return calculateNewFileUri(
extractPathFromUri,
getDirectorySeparator,
generateNewFilePath,
);
With the above, extractPathFromUri, getDirectorySeparator, and generateNewFilePath are unique for ItcServerAdapter or RestServerAdapter are unique, while the code moved to a shared calculateNewFileUri function would contain the duplicated bits (NOTE: This is an oversimplification to some extent and there may need to be more parameters passed into the shared function)
There was a problem hiding this comment.
I broke down the functions to utils instead of passing those functions as a prop. passing 6 parameters and passing 3 of them back to those functions was not looking good. I added them in utils of a specific adapter instead.
49b6eeb to
e2db22e
Compare
…or folders Signed-off-by: tariku <tarikutadese24@gmail.com>
Signed-off-by: tariku <tarikutadese24@gmail.com>
Signed-off-by: tariku <tarikutadese24@gmail.com>
Signed-off-by: tariku <tarikutadese24@gmail.com>
Signed-off-by: tariku <tarikutadese24@gmail.com>
Signed-off-by: tariku <tarikutadese24@gmail.com>
Summary:
Testing:
verified it opens previously opened files instead of opening a folder as a file.
Fixes #1478