Skip to content

Commit bb63b4d

Browse files
committed
Show error message when user setting select zero files for download
It is possible to create glob patterns such that no files are selected for download. If this happens, let's tell the user what happended and suggest how to fix it. Fixes #75
1 parent 4eced2f commit bb63b4d

File tree

2 files changed

+19
-0
lines changed

2 files changed

+19
-0
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ Check [Keep a Changelog](http://keepachangelog.com/) for recommendations on how
66
## Unreleased
77
### Fixed
88
- Files are not downloaded when using global launch configuration
9+
- No indication when zero files are downloaded
910

1011
## 1.0.1 - 2019-02-02
1112
### Fixed

src/extension.ts

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -215,6 +215,24 @@ async function download(folder: vscode.WorkspaceFolder, device: Device): Promise
215215
}, async (progress, token) => {
216216
try {
217217
const files = await vscode.workspace.findFiles(includeFiles, excludeFiles);
218+
219+
// If there are no files matching the given include and exclude patterns,
220+
// let the user know about it.
221+
if (!files.length) {
222+
const msg = 'No files selected for download. Please check the ev3devBrowser.download.include and ev3devBrowser.download.exclude settings.';
223+
// try to make it easy for the user to fix the problem by offering to
224+
// open the settings editor
225+
const openSettings = 'Open Settings';
226+
vscode.window.showErrorMessage(msg, openSettings).then(result => {
227+
if (result === openSettings) {
228+
vscode.commands.executeCommand('workbench.action.openSettings2');
229+
}
230+
});
231+
232+
// "cancel" the download
233+
return false;
234+
}
235+
218236
const increment = 100 / files.length;
219237
let fileIndex = 1;
220238
const reportProgress = (message: string) => progress.report({ message: message });

0 commit comments

Comments
 (0)