diff --git a/CHANGELOG.md b/CHANGELOG.md
index 7b9ec9a..0f9ddc3 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,5 +1,9 @@
# Change Log
+## [1.61.1] 2024-01-30
+### Added
+- ${workspaceFolder:name:nomsg}
: option to suppress error message
+
## [1.61.0] 2023-12-19
### Added
- `openDialog`: get file path from the OS File/Directory open dialog
diff --git a/README.md b/README.md
index c1ff82e..6be54b7 100644
--- a/README.md
+++ b/README.md
@@ -2123,6 +2123,7 @@ VSC does not perform [variable substitution](https://code.visualstudio.com/docs/
* ${userHome}
: the path of the user's home folder
* `${workspaceFolder}` : the path of the workspace folder opened in VS Code containing the current file.
* ${workspaceFolder:name}
: the path of the workspace folder with the specified _name_ opened in VS Code
+* ${workspaceFolder:name:nomsg}
: same as ${workspaceFolder:name}
but there will be no ErrorMessage shown.
* `${workspaceFolderBasename}` : the name of the workspace folder opened in VS Code containing the current file without any slashes
* `${file}` : the current opened file (the file system path)
* `${relativeFile}` : the current opened file relative to workspaceFolder
diff --git a/extension-common.js b/extension-common.js
index 67d8853..f5e68d4 100644
--- a/extension-common.js
+++ b/extension-common.js
@@ -31,6 +31,8 @@ function setAsDesktopExtension() {
gWebExtension = false;
}
+function setShowErrMsg(b) { utils.setShowErrMsg(b); }
+
const PostfixURI = '@URI@';
let numberStore = {};
@@ -646,6 +648,7 @@ module.exports = {
activate,
deactivate,
showDeprecationMessage,
+ setShowErrMsg,
gDeprecationRememberPickVariable,
gDeprecationRememberPickCommand,
storeStringRemember,
diff --git a/extension.js b/extension.js
index e51b381..c789932 100644
--- a/extension.js
+++ b/extension.js
@@ -312,8 +312,10 @@ function activate(context) {
return workspaceFolder.uri.fsPath;
});
});
- result = variableReplaceAndFilter(result, 'workspaceFolder:(.+?)', 1, (m, p1) => {
+ result = variableReplaceAndFilter(result, 'workspaceFolder:(.+?)(:nomsg)?', 2, (m, p1, p2) => {
+ if (p2) { common.setShowErrMsg(false); }
let wsf = common.getNamedWorkspaceFolder(p1);
+ if (p2) { common.setShowErrMsg(true); }
if (!wsf) { return 'Unknown'; }
return wsf.uri.fsPath;
});
diff --git a/package.json b/package.json
index 5cb709a..59c1397 100644
--- a/package.json
+++ b/package.json
@@ -4,7 +4,7 @@
"description": "Calculate command variables for launch.json and tasks.json",
"publisher": "rioj7",
"license": "MIT",
- "version": "1.61.0",
+ "version": "1.61.1",
"engines": {"vscode": "^1.55.0"},
"categories": ["Other"],
"keywords": ["command","variable","launch","tasks","date","multi-root ready","pick","file","key","value","uuid","clipboard","number","remember"],
diff --git a/utils.js b/utils.js
index 6c2e6a9..447ac85 100644
--- a/utils.js
+++ b/utils.js
@@ -10,9 +10,14 @@ function utf8_to_str (src, off, lim) { // https://github.com/quicbit-js/qb-utf8
return decodeURIComponent(s);
}
+let showErrMsg = true;
+function setShowErrMsg(b) { showErrMsg = b; }
+function getShowErrMsg() { return showErrMsg; }
function getProperty(obj, prop, deflt) { return obj.hasOwnProperty(prop) ? obj[prop] : deflt; }
function getDefaultProperty(obj, deflt) { return getProperty(obj, 'default', deflt); }
-function errorMessage(msg, noObject) { vscode.window.showErrorMessage(msg); return noObject ? noObject : "Unknown";}
+function errorMessage(msg, noObject) {
+ if (getShowErrMsg()) { vscode.window.showErrorMessage(msg); }
+ return noObject ? noObject : "Unknown";}
function fileNotInFolderError(noObject) { return errorMessage('File not in Multi-root Workspace', noObject); }
function isString(obj) { return typeof obj === 'string';}
function isArray(obj) { return Array.isArray(obj);}
@@ -22,5 +27,5 @@ function dblQuest(value, deflt) { return value !== undefined ? value : deflt; }
function nUp(i) { return i===0 ? '' : i.toString()+'Up'; }
module.exports = {
- getProperty, getDefaultProperty, errorMessage, fileNotInFolderError, isString, isArray, isObject, range, dblQuest, nUp, utf8_to_str
+ getProperty, getDefaultProperty, errorMessage, setShowErrMsg, fileNotInFolderError, isString, isArray, isObject, range, dblQuest, nUp, utf8_to_str
}