Browse Source

Fixes #1488 issue with translated error messages

main
Eric Amodio 2 years ago
parent
commit
37feb18ca1
2 changed files with 22 additions and 14 deletions
  1. +1
    -0
      CHANGELOG.md
  2. +21
    -14
      src/trackers/documentTracker.ts

+ 1
- 0
CHANGELOG.md View File

@ -12,6 +12,7 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/) and this p
### Fixed
- Fixes [#1488](https://github.com/gitkraken/vscode-gitlens/issues/1488) - Open Folder History not working with non-English language pack
- Fixes [#2303](https://github.com/gitkraken/vscode-gitlens/issues/2303) - "Googlesource" gerrit only supports two levels of domain — thanks to [PR #2304](https://github.com/gitkraken/vscode-gitlens/pull/2304) by Matt Buckley ([@Mattadore](https://github.com/Mattadore))
- Fixes [#2300](https://github.com/gitkraken/vscode-gitlens/issues/2300) - extra non-functional toolbar buttons when viewing PR diffs in VSCode web
- Fixes [#2281](https://github.com/gitkraken/vscode-gitlens/issues/2281) - Push and Pull buttons missing from the commits view w/ integrations disabled

+ 21
- 14
src/trackers/documentTracker.ts View File

@ -9,7 +9,7 @@ import type {
TextEditor,
TextLine,
} from 'vscode';
import { Disposable, EndOfLine, EventEmitter, Uri, window, workspace } from 'vscode';
import { Disposable, EndOfLine, env, EventEmitter, Uri, window, workspace } from 'vscode';
import { configuration } from '../configuration';
import { ContextKeys } from '../constants';
import type { Container } from '../container';
@ -241,20 +241,27 @@ export class DocumentTracker implements Disposable {
document = await workspace.openTextDocument(documentOrUri.documentUri());
} catch (ex) {
const msg: string = ex?.toString() ?? '';
if (msg.includes('File seems to be binary and cannot be opened as text')) {
document = new BinaryTextDocument(documentOrUri);
} else if (
msg.includes('File not found') ||
msg.includes('Unable to read file') ||
msg.includes('Unable to resolve non-existing file')
) {
// If we can't find the file, assume it is because the file has been renamed or deleted at some point
if (env.language.startsWith('en')) {
if (msg.includes('File seems to be binary and cannot be opened as text')) {
document = new BinaryTextDocument(documentOrUri);
} else if (
msg.includes('File not found') ||
msg.includes('Unable to read file') ||
msg.includes('Unable to resolve non-existing file')
) {
// If we can't find the file, assume it is because the file has been renamed or deleted at some point
document = new MissingRevisionTextDocument(documentOrUri);
// const [fileName, repoPath] = await this.container.git.findWorkingFileName(documentOrUri, undefined, ref);
// if (fileName == null) throw new Error(`Failed to add tracking for document: ${documentOrUri}`);
// documentOrUri = await workspace.openTextDocument(path.resolve(repoPath!, fileName));
} else {
throw ex;
}
} else if (msg.includes('cannot open')) {
// If we aren't in english, we can't figure out what the error might be (since the messages are translated), so just assume its missing
document = new MissingRevisionTextDocument(documentOrUri);
// const [fileName, repoPath] = await this.container.git.findWorkingFileName(documentOrUri, undefined, ref);
// if (fileName == null) throw new Error(`Failed to add tracking for document: ${documentOrUri}`);
// documentOrUri = await workspace.openTextDocument(path.resolve(repoPath!, fileName));
} else {
throw ex;
}

Loading…
Cancel
Save