Skip to content

Commit 55af0b6

Browse files
committed
Fix #111, Relative paths in pyIgnore setting do not work
- Added support for syncFolder specific pyIgnore values
1 parent 7465e5c commit 55af0b6

File tree

4 files changed

+41
-20
lines changed

4 files changed

+41
-20
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ Pico-W-Go provides code auto-completion and allows you to communicate with your
66
77
Works with:
88
| Platform | x64 | arm64 | armhf |
9-
| -------- | --- | ----- | ----- |
9+
| :------- | :-: | :---: | :---: |
1010
| Windows ||||
1111
| macOS ||||
1212
| Linux ||||
@@ -74,7 +74,7 @@ This extension contributes the following settings:
7474
* `picowgo.additionalSyncFolders`: Specifies additional folders that can be selected as upload sources when uploading a project. If left empty, the sync will be performed based on the folder specified in the 'syncFolder' setting. Only folders within the project are allowed. Specify the path relative to the project you have opened in Visual Studio Code, without a leading or trailing slash.
7575
* `picowgo.syncAllFileTypes`: If enabled, all files will be uploaded no matter the file type. The list of file types below will be ignored.
7676
* `picowgo.syncFileTypes`: All types of files that will be uploaded to the board, seperated by comma. All other filetypes will be ignored during an upload (or download) action.
77-
* `picowgo.pyIgnore`: Comma separated list of files and folders to ignore when uploading (no wildcard or regular expressions supported).
77+
* `picowgo.pyIgnore`: Comma separated list of files and folders to ignore when uploading relative to syncFolder (no wildcard or regular expressions supported except `**/<file/folder>` to exclude an item by its name in every sub folder). Use `<additionalSyncFolder>:file/to/exclude.py` to create sync folder exclusive exclusion rules (all other rules will always be applied relative to the selected sync folder). Replace `additionalSyncFolder` with a value from your `picowgo.additionalSyncFolders` setting or the value from `picowgo.syncFolder`.
7878
* `picowgo.openOnStart`: Automatically open the Pico-W-Go console and connect to the board after starting VS Code.
7979
* `picowgo.statusbarButtons`: Select which buttons to show in the statusbar (DO NOT CHANGE, unless you know what you are doing)
8080
* `picowgo.gcBeforeUpload`: Run garbage collection before uploading files to the board. This will free up some memory usefull when uploading large files but adds about a second or two to the upload process.

package.json

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -314,19 +314,20 @@
314314
},
315315
"picowgo.pyIgnore": {
316316
"title": "Pyignore list",
317-
"description": "Comma separated list of files and folders to ignore when uploading relative to syncFolder (no wildcard or regular expressions supported)",
317+
"markdownDescription": "Comma separated list of files and folders to ignore when uploading relative to syncFolder (no wildcard or regular expressions supported except `**/<file/folder>` to exclude an item by its name in every sub folder). Use `<additionalSyncFolder>:file/to/exclude.py` to create sync folder exclusive exclusion rules (all other rules will always be applied relative to the selected sync folder). Replace `additionalSyncFolder` with a value from your `picowgo.additionalSyncFolders` setting or the value from `picowgo.syncFolder`.",
318318
"type": "array",
319319
"items": {
320320
"type": "string"
321321
},
322322
"default": [
323-
".picowgo",
324-
".vscode",
325-
".gitignore",
326-
".git",
327-
"project.pico-go",
328-
"env",
329-
"venv"
323+
"**/.picowgo",
324+
"**/.vscode",
325+
"**/.gitignore",
326+
"**/.git",
327+
"**/.DS_Store",
328+
"**/project.pico-go",
329+
"**/env",
330+
"**/venv"
330331
],
331332
"order": 8
332333
},
@@ -380,7 +381,6 @@
380381
"picowgo.softResetAfterUpload": {
381382
"type": "boolean",
382383
"default": false,
383-
"scope": "machine-overridable",
384384
"title": "Soft-reset after upload",
385385
"description": "Soft-resets your board after any upload action which also reruns main.py and boot.py. Usefull when working with main.py and boot.py.",
386386
"order": 12

src/activator.mts

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -513,6 +513,20 @@ export default class Activator {
513513
return;
514514
}
515515

516+
// reducde replaces filter, map and concat
517+
const ignoredSyncItems = settings.getIngoredSyncItems().reduce(
518+
(acc: string[], item: string) => {
519+
// item must either be global or for the current sync folder otherwise it is ignored
520+
if (!item.includes(":") || item.split(":")[0] === syncDir[0]) {
521+
const finalItem = item.includes(":") ? item.split(":")[1] : item;
522+
acc.push(finalItem);
523+
}
524+
525+
return acc;
526+
},
527+
["**/.picowgo", "**/.DS_Store"]
528+
);
529+
516530
if (settings.getBoolean(SettingsKey.gcBeforeUpload)) {
517531
// TODO: maybe do soft reboot instead of gc for bigger impact
518532
await this.pyb?.executeCommand(
@@ -532,9 +546,9 @@ export default class Activator {
532546

533547
let currentFileIndex = -1;
534548
const data = await this.pyb?.startUploadingProject(
535-
syncDir,
549+
syncDir[1],
536550
settings.getSyncFileTypes(),
537-
settings.getIngoredSyncItems().concat([".picowgo"]),
551+
ignoredSyncItems,
538552
(data: string) => {
539553
this.logger.debug("upload progress: " + data);
540554
const status = this.analyseUploadDownloadProgress(data);
@@ -551,7 +565,7 @@ export default class Activator {
551565
}
552566

553567
progress.report({
554-
message: sep + relative(syncDir, status.filePath),
568+
message: sep + relative(syncDir[1], status.filePath),
555569
});
556570
}
557571
);
@@ -693,7 +707,7 @@ export default class Activator {
693707
async (progress /*, token*/) => {
694708
let currentFileIndex = -1;
695709
const data = await this.pyb?.downloadProject(
696-
syncDir,
710+
syncDir[1],
697711
(data: string) => {
698712
const status = this.analyseUploadDownloadProgress(data);
699713

src/settings.mts

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import type { Memento, WorkspaceConfiguration } from "vscode";
22
import { window, workspace } from "vscode";
33
import { PyboardRunner } from "@paulober/pyboard-serial-com";
44
import { getProjectPath } from "./api.mjs";
5-
import { join } from "path";
5+
import { join, relative } from "path";
66

77
export enum SettingsKey {
88
autoConnect = "autoConnect",
@@ -129,11 +129,12 @@ export default class Settings {
129129
* @param actionTitle The title of the action to perform. Used in the selection dialog.
130130
* E.g. "Upload" or "Download".
131131
*
132-
* @returns The absolute path to one sync folder.
132+
* @returns [Relative to workspace root path of one sync folder,
133+
* The absolute path to one sync folder]
133134
*/
134135
public async requestSyncFolder(
135136
actionTitle: string
136-
): Promise<string | undefined> {
137+
): Promise<[string, string] | undefined> {
137138
const syncFolder = this.getSyncFolderAbsPath();
138139
const projectDir = getProjectPath();
139140

@@ -150,7 +151,11 @@ export default class Settings {
150151
additionalSyncFolders === undefined ||
151152
additionalSyncFolders.length === 0
152153
) {
153-
return syncFolder;
154+
if (syncFolder === undefined) {
155+
return undefined;
156+
} else {
157+
return [relative(projectDir, syncFolder), syncFolder];
158+
}
154159
}
155160

156161
// prepend normal syncFolder if available to options
@@ -170,7 +175,9 @@ export default class Settings {
170175
title: `${actionTitle} sync folder selection`,
171176
});
172177

173-
return selectedFolder;
178+
return selectedFolder === undefined
179+
? undefined
180+
: [relative(projectDir, selectedFolder), selectedFolder];
174181
}
175182

176183
/**

0 commit comments

Comments
 (0)