From ac442aa0e0b8c42e2bc336666e97dab8f7b5b8ea Mon Sep 17 00:00:00 2001 From: Julia Yan Date: Wed, 8 May 2024 19:08:07 -0400 Subject: [PATCH 01/10] Add a refresh file button to the editor --- package.json | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/package.json b/package.json index c13d6e0e4..205d9b3bd 100644 --- a/package.json +++ b/package.json @@ -1630,7 +1630,13 @@ "category": "IBM i", "icon": "$(settings-gear)", "enablement": "!code-for-ibmi:debugWorking" - } + }, + { + "command": "workbench.action.files.revert", + "title": "Refresh File", + "category": "IBM i", + "icon": "$(refresh)" + } ], "keybindings": [ { @@ -2325,6 +2331,11 @@ "command": "code-for-ibmi.clearDiagnostics", "when": "code-for-ibmi:connected", "group": "navigation@3" + }, + { + "command": "workbench.action.files.revert", + "when": "code-for-ibmi:connected && resourceScheme == streamfile", + "group": "navigation@4" } ], "view/item/context": [ From 28dab83d632ae54d180e59bf85d027661bf93871 Mon Sep 17 00:00:00 2001 From: Julia Yan Date: Wed, 8 May 2024 19:19:43 -0400 Subject: [PATCH 02/10] Added contribution link --- CONTRIBUTING.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 218172f7b..7330dc464 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -53,4 +53,5 @@ Thanks so much to everyone [who has contributed](https://github.com/codefori/vsc * [@ThePrez](https://github.com/ThePrez) * [@BoykaZhu](https://github.com/BoykaZhu) * [@krka01](https://github.com/krka01) -* [@william-xiang](https://github.com/william-xiang) \ No newline at end of file +* [@william-xiang](https://github.com/william-xiang) +* [@julesyan](https://github.com/julesyan) \ No newline at end of file From 6c39b5d224f37d6678dd4af5bcce516232b18e23 Mon Sep 17 00:00:00 2001 From: Julia Yan Date: Thu, 9 May 2024 10:16:26 -0400 Subject: [PATCH 03/10] Update refresh file to include members --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 205d9b3bd..7e18b60e4 100644 --- a/package.json +++ b/package.json @@ -2334,7 +2334,7 @@ }, { "command": "workbench.action.files.revert", - "when": "code-for-ibmi:connected && resourceScheme == streamfile", + "when": "code-for-ibmi:connected && (resourceScheme == streamfile || resourceScheme == member)", "group": "navigation@4" } ], From 297407c9cfb0e22e1cbb036fbae6e069e3d9e518 Mon Sep 17 00:00:00 2001 From: Julia Yan Date: Sat, 11 May 2024 13:43:30 -0400 Subject: [PATCH 04/10] Add warning dialog before refreshing file when changes have not been saved --- package.json | 4 ++-- src/instantiate.ts | 15 ++++++++++++++- 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/package.json b/package.json index 7e18b60e4..088780318 100644 --- a/package.json +++ b/package.json @@ -1632,7 +1632,7 @@ "enablement": "!code-for-ibmi:debugWorking" }, { - "command": "workbench.action.files.revert", + "command": "code-for-ibmi.refreshFile", "title": "Refresh File", "category": "IBM i", "icon": "$(refresh)" @@ -2333,7 +2333,7 @@ "group": "navigation@3" }, { - "command": "workbench.action.files.revert", + "command": "code-for-ibmi.refreshFile", "when": "code-for-ibmi:connected && (resourceScheme == streamfile || resourceScheme == member)", "group": "navigation@4" } diff --git a/src/instantiate.ts b/src/instantiate.ts index 86df5a831..523f1a94b 100644 --- a/src/instantiate.ts +++ b/src/instantiate.ts @@ -700,7 +700,20 @@ export async function loadAllofExtension(context: vscode.ExtensionContext) { vscode.commands.executeCommand(`code-for-ibmi.openEditable`, item.path, { readonly }); }), vscode.commands.registerCommand("code-for-ibmi.updateConnectedBar", updateConnectedBar), - ); + + vscode.commands.registerCommand("code-for-ibmi.refreshFile", async () => { + const editor = vscode.window.activeTextEditor; + if (editor?.document.isDirty) { + vscode.window + .showWarningMessage(`Your changes will be discarded`, `Continue`, `Cancel`) + .then(result => { + if (result === `Continue`) { + vscode.commands.executeCommand(`workbench.action.files.revert`); + } + }); + } + }), +); ActionsUI.initialize(context); VariablesUI.initialize(context); From 97f7c62a561bc021612766c016c41c4be5a97708 Mon Sep 17 00:00:00 2001 From: Julia Yan Date: Mon, 13 May 2024 10:05:14 -0400 Subject: [PATCH 05/10] Make better use of incoming params --- src/api/Tools.ts | 7 ++++++- src/instantiate.ts | 29 +++++++++++++++++++---------- 2 files changed, 25 insertions(+), 11 deletions(-) diff --git a/src/api/Tools.ts b/src/api/Tools.ts index bb6f93682..eb19e4e2a 100644 --- a/src/api/Tools.ts +++ b/src/api/Tools.ts @@ -292,9 +292,14 @@ export namespace Tools { * Without this, it's possible for the same document to be opened twice simply due to the readonly flag. */ export function findExistingDocumentUri(uri: vscode.Uri) { + const possibleDoc = findExistingDocument(uri); + return possibleDoc?.uri || uri; + } + + export function findExistingDocument(uri: vscode.Uri) { const baseUriString = uriStringWithoutFragment(uri); const possibleDoc = vscode.workspace.textDocuments.find(document => uriStringWithoutFragment(document.uri) === baseUriString); - return possibleDoc?.uri || uri; + return possibleDoc; } /** diff --git a/src/instantiate.ts b/src/instantiate.ts index 523f1a94b..98f2ddd4e 100644 --- a/src/instantiate.ts +++ b/src/instantiate.ts @@ -701,17 +701,26 @@ export async function loadAllofExtension(context: vscode.ExtensionContext) { }), vscode.commands.registerCommand("code-for-ibmi.updateConnectedBar", updateConnectedBar), - vscode.commands.registerCommand("code-for-ibmi.refreshFile", async () => { + vscode.commands.registerCommand("code-for-ibmi.refreshFile", async (uri?: vscode.Uri) => { + let doc: vscode.TextDocument | undefined; + if (uri) { + doc = Tools.findExistingDocument(uri); + } else { const editor = vscode.window.activeTextEditor; - if (editor?.document.isDirty) { - vscode.window - .showWarningMessage(`Your changes will be discarded`, `Continue`, `Cancel`) - .then(result => { - if (result === `Continue`) { - vscode.commands.executeCommand(`workbench.action.files.revert`); - } - }); - } + doc = editor?.document; + } + + if (doc?.isDirty) { + vscode.window + .showWarningMessage(`Your changes will be discarded`, `Continue`, `Cancel`) + .then(result => { + if (result === `Continue`) { + vscode.commands.executeCommand(`workbench.action.files.revert`); + } + }); + } else { + vscode.commands.executeCommand(`workbench.action.files.revert`); + } }), ); From d85b7b04f23ea72e223d14e8ba2c1c01ced4f139 Mon Sep 17 00:00:00 2001 From: Julia Yan Date: Mon, 13 May 2024 10:06:50 -0400 Subject: [PATCH 06/10] Fix formatting --- package.json | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/package.json b/package.json index 0297b54e9..9eafd03e2 100644 --- a/package.json +++ b/package.json @@ -1631,11 +1631,11 @@ "icon": "$(settings-gear)", "enablement": "!code-for-ibmi:debugWorking" }, - { - "command": "code-for-ibmi.refreshFile", - "title": "Refresh File", - "category": "IBM i", - "icon": "$(refresh)" + { + "command": "code-for-ibmi.refreshFile", + "title": "Refresh File", + "category": "IBM i", + "icon": "$(refresh)" }, { "command": "code-for-ibmi.searchObjectBrowser", @@ -1650,7 +1650,7 @@ "category": "IBM i", "icon": "$(search-fuzzy)", "enablement": "code-for-ibmi:connected" - } + } ], "keybindings": [ { From 478a67b843e24e3946cfa5689ab2de6900296003 Mon Sep 17 00:00:00 2001 From: Julia Yan Date: Tue, 14 May 2024 09:41:01 -0400 Subject: [PATCH 07/10] Change warning to be a modal --- src/instantiate.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/instantiate.ts b/src/instantiate.ts index 98f2ddd4e..4ce47e05a 100644 --- a/src/instantiate.ts +++ b/src/instantiate.ts @@ -712,7 +712,10 @@ export async function loadAllofExtension(context: vscode.ExtensionContext) { if (doc?.isDirty) { vscode.window - .showWarningMessage(`Your changes will be discarded`, `Continue`, `Cancel`) + .showWarningMessage( + `Your changes will be discarded`, + { modal: true }, + `Continue`) .then(result => { if (result === `Continue`) { vscode.commands.executeCommand(`workbench.action.files.revert`); From 3df0ba9e7203271c30bb00ebd8c115a31d08a9e2 Mon Sep 17 00:00:00 2001 From: Julia Yan Date: Tue, 14 May 2024 17:51:07 -0400 Subject: [PATCH 08/10] Update to use translated strings --- src/instantiate.ts | 7 ++++--- src/locale/ids/en.json | 1 + 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/instantiate.ts b/src/instantiate.ts index 4ce47e05a..937081126 100644 --- a/src/instantiate.ts +++ b/src/instantiate.ts @@ -19,6 +19,7 @@ import { Action, BrowserItem, DeploymentMethod, MemberItem, OpenEditableOptions, import { SearchView } from "./views/searchView"; import { ActionsUI } from './webviews/actions'; import { VariablesUI } from "./webviews/variables"; +import { t } from './locale'; export let instance: Instance; @@ -713,11 +714,11 @@ export async function loadAllofExtension(context: vscode.ExtensionContext) { if (doc?.isDirty) { vscode.window .showWarningMessage( - `Your changes will be discarded`, + t(`discard.changes`), { modal: true }, - `Continue`) + t(`Continue`)) .then(result => { - if (result === `Continue`) { + if (result === t(`Continue`)) { vscode.commands.executeCommand(`workbench.action.files.revert`); } }); diff --git a/src/locale/ids/en.json b/src/locale/ids/en.json index faff6b5dd..dc64c0236 100644 --- a/src/locale/ids/en.json +++ b/src/locale/ids/en.json @@ -120,6 +120,7 @@ "delete": "Delete", "detail.reading.error": "Failed to read debug service detail file {0}: {1}", "directory": "directory", + "discard.changes": "Your changes will be discarded", "download.certificate": "Download certificate", "duplicate": "Duplicate", "enddbgsvr.failed": "Failed to stop debug server: {0}", From cd9dd829452ff79bcf2a74d39ef5017b7641f6e5 Mon Sep 17 00:00:00 2001 From: Julia Yan Date: Wed, 15 May 2024 10:33:33 -0400 Subject: [PATCH 09/10] Add french translation --- src/locale/ids/fr.json | 1 + 1 file changed, 1 insertion(+) diff --git a/src/locale/ids/fr.json b/src/locale/ids/fr.json index bf155d54c..49fa31ef0 100644 --- a/src/locale/ids/fr.json +++ b/src/locale/ids/fr.json @@ -120,6 +120,7 @@ "delete": "Supprimer", "detail.reading.error": "Erreur de lecture du fichier détail du service de débogage {0}: {1}", "directory": "Répertoire", + "discard.changes": "Vos modifications vont être perdues", "download.certificate": "Télécharger le certificat", "duplicate": "Dupliquer", "enddbgsvr.failed": "Échec de l\"arrêt du serveur de débogage: {0}", From cec100fa16488488cffb6f46022d38bf83eddaf2 Mon Sep 17 00:00:00 2001 From: Christian Jorgensen Date: Tue, 28 May 2024 10:08:51 +0200 Subject: [PATCH 10/10] Add danish translation --- src/locale/ids/da.json | 1 + 1 file changed, 1 insertion(+) diff --git a/src/locale/ids/da.json b/src/locale/ids/da.json index 5f3de6001..681bbb5ca 100644 --- a/src/locale/ids/da.json +++ b/src/locale/ids/da.json @@ -120,6 +120,7 @@ "delete": "Slet", "detail.reading.error": "Fejl ved læsning af debug service detail fil {0}: {1}", "directory": "mappe", + "discard.changes": "Dine ændringer vil blive kasseret", "download.certificate": "Hent certifikat", "duplicate": "Kopier", "enddbgsvr.failed": "Fejl ved stop af debug server: {0}",