Skip to content

Commit

Permalink
fix(fsp): Do not fetch changes during conflict; use custom context val
Browse files Browse the repository at this point in the history
Signed-off-by: Trae Yelovich <trae.yelovich@broadcom.com>
  • Loading branch information
traeok committed Aug 30, 2024
1 parent a9b0ec8 commit 60ff771
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 7 deletions.
13 changes: 10 additions & 3 deletions packages/zowe-explorer-api/src/fs/BaseProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ export class BaseProvider {
public onDidChangeFile: vscode.Event<vscode.FileChangeEvent[]> = this._onDidChangeFileEmitter.event;
protected root: DirEntry;
public openedUris: vscode.Uri[] = [];
public onDocClosedEventDisposable: vscode.Disposable = null;

protected constructor() {}

Expand Down Expand Up @@ -296,14 +297,19 @@ export class BaseProvider {

// This event removes the "diff view" flag from the local file,
// so that API calls can continue after the conflict dialog is closed.
private static onCloseEvent(provider: BaseProvider, e: vscode.TextDocument): void {
private static onCloseEvent(this: BaseProvider, e: vscode.TextDocument): void {

Check warning on line 300 in packages/zowe-explorer-api/src/fs/BaseProvider.ts

View check run for this annotation

Codecov / codecov/patch

packages/zowe-explorer-api/src/fs/BaseProvider.ts#L300

Added line #L300 was not covered by tests
if (e.uri.query && e.uri.scheme.startsWith("zowe-")) {
const queryParams = new URLSearchParams(e.uri.query);
if (queryParams.has("conflict")) {
const fsEntry = provider._lookupAsFile(e.uri, { silent: true });
const fsEntry = this._lookupAsFile(e.uri, { silent: true });

Check warning on line 304 in packages/zowe-explorer-api/src/fs/BaseProvider.ts

View check run for this annotation

Codecov / codecov/patch

packages/zowe-explorer-api/src/fs/BaseProvider.ts#L304

Added line #L304 was not covered by tests
if (fsEntry) {
fsEntry.inDiffView = false;
}

if (vscode.window.visibleTextEditors.every((editor) => !editor.document.uri.query.includes("conflict=true"))) {
vscode.commands.executeCommand("setContext", "zowe.vscode-extension-for-zowe.inConflict", false);
this.onDocClosedEventDisposable.dispose();

Check warning on line 311 in packages/zowe-explorer-api/src/fs/BaseProvider.ts

View check run for this annotation

Codecov / codecov/patch

packages/zowe-explorer-api/src/fs/BaseProvider.ts#L310-L311

Added lines #L310 - L311 were not covered by tests
}
}
}
}
Expand Down Expand Up @@ -332,13 +338,14 @@ export class BaseProvider {

// User selected "Compare", show diff with local contents and LPAR contents
if (userSelection === conflictOptions[0]) {
vscode.workspace.onDidCloseTextDocument(BaseProvider.onCloseEvent.bind(this));
await vscode.commands.executeCommand("setContext", "zowe.vscode-extension-for-zowe.inConflict", true);
await vscode.commands.executeCommand(
"vscode.diff",
uri.with({ query: "conflict=true" }),
uri.with({ query: "inDiff=true" }),
`${entry.name} (Remote) ↔ ${entry.name}`
);
this.onDocClosedEventDisposable = vscode.workspace.onDidCloseTextDocument(BaseProvider.onCloseEvent.bind(this));
return ConflictViewSelection.Compare;
}

Expand Down
4 changes: 2 additions & 2 deletions packages/zowe-explorer/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -684,12 +684,12 @@
{
"command": "zowe.diff.useLocalContent",
"group": "navigation@0",
"when": "resourceScheme =~ /zowe-.*/ && isInDiffEditor"
"when": "resourceScheme =~ /zowe-.*/ && isInDiffEditor && zowe.vscode-extension-for-zowe.inConflict"
},
{
"command": "zowe.diff.useRemoteContent",
"group": "navigation@1",
"when": "resourceScheme =~ /zowe-.*/ && isInDiffEditor"
"when": "resourceScheme =~ /zowe-.*/ && isInDiffEditor && zowe.vscode-extension-for-zowe.inConflict"
}
],
"view/title": [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,8 @@ export class DatasetFSProvider extends BaseProvider implements vscode.FileSystem
const queryParams = new URLSearchParams(uri.query);
if (queryParams.has("conflict")) {
return { ...this.lookup(uri, false), permissions: vscode.FilePermission.Readonly };
} else if (queryParams.has("inDiff")) {
return this.lookup(uri, false);

Check warning on line 99 in packages/zowe-explorer/src/trees/dataset/DatasetFSProvider.ts

View check run for this annotation

Codecov / codecov/patch

packages/zowe-explorer/src/trees/dataset/DatasetFSProvider.ts#L99

Added line #L99 was not covered by tests
}
isFetching = queryParams.has("fetch") && queryParams.get("fetch") === "true";
}
Expand Down Expand Up @@ -389,7 +391,7 @@ export class DatasetFSProvider extends BaseProvider implements vscode.FileSystem
const isConflict = urlQuery.has("conflict");

// we need to fetch the contents from the mainframe if the file hasn't been accessed yet
if (!file.wasAccessed || isConflict) {
if ((!file.wasAccessed && !urlQuery.has("inDiff")) || isConflict) {
await this.fetchDatasetAtUri(uri, { isConflict });
if (!isConflict) {
file.wasAccessed = true;
Expand Down
4 changes: 3 additions & 1 deletion packages/zowe-explorer/src/trees/uss/UssFSProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,8 @@ export class UssFSProvider extends BaseProvider implements vscode.FileSystemProv
const queryParams = new URLSearchParams(uri.query);
if (queryParams.has("conflict")) {
return { ...this.lookup(uri, false), permissions: vscode.FilePermission.Readonly };
} else if (queryParams.has("inDiff")) {
return this.lookup(uri, false);

Check warning on line 71 in packages/zowe-explorer/src/trees/uss/UssFSProvider.ts

View check run for this annotation

Codecov / codecov/patch

packages/zowe-explorer/src/trees/uss/UssFSProvider.ts#L71

Added line #L71 was not covered by tests
}
isFetching = queryParams.has("fetch") && queryParams.get("fetch") === "true";
}
Expand Down Expand Up @@ -315,7 +317,7 @@ export class UssFSProvider extends BaseProvider implements vscode.FileSystemProv
// Fetch contents from the mainframe if:
// - the file hasn't been accessed yet
// - fetching a conflict from the remote FS
if (!file.wasAccessed || isConflict) {
if ((!file.wasAccessed && !urlQuery.has("inDiff")) || isConflict) {
await this.fetchFileAtUri(uri, { isConflict });
if (!isConflict) {
file.wasAccessed = true;
Expand Down

0 comments on commit 60ff771

Please sign in to comment.