Skip to content

Commit

Permalink
fix: Add a note about degraded experience on image hover with vscode …
Browse files Browse the repository at this point in the history
…1.53/1.54
  • Loading branch information
svsool committed Mar 20, 2021
1 parent 37c7206 commit cd085f9
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 7 deletions.
4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,7 @@
"@types/moment": "^2.13.0",
"@types/node": "^14.14.35",
"@types/open": "^6.2.1",
"@types/semver": "^7.3.4",
"@types/vscode": "^1.54.0",
"@typescript-eslint/eslint-plugin": "^4.18.0",
"@typescript-eslint/parser": "^4.18.0",
Expand Down Expand Up @@ -277,6 +278,7 @@
"markdown-it": "^12.0.4",
"markdown-it-regex": "^0.2.0",
"moment": "^2.29.1",
"open": "^8.0.3"
"open": "^8.0.3",
"semver": "^7.3.4"
}
}
3 changes: 2 additions & 1 deletion src/features/ReferenceHoverProvider.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,8 @@ describe('ReferenceHoverProvider', () => {
});
});

it('should provide hover for image', async () => {
// Skipped until a proper solution found. See this issue https:/svsool/vscode-memo/issues/306.
it.skip('should provide hover for image', async () => {
const name0 = rndName();
const name1 = rndName();

Expand Down
15 changes: 10 additions & 5 deletions src/features/ReferenceHoverProvider.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import vscode from 'vscode';
import fs from 'fs';
import path from 'path';
import semver from 'semver';

import {
containsImageExt,
Expand Down Expand Up @@ -44,11 +45,15 @@ export default class ReferenceHoverProvider implements vscode.HoverProvider {
);
const getContent = () => {
if (containsImageExt(foundUri.fsPath)) {
return `![${
isUncPath(foundUri.fsPath)
? 'UNC paths are not supported for images preview due to VSCode Content Security Policy. Use markdown preview or open image via cmd (ctrl) + click instead.'
: ''
}](${vscode.Uri.file(foundUri.fsPath).toString()}|height=${imageMaxHeight})`;
if (semver.gt(vscode.version, '1.52.1')) {
return `Image preview is currently not supported with VSCode > **1.52.1** 😔. You version is **${vscode.version}**. See [this issue](https:/svsool/vscode-memo/issues/306) for additional details.`;
}

if (isUncPath(foundUri.fsPath)) {
return 'UNC paths are not supported for images preview due to VSCode Content Security Policy. Use markdown preview or open image via cmd (ctrl) + click instead.';
}

return `![](${vscode.Uri.file(foundUri.fsPath).toString()}|height=${imageMaxHeight})`;
} else if (containsOtherKnownExts(foundUri.fsPath)) {
const ext = path.parse(foundUri.fsPath).ext;
return `Preview is not supported for "${ext}" file type. Click to open in the default app.`;
Expand Down
5 changes: 5 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -934,6 +934,11 @@
resolved "https://registry.yarnpkg.com/@types/prettier/-/prettier-2.0.2.tgz#5bb52ee68d0f8efa9cc0099920e56be6cc4e37f3"
integrity sha512-IkVfat549ggtkZUthUzEX49562eGikhSYeVGX97SkMFn+sTZrgRewXjQ4tPKFPCykZHkX1Zfd9OoELGqKU2jJA==

"@types/semver@^7.3.4":
version "7.3.4"
resolved "https://registry.yarnpkg.com/@types/semver/-/semver-7.3.4.tgz#43d7168fec6fa0988bb1a513a697b29296721afb"
integrity sha512-+nVsLKlcUCeMzD2ufHEYuJ9a2ovstb6Dp52A5VsoKxDXgvE051XgHI/33I1EymwkRGQkwnA0LkhnUzituGs4EQ==

"@types/stack-utils@^1.0.1":
version "1.0.1"
resolved "https://registry.yarnpkg.com/@types/stack-utils/-/stack-utils-1.0.1.tgz#0a851d3bd96498fa25c33ab7278ed3bd65f06c3e"
Expand Down

0 comments on commit cd085f9

Please sign in to comment.