diff --git a/packages/zowe-explorer/__tests__/__unit__/dataset/actions.unit.test.ts b/packages/zowe-explorer/__tests__/__unit__/dataset/actions.unit.test.ts index 3ac7da94f5..6462414f16 100644 --- a/packages/zowe-explorer/__tests__/__unit__/dataset/actions.unit.test.ts +++ b/packages/zowe-explorer/__tests__/__unit__/dataset/actions.unit.test.ts @@ -1501,7 +1501,6 @@ describe("Dataset Actions Unit Tests - Function saveFile", () => { (testDocument as any).fileName = path.join(globals.DS_DIR, testDocument.fileName); const logSpy = jest.spyOn(ZoweLogger, "warn"); const commandSpy = jest.spyOn(vscode.commands, "executeCommand"); - const applyEditSpy = jest.spyOn(vscode.workspace, "applyEdit"); jest.spyOn(fs, "statSync").mockReturnValueOnce({ size: 0 } as any); await dsActions.saveFile(testDocument, blockMocks.testDatasetTree); @@ -1509,10 +1508,8 @@ describe("Dataset Actions Unit Tests - Function saveFile", () => { expect(logSpy).toBeCalledWith("Remote file has changed. Presenting with way to resolve file."); expect(mocked(sharedUtils.concatChildNodes)).toBeCalled(); expect(commandSpy).toBeCalledWith("workbench.files.action.compareWithSaved"); - expect(applyEditSpy).toHaveBeenCalledTimes(2); logSpy.mockClear(); commandSpy.mockClear(); - applyEditSpy.mockClear(); }); }); diff --git a/packages/zowe-explorer/i18n/sample/package.i18n.json b/packages/zowe-explorer/i18n/sample/package.i18n.json index cf533d932a..ef8728b452 100644 --- a/packages/zowe-explorer/i18n/sample/package.i18n.json +++ b/packages/zowe-explorer/i18n/sample/package.i18n.json @@ -159,7 +159,7 @@ "ds.selectSortOpt": "Select a sorting option for {0}", "jobs.selectSortOpt": "Select a sorting option for jobs in {0}", "ds.filterBy": "Filter PDS members...", - "ds.sortBy": "Sort PDS members..." + "ds.sortBy": "Sort PDS members...", "selectForCompare": "Select for Compare", "compareWithSelected": "Compare with Selected", "compareWithSelectedReadOnly": "Compare with Selected (Read-Only)", diff --git a/packages/zowe-explorer/i18n/sample/src/uss/actions.i18n.json b/packages/zowe-explorer/i18n/sample/src/uss/actions.i18n.json index e339bd8d20..af4d5fc0cb 100644 --- a/packages/zowe-explorer/i18n/sample/src/uss/actions.i18n.json +++ b/packages/zowe-explorer/i18n/sample/src/uss/actions.i18n.json @@ -13,7 +13,6 @@ "deleteUssPrompt.confirmation.cancel.log.debug": "Delete action was canceled.", "ZoweUssNode.copyDownload.progress": "Copying file structure...", "uss.paste.apiNotAvailable": "The paste operation is not supported for this node.", - "ZoweUssNode.copyUpload.progress": "Pasting files..." "ZoweUssNode.copyUpload.progress": "Pasting files...", "downloadUnixFile.invalidNode.error": "open() called from invalid node.", "downloadUnixFile.name.exists": "There is already a file with the same name. Please change your OS file system settings if you want to give case sensitive file names", diff --git a/packages/zowe-explorer/package.nls.json b/packages/zowe-explorer/package.nls.json index cf533d932a..ef8728b452 100644 --- a/packages/zowe-explorer/package.nls.json +++ b/packages/zowe-explorer/package.nls.json @@ -159,7 +159,7 @@ "ds.selectSortOpt": "Select a sorting option for {0}", "jobs.selectSortOpt": "Select a sorting option for jobs in {0}", "ds.filterBy": "Filter PDS members...", - "ds.sortBy": "Sort PDS members..." + "ds.sortBy": "Sort PDS members...", "selectForCompare": "Select for Compare", "compareWithSelected": "Compare with Selected", "compareWithSelectedReadOnly": "Compare with Selected (Read-Only)", diff --git a/packages/zowe-explorer/src/globals.ts b/packages/zowe-explorer/src/globals.ts index 964c52859e..4400f70edb 100644 --- a/packages/zowe-explorer/src/globals.ts +++ b/packages/zowe-explorer/src/globals.ts @@ -35,7 +35,7 @@ export let DS_DIR: string; export let CONFIG_PATH; // set during activate export let ISTHEIA = false; // set during activate export let LOG: imperative.Logger; -export const COMMAND_COUNT = 115; +export const COMMAND_COUNT = 119; export const MAX_SEARCH_HISTORY = 5; export const MAX_FILE_HISTORY = 10; export const MS_PER_SEC = 1000; diff --git a/packages/zowe-explorer/src/job/actions.ts b/packages/zowe-explorer/src/job/actions.ts index 98b886dedb..e3cef45c35 100644 --- a/packages/zowe-explorer/src/job/actions.ts +++ b/packages/zowe-explorer/src/job/actions.ts @@ -19,7 +19,7 @@ import { Job, Spool } from "./ZoweJobNode"; import * as nls from "vscode-nls"; import SpoolProvider, { encodeJobFile, getSpoolFiles, matchSpool } from "../SpoolProvider"; import { ZoweLogger } from "../utils/LoggerUtils"; -import { SORT_DIRS, getDefaultUri } from "../shared/utils"; +import { SORT_DIRS } from "../shared/utils"; import { ZosJobsProvider } from "./ZosJobsProvider"; import { JOB_SORT_OPTS } from "./utils"; import * as globals from "../globals"; diff --git a/packages/zowe-explorer/src/shared/utils.ts b/packages/zowe-explorer/src/shared/utils.ts index 582568ee76..7d2d745f02 100644 --- a/packages/zowe-explorer/src/shared/utils.ts +++ b/packages/zowe-explorer/src/shared/utils.ts @@ -11,11 +11,9 @@ // Generic utility functions related to all node types. See ./src/utils.ts for other utility functions. -import * as fs from "fs"; import * as vscode from "vscode"; import * as path from "path"; import * as globals from "../globals"; -import * as os from "os"; import { Gui, IZoweTreeNode, IZoweNodeType, IZoweDatasetTreeNode, IZoweUSSTreeNode, IZoweJobTreeNode } from "@zowe/zowe-explorer-api"; import { ZoweExplorerApiRegister } from "../ZoweExplorerApiRegister"; import * as nls from "vscode-nls"; @@ -343,71 +341,3 @@ export function jobStringValidator(text: string, localizedParam: "owner" | "pref return text.length > globals.JOBS_MAX_PREFIX ? localize("searchJobs.prefix.invalid", "Invalid job prefix") : null; } } - -export function getDefaultUri(): vscode.Uri { - return vscode.workspace.workspaceFolders?.[0]?.uri ?? vscode.Uri.file(os.homedir()); -} - -/** - * Function that triggers compare of the old and new document in the active editor - * @param {vscode.TextDocument} doc - document to update and compare with previous content - * @param {IZoweDatasetTreeNode | IZoweUSSTreeNode} node - IZoweTreeNode - * @param {string} label - {optional} used by IZoweDatasetTreeNode to getContents of file - * @param {boolean} binary - {optional} used by IZoweUSSTreeNode to getContents of file - * @param {imperative.IProfileLoaded} profile - {optional} - * @returns {Promise} - */ -export async function compareFileContent( - doc: vscode.TextDocument, - node: IZoweDatasetTreeNode | IZoweUSSTreeNode, - label?: string, - binary?: boolean, - profile?: imperative.IProfileLoaded -): Promise { - await markDocumentUnsaved(doc); - const prof = node ? node.getProfile() : profile; - let downloadResponse; - - if (isTypeUssTreeNode(node)) { - downloadResponse = await ZoweExplorerApiRegister.getUssApi(prof).getContents(node.fullPath, { - file: node.getUSSDocumentFilePath(), - binary, - returnEtag: true, - encoding: prof.profile?.encoding, - responseTimeout: prof.profile?.responseTimeout, - }); - } else { - downloadResponse = await ZoweExplorerApiRegister.getMvsApi(prof).getContents(label, { - file: doc.fileName, - returnEtag: true, - encoding: prof.profile?.encoding, - responseTimeout: prof.profile?.responseTimeout, - }); - } - - // If local and remote file size are the same, then VS Code won't detect - // there is a conflict and remote changes may get overwritten. To work - // around this limitation of VS Code, when the sizes are identical we - // temporarily add a trailing newline byte to the local copy which forces - // the file size to be different. This is a terrible hack but it works. - // See https://github.com/microsoft/vscode/issues/119002 - const oldSize = doc.getText().length; - const newSize = fs.statSync(doc.fileName).size; - if (newSize === oldSize) { - const edits = new vscode.WorkspaceEdit(); - edits.insert(doc.uri, doc.positionAt(oldSize), doc.eol.toString()); - await vscode.workspace.applyEdit(edits); - } - ZoweLogger.warn(localize("saveFile.etagMismatch.log.warning", "Remote file has changed. Presenting with way to resolve file.")); - await vscode.commands.executeCommand("workbench.files.action.compareWithSaved"); - if (newSize === oldSize) { - const edits2 = new vscode.WorkspaceEdit(); - edits2.delete(doc.uri, new vscode.Range(doc.positionAt(oldSize), doc.positionAt(oldSize + doc.eol.toString().length))); - await vscode.workspace.applyEdit(edits2); - } - // re-assign etag, so that it can be used with subsequent requests - const downloadEtag = downloadResponse?.apiResponse?.etag; - if (node && downloadEtag !== node.getEtag()) { - node.setEtag(downloadEtag); - } -} \ No newline at end of file