Skip to content

Commit

Permalink
fix: Fixed reading base64 file (#1757)
Browse files Browse the repository at this point in the history
  • Loading branch information
shd101wyy authored Sep 14, 2023
1 parent c6996c3 commit 426b579
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 8 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -620,7 +620,7 @@
"dependencies": {
"@types/crypto-js": "^4.1.2",
"@types/vfile": "^3.0.2",
"crossnote": "^0.8.11",
"crossnote": "^0.8.12",
"crypto-js": "^4.1.1"
},
"devDependencies": {
Expand Down
14 changes: 14 additions & 0 deletions src/extension-common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -627,6 +627,13 @@ export function initExtensionCommon(context: vscode.ExtensionContext) {
});
}

async function toggleAlwaysShowBacklinksInPreview(uri, flag) {
const config = vscode.workspace.getConfiguration(
'markdown-preview-enhanced',
);
config.update('alwaysShowBacklinksInPreview', flag, true);
}

context.subscriptions.push(
vscode.workspace.onDidSaveTextDocument(async (document) => {
if (isMarkdownFile(document)) {
Expand Down Expand Up @@ -1080,6 +1087,13 @@ export function initExtensionCommon(context: vscode.ExtensionContext) {
context.subscriptions.push(
vscode.commands.registerCommand('_crossnote.showBacklinks', showBacklinks),
);

context.subscriptions.push(
vscode.commands.registerCommand(
'_crossnote.toggleAlwaysShowBacklinksInPreview',
toggleAlwaysShowBacklinksInPreview,
),
);
}

function revealLine(uri, line) {
Expand Down
6 changes: 3 additions & 3 deletions src/vscode-fs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,15 @@ export function wrapVSCodeFSAsApi(scheme: string): FileSystemApi {
path = path.replace(/^\//, '');
const uri = getUri(path, scheme);
const data = await vscode.workspace.fs.readFile(uri);
return new TextDecoder(encoding ?? 'utf-8').decode(data);
return Buffer.from(data).toString(encoding);
},
writeFile: async (
path: string,
data: string,
encoding?: string,
encoding?: BufferEncoding,
): Promise<void> => {
const uri = getUri(path, scheme);
await vscode.workspace.fs.writeFile(uri, new TextEncoder().encode(data));
await vscode.workspace.fs.writeFile(uri, Buffer.from(data, encoding));
},
mkdir: async (path: string): Promise<void> => {
await vscode.workspace.fs.createDirectory(getUri(path, scheme));
Expand Down
8 changes: 4 additions & 4 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1880,10 +1880,10 @@ cross-spawn@^7.0.0, cross-spawn@^7.0.2, cross-spawn@^7.0.3:
shebang-command "^2.0.0"
which "^2.0.1"

crossnote@^0.8.11:
version "0.8.11"
resolved "https://registry.yarnpkg.com/crossnote/-/crossnote-0.8.11.tgz#a6d631aff0779b8ef80af88f9f8c57ec2f6513f7"
integrity sha512-x82a2VK57XG1q2+1RihEDXaUaesHJ8bUP8YwKE37TTGkM0Zm4kv21oiR5aFOPN51crRAdEo7AxxUFLJmHBhIXw==
crossnote@^0.8.12:
version "0.8.12"
resolved "https://registry.yarnpkg.com/crossnote/-/crossnote-0.8.12.tgz#54d7fe75c6ac2004a16c037926ad0a60cc67f779"
integrity sha512-a7s/ihxciBj6Kngram+ODKSsW5MPSGoVopz5qa78ytZfz2sko/x7SEGJXpJh1nvFRb2M2rDynVbzQ+Uj3mN5mA==
dependencies:
"@headlessui/react" "^1.7.17"
"@heroicons/react" "^2.0.18"
Expand Down

0 comments on commit 426b579

Please sign in to comment.