Skip to content

Commit

Permalink
Support old and new RenderOptions API
Browse files Browse the repository at this point in the history
  • Loading branch information
kisstkondoros committed Sep 29, 2016
1 parent e38b39d commit 2ac1f6f
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
2 changes: 2 additions & 0 deletions .vscode/settings.json
Expand Up @@ -9,4 +9,6 @@
"search.exclude": {
"out": true // set this to false to include "out" folder in search results
}
,
"typescript.tsdk": "./node_modules/typescript/lib"
}
11 changes: 8 additions & 3 deletions src/extension.ts
Expand Up @@ -9,7 +9,7 @@ interface Decoration {
absoluteImagePath: string;
}

const acceptedExtensions = ['.svg', '.png', '.jpeg', '.jpg', '.bmp'];
const acceptedExtensions = ['.svg', '.png', '.jpeg', '.jpg', '.bmp', '.gif'];

const appendImagePath = (absoluteImagePath, lineIndex, lastScanResult) => {
if (absoluteImagePath) {
Expand All @@ -29,11 +29,16 @@ const appendImagePath = (absoluteImagePath, lineIndex, lastScanResult) => {
range: new vscode.Range(lineIndex, 0, lineIndex, 0),
hoverMessage: ""
});
var uri = absoluteImagePath;
var [major, minor, patch] = vscode.version.split('.').map(v=>parseInt(v));
if (major > 1 || (major == 1 && minor > 5)) {
uri = vscode.Uri.parse(absoluteImagePath);
}
let decorationRenderOptions: vscode.DecorationRenderOptions = {
gutterIconPath: absoluteImagePath,
gutterIconPath: uri,
gutterIconSize: 'contain'
};
let textEditorDecorationType: vscode.TextEditorDecorationType = vscode.window.createTextEditorDecorationType(decorationRenderOptions);
let textEditorDecorationType: vscode.TextEditorDecorationType = vscode.window.createTextEditorDecorationType(<any>decorationRenderOptions);
lastScanResult.push({ textEditorDecorationType, decorations, absoluteImagePath });
}
}
Expand Down

0 comments on commit 2ac1f6f

Please sign in to comment.