Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Fix - Windows Export/Import to/from Scope File #8

Merged
merged 1 commit into from
Jul 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,3 +32,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

- Fix: empty decoration errors in last vscode builds
- Bump dependencies

### [1.1.3] - 2024-07-02

- Fix: Import/Export marked files from scope file on Windows systems.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "markfiles",
"displayName": "Mark Files",
"description": "An extension that allows you to mark files in the file explorer",
"version": "1.1.2",
"version": "1.1.3",
"publisher": "vquelque",
"engines": {
"vscode": "^1.76.0"
Expand Down
29 changes: 15 additions & 14 deletions src/fileDecorationProvider.ts
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
import path = require("path");
import { existsSync, writeFile } from "fs";
import ignore from "ignore";
import {
Uri,
CancellationToken,
FileDecorationProvider,
FileDecoration,
EventEmitter,
Event,
workspace,
ThemeColor,
EventEmitter,
FileDecoration,
FileDecorationProvider,
FileType,
ThemeColor,
Uri,
window,
workspace,
} from "vscode";
import { asyncReadFile } from "./utils";
import { existsSync, writeFile } from "fs";
import ignore from "ignore";
import { getStorage, printChannelOutput } from "./extension";
import { asyncReadFile } from "./utils";

export class DecorationProvider implements FileDecorationProvider {
private readonly _onDidChangeFileDecorations: EventEmitter<Uri | Uri[]> =
Expand Down Expand Up @@ -62,7 +62,7 @@ export class DecorationProvider implements FileDecorationProvider {
case FileType.Directory: {
// recurse
const files = (await workspace.fs.readDirectory(uri)).map((tu) =>
Uri.parse(`${uri}/${tu[0]}`),
Uri.file(`${uri}/${tu[0]}`),
);
return this.markOrUnmarkFiles(files);
}
Expand Down Expand Up @@ -123,7 +123,7 @@ export class DecorationProvider implements FileDecorationProvider {
.map((uri) => path.relative(projectRootUri, uri.fsPath))
.filter((relPath) => ig.ignores(relPath))
.map((relPath) => Uri.file(path.resolve(projectRootUri, relPath)));
printChannelOutput(`Loaded patterns from ${scopeUri}`);
printChannelOutput(`Loaded patterns from ${scopeUri}`);
this.markOrUnmarkFiles(markedAbsPath);
}

Expand All @@ -150,9 +150,10 @@ export class DecorationProvider implements FileDecorationProvider {
const markedFilesByWS = Array.from(this.markedFiles).reduce<{
[key: string]: string[];
}>((acc: { [key: string]: string[] }, uri: string) => {
const workspaceFolder = workspace.getWorkspaceFolder(Uri.parse(uri));
const workspaceFolder = workspace.getWorkspaceFolder(Uri.file(uri));
if (workspaceFolder) {
const relativePath = path.relative(workspaceFolder.uri.fsPath, uri); //use relative URIs in the scope file
const relativePath = path.relative(workspaceFolder.uri.fsPath, uri).replace(/\\/g, '/'); //use relative URIs in the scope file - use forward slash even on windows because of globs

if (!acc[workspaceFolder.uri.fsPath]) {
acc[workspaceFolder.uri.fsPath] = [relativePath];
} else {
Expand Down Expand Up @@ -231,7 +232,7 @@ export class DecorationProvider implements FileDecorationProvider {
const scopeFilesByProjectRootsURIs: { [scopeUri: string]: string } = {};
//iterate over all opened workspace folders
const rootFolders = workspace.workspaceFolders?.map(
(folder) => folder.uri.path,
(folder) => folder.uri.fsPath,
);
if (!rootFolders) {
return {};
Expand Down