Skip to content

Commit

Permalink
v1.61.1 ${workspaceFolder:name:nomsg} do not show error notification, f…
Browse files Browse the repository at this point in the history
…ix #78
  • Loading branch information
rioj7 committed Jan 30, 2024
1 parent 8a2923a commit 200f9a7
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 4 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
@@ -1,5 +1,9 @@
# Change Log

## [1.61.1] 2024-01-30
### Added
- <code>&dollar;{workspaceFolder:<em>name</em>:nomsg}</code>: option to suppress error message

## [1.61.0] 2023-12-19
### Added
- `openDialog`: get file path from the OS File/Directory open dialog
Expand Down
1 change: 1 addition & 0 deletions README.md
Expand Up @@ -2123,6 +2123,7 @@ VSC does not perform [variable substitution](https://code.visualstudio.com/docs/
* <code>&dollar;{userHome}</code> : the path of the user's home folder
* `${workspaceFolder}` : the path of the workspace folder opened in VS Code containing the current file.
* <code>&dollar;{workspaceFolder:<em>name</em>}</code> : the path of the workspace folder with the specified _name_ opened in VS Code
* <code>&dollar;{workspaceFolder:<em>name</em>:nomsg}</code> : same as <code>&dollar;{workspaceFolder:<em>name</em>}</code> 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
Expand Down
3 changes: 3 additions & 0 deletions extension-common.js
Expand Up @@ -31,6 +31,8 @@ function setAsDesktopExtension() {
gWebExtension = false;
}

function setShowErrMsg(b) { utils.setShowErrMsg(b); }

const PostfixURI = '@URI@';

let numberStore = {};
Expand Down Expand Up @@ -646,6 +648,7 @@ module.exports = {
activate,
deactivate,
showDeprecationMessage,
setShowErrMsg,
gDeprecationRememberPickVariable,
gDeprecationRememberPickCommand,
storeStringRemember,
Expand Down
4 changes: 3 additions & 1 deletion extension.js
Expand Up @@ -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;
});
Expand Down
2 changes: 1 addition & 1 deletion package.json
Expand Up @@ -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"],
Expand Down
9 changes: 7 additions & 2 deletions utils.js
Expand Up @@ -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);}
Expand All @@ -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
}

0 comments on commit 200f9a7

Please sign in to comment.