Skip to content
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

Add ability to refresh the currently focused remote file #408

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -283,6 +283,15 @@
"light": "resources/light/refresh.svg",
"dark": "resources/dark/refresh.svg"
}
},
{
"command": "sftp.remoteExplorer.refreshActiveFile",
"title": "Refresh Active Remote File",
"category": "SFTP",
"icon": {
"light": "resources/light/refresh.svg",
"dark": "resources/dark/refresh.svg"
}
}
],
"menus": {
Expand Down Expand Up @@ -527,6 +536,13 @@
"when": "sftp.enabled && resourceScheme == remote"
}
],
"editor/title": [
{
"command": "sftp.remoteExplorer.refreshActiveFile",
"group": "navigation",
"when": "sftp.enabled && resourceScheme == remote"
}
],
"editor/title/context": [
{
"command": "sftp.revealInExplorer",
Expand Down
1 change: 1 addition & 0 deletions src/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ export const COMMAND_REVEAL_IN_EXPLORER = 'sftp.revealInExplorer';
export const COMMAND_REVEAL_IN_REMOTE_EXPLORER = 'sftp.revealInRemoteExplorer';

export const COMMAND_REMOTEEXPLORER_REFRESH = 'sftp.remoteExplorer.refresh';
export const COMMAND_REMOTEEXPLORER_REFRESH_ACTIVE_FILE = "sftp.remoteExplorer.refreshActiveFile"
export const COMMAND_REMOTEEXPLORER_EDITINLOCAL = 'sftp.remoteExplorer.editInLocal';
export const COMMAND_REMOTEEXPLORER_VIEW_CONTENT = 'sftp.viewContent';

Expand Down
25 changes: 25 additions & 0 deletions src/modules/remoteExplorer/explorer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import * as vscode from 'vscode';
import { registerCommand } from '../../host';
import {
COMMAND_REMOTEEXPLORER_REFRESH,
COMMAND_REMOTEEXPLORER_REFRESH_ACTIVE_FILE,
COMMAND_REMOTEEXPLORER_VIEW_CONTENT,
} from '../../constants';
import { UResource } from '../../core';
Expand All @@ -27,6 +28,7 @@ export default class RemoteExplorer {
});

registerCommand(context, COMMAND_REMOTEEXPLORER_REFRESH, () => this._refreshSelection());
registerCommand(context, COMMAND_REMOTEEXPLORER_REFRESH_ACTIVE_FILE, () => this._refreshActiveRemoteFile());
registerCommand(context, COMMAND_REMOTEEXPLORER_VIEW_CONTENT, (item: ExplorerItem) =>
this._treeDataProvider.showItem(item)
);
Expand Down Expand Up @@ -74,4 +76,27 @@ export default class RemoteExplorer {
this.refresh();
}
}

private _refreshActiveRemoteFile() {
const focusedEditor = vscode.window.activeTextEditor;
if (focusedEditor) {

const remoteFileUri = focusedEditor.document.uri;
const root = this._treeDataProvider.findRoot(remoteFileUri);
const incompleteResource = UResource.makeResource(remoteFileUri);

if (!root) {
return;
}
const remoteFileItem = {
resource: UResource.updateResource(root.resource, {
remotePath: incompleteResource.fsPath
}),
isDirectory: false
};

this.refresh(remoteFileItem);
}

}
}