Skip to content

fix: reopens files that were opened when dragging and dropping files or folders#1704

Open
tarikutk wants to merge 6 commits into
sassoftware:mainfrom
tarikutk:fix/drag/drop
Open

fix: reopens files that were opened when dragging and dropping files or folders#1704
tarikutk wants to merge 6 commits into
sassoftware:mainfrom
tarikutk:fix/drag/drop

Conversation

@tarikutk

@tarikutk tarikutk commented Nov 19, 2025

Copy link
Copy Markdown
Contributor

Summary:

  1. it opens previously opened files when dragging and dropping a file or a folder.
  2. it prevents VSCode from opening a folder as a file when moving a folder from one folder to another folder. it instead opens the file that was opened in that folder

Testing:
verified it opens previously opened files instead of opening a folder as a file.

Fixes #1478

@tarikutk tarikutk changed the title fix: opens closed file not the folder in drag/drop fix: reopens files that were opened when dragging and dropping files or folders Nov 19, 2025
@tarikutk
tarikutk marked this pull request as ready for review November 20, 2025 04:03

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 moveTo handling logic to track closed files as an array instead of a boolean
  • Added a new calculateNewFileUri method 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.

Comment thread client/src/components/ContentNavigator/ContentDataProvider.ts Outdated
Comment thread client/src/components/ContentNavigator/ContentDataProvider.ts Outdated
Comment thread client/src/components/ContentNavigator/ContentDataProvider.ts Outdated
Comment thread client/src/components/ContentNavigator/ContentDataProvider.ts
Comment thread client/src/components/ContentNavigator/ContentDataProvider.ts Outdated
Comment thread client/src/components/ContentNavigator/ContentDataProvider.ts Outdated
Comment thread client/src/components/ContentNavigator/ContentDataProvider.ts Outdated
Comment thread client/src/components/ContentNavigator/ContentDataProvider.ts Outdated
Comment thread client/src/components/ContentNavigator/ContentDataProvider.ts Outdated
Comment thread client/src/components/ContentNavigator/ContentDataProvider.ts Outdated
@scottdover

Copy link
Copy Markdown
Contributor

Hey @tarikutk . Is there a github issue associated with this PR? Or rather, what issue is this solving?

Comment thread client/src/components/ContentNavigator/ContentDataProvider.ts Outdated
Comment thread client/src/components/ContentNavigator/ContentDataProvider.ts Outdated
@tarikutk

tarikutk commented Dec 8, 2025

Copy link
Copy Markdown
Contributor Author

Hey @tarikutk . Is there a github issue associated with this PR? Or rather, what issue is this solving?

yes @scottdover, there is a GitHub issue associated with it. I attached the link now in the PR message. it is #1478.

@tarikutk
tarikutk requested a review from scottdover December 8, 2025 01:41
@scottdover

scottdover commented Jan 15, 2026

Copy link
Copy Markdown
Contributor

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.

  • ContentDataProvider exposes the data view to the ui via a treeview
  • ContentModel is responsible for handling the business logic related to file CRUD operations
  • ContentAdapter is an interface that defines the specific methods used in ContentModel to provide data back to the user
  • There are a few implementations of ContentAdapter
    • ItcServerAdapter: For server files via an itc connection
    • RestServerAdapter: For server files via a rest (viya) connection
    • RestContentAdapter: For sas content via a rest (viya) connection

Your implementation has itc (relativePath.replace(/^~fs~/, "") as an example) & rest specific code (/(\/files\/[^&]*)/ as an example) in ContentDataProvider. Any code that is specific to a certain connection type should be nested in the relevant adapter.

@tarikutk
tarikutk force-pushed the fix/drag/drop branch 2 times, most recently from 8d2e0f0 to 49b6eeb Compare February 18, 2026 12:24
@tarikutk

Copy link
Copy Markdown
Contributor Author

I updated @scottdover .

@tarikutk

Copy link
Copy Markdown
Contributor Author

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

@scottdover
scottdover requested review from smorrisj and removed request for kpatl1 February 20, 2026 18:28
Comment thread client/src/components/ContentNavigator/ContentDataProvider.ts Outdated
Comment thread client/src/components/ContentNavigator/ContentDataProvider.ts Outdated
Comment thread client/src/components/ContentNavigator/types.ts Outdated
Comment thread client/src/connection/itc/ItcServerAdapter.ts
tarikutk added 6 commits March 9, 2026 15:12
…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>

@scottdover scottdover left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is looking a lot better...just a few minor things.

Comment on lines +683 to +685
const newFileUri = this.model
.getAdapter()
.calculateNewFileUri?.(closedFileUri, item, newUri);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Calls to adapter methods should be contained within a ContentModel (i.e. this should be this.model.calculateNewFileUri). It doesn't look like we expose adapter in any other content data provider methods.


export const extractPathFromUri = (uri: string): string => {
try {
const queryStart = uri.indexOf("?");

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nitpick. We're doing this indexOf query param check here and below. Creating a small shared function to handle this functionality would prevent us from repeating ourselves.

oldBasePath: string,
closedFilePath: string,
newItemUri: Uri,
dirSeparator: string,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's no need to pass this in as a parameter. The function is available to call just above this one.

Comment on lines +95 to +100
const queryStart = uri.indexOf("?");
if (queryStart === -1) {
return "";
}

const queryString = uri.substring(queryStart + 1);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seeing this behavior once more...if this behavior is shared across multiple connection types, a suitable place to define a helper function may be in client/src/connection/util

const decodedQuery = decodeURIComponent(queryMatch[1]);
const newQuery = decodedQuery.replace(
/(\/files\/[^&]*)/,
`$1~fs~${filename}`,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would it be possible to use SAS_FILE_SEPARATOR here and above (you'll likely need to change that to new RegExp(...)) instead of hard coding this?

@tarikutk tarikutk self-assigned this Jul 15, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

File folder will be opened as a file when drag/drop it to a new position on SAS SERVER

3 participants