Skip to content

Commit

Permalink
Update dependencies and fix encoding issue (#38)
Browse files Browse the repository at this point in the history
  • Loading branch information
caponetto authored Apr 10, 2022
1 parent 992da45 commit 3da6c01
Show file tree
Hide file tree
Showing 7 changed files with 855 additions and 505 deletions.
13 changes: 1 addition & 12 deletions .github/actions/setup-env/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,9 @@ runs:
- name: "Setup :: Node"
uses: actions/setup-node@v2
with:
node-version: 16.2.0
node-version: 16.13.2
cache: "yarn"

- name: "Setup :: Yarn"
shell: bash
run: |
npm install -g [email protected]
yarn config set network-timeout 1000000
- name: "Bootstrap"
shell: bash
run: |
Expand All @@ -27,11 +21,6 @@ runs:
git diff yarn.lock;
[ "0" == "$(git diff yarn.lock | wc -l | tr -d ' ')" ]
- name: "Check :: dependencies mismatches"
shell: bash
run: |
npx --yes syncpack list-mismatches
- name: "Check :: format"
shell: bash
run: |
Expand Down
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# 1.2.0

Update dependencies and fix encoding issue

# 1.1.14

Codebase improvements
Expand Down
23 changes: 12 additions & 11 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "vscode-diff-viewer",
"displayName": "Diff Viewer",
"description": "Visualize git diff files in VS Code",
"version": "1.1.14",
"version": "1.2.0",
"license": "MIT",
"publisher": "caponetto",
"repository": {
Expand Down Expand Up @@ -131,20 +131,21 @@
"run:webmode": "yarn vscode-test-web --browserType=chromium --extensionDevelopmentPath=. --version=stable"
},
"dependencies": {
"diff2html": "3.4.11"
"chardet": "1.4.0",
"diff2html": "3.4.16"
},
"devDependencies": {
"@types/node": "16.3.3",
"@types/node": "17.0.23",
"@types/vscode": "^1.46.0",
"@vscode/test-web": "^0.0.8",
"ts-loader": "9.2.3",
"typescript": "4.3.5",
"vsce": "1.96.3",
"@vscode/test-web": "^0.0.24",
"path-browserify": "1.0.1",
"webpack": "5.45.1",
"webpack-cli": "4.7.2",
"prettier": "2.3.2",
"prettier": "2.6.2",
"rimraf": "^3.0.2",
"ts-loader": "9.2.8",
"tslint-config-prettier": "1.18.0",
"rimraf": "^3.0.2"
"typescript": "4.6.3",
"vsce": "2.7.0",
"webpack": "5.72.0",
"webpack-cli": "4.9.2"
}
}
6 changes: 4 additions & 2 deletions src/DiffDocument.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import * as chardet from "chardet";
import * as path from "path";
import * as vscode from "vscode";

export class DiffDocument implements vscode.CustomDocument {
private readonly _onDidDispose = new vscode.EventEmitter<void>();
private static readonly decoder = new TextDecoder("utf-8");
public readonly onDidDispose = this._onDidDispose.event;

get filename(): string {
Expand All @@ -19,6 +19,8 @@ export class DiffDocument implements vscode.CustomDocument {

public static async create(uri: vscode.Uri): Promise<DiffDocument | PromiseLike<DiffDocument>> {
const fileData = await vscode.workspace.fs.readFile(uri);
return new DiffDocument(uri, this.decoder.decode(fileData));
const encoding = chardet.detect(fileData);
const decoder = new TextDecoder(encoding ?? "utf-8");
return new DiffDocument(uri, decoder.decode(fileData));
}
}
2 changes: 1 addition & 1 deletion src/DiffViewerProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export class DiffViewerProvider implements vscode.CustomReadonlyEditorProvider<D
_openContext: vscode.CustomDocumentOpenContext,
_token: vscode.CancellationToken
): Promise<DiffDocument> {
return await DiffDocument.create(uri);
return DiffDocument.create(uri);
}

public async resolveCustomEditor(
Expand Down
4 changes: 4 additions & 0 deletions webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,5 +31,9 @@ module.exports = async (_argv) => [
entry: {
extension: "./src/extension.ts",
},
performance: {
maxEntrypointSize: 1024 * 1024 * 1,
maxAssetSize: 1024 * 1024 * 1,
},
},
];
Loading

0 comments on commit 3da6c01

Please sign in to comment.