Ver código fonte

Adds renamed file path to file view nodes

Adds originalPath token
main
Eric Amodio 5 anos atrás
pai
commit
bfd310fa8d
7 arquivos alterados com 65 adições e 21 exclusões
  1. +9
    -9
      package.json
  2. +14
    -0
      src/git/formatters/statusFormatter.ts
  3. +6
    -0
      src/git/models/file.ts
  4. +15
    -0
      src/system/string.ts
  5. +6
    -3
      src/views/nodes/commitFileNode.ts
  6. +12
    -6
      src/views/nodes/resultsFileNode.ts
  7. +3
    -3
      src/views/nodes/statusFileNode.ts

+ 9
- 9
package.json Ver arquivo

@ -1266,13 +1266,13 @@
"gitlens.views.commitFileFormat": {
"type": "string",
"default": "${file}",
"markdownDescription": "Specifies the format of a committed file in the views\n- Available tokens\n - `${directory}` — directory name\n - `${file}` — file name\n - `${filePath}` — formatted file name and path\n - `${path}` — full file path",
"markdownDescription": "Specifies the format of a committed file in the views\n- Available tokens\n - `${directory}` — directory name\n - `${file}` — file name\n - `${filePath}` — formatted file name and path\n - `${originalPath}` — full file path of the original file if renamed\n - `${path}` — full file path",
"scope": "window"
},
"gitlens.views.commitFileDescriptionFormat": {
"type": "string",
"default": "${directory}",
"markdownDescription": "Specifies the description format of a committed file in the views\n- Available tokens\n - `${directory}` — directory name\n - `${file}` — file name\n - `${filePath}` — formatted file name and path\n - `${path}` — full file path",
"default": "${directory}${ ← originalPath}",
"markdownDescription": "Specifies the description format of a committed file in the views\n- Available tokens\n - `${directory}` — directory name\n - `${file}` — file name\n - `${filePath}` — formatted file name and path\n - `${originalPath}` — full file path of the original file if renamed\n - `${path}` — full file path",
"scope": "window"
},
"gitlens.views.commitFormat": {
@ -1576,13 +1576,13 @@
"gitlens.views.stashFileFormat": {
"type": "string",
"default": "${file}",
"markdownDescription": "Specifies the format of a stashed file in the views\n- Available tokens\n - `${directory}` — directory name\n - `${file}` — file name\n - `${filePath}` — formatted file name and path\n - `${path}` — full file path",
"markdownDescription": "Specifies the format of a stashed file in the views\n- Available tokens\n - `${directory}` — directory name\n - `${file}` — file name\n - `${filePath}` — formatted file name and path\n - `${originalPath}` — full file path of the original file if renamed\n - `${path}` — full file path",
"scope": "window"
},
"gitlens.views.stashFileDescriptionFormat": {
"type": "string",
"default": "${directory}",
"markdownDescription": "Specifies the description format of a stashed file in the views\n- Available tokens\n - `${directory}` — directory name\n - `${file}` — file name\n - `${filePath}` — formatted file name and path\n - `${path}` — full file path",
"default": "${directory}${ ← originalPath}",
"markdownDescription": "Specifies the description format of a stashed file in the views\n- Available tokens\n - `${directory}` — directory name\n - `${file}` — file name\n - `${filePath}` — formatted file name and path\n - `${originalPath}` — full file path of the original file if renamed\n - `${path}` — full file path",
"scope": "window"
},
"gitlens.views.stashFormat": {
@ -1600,13 +1600,13 @@
"gitlens.views.statusFileFormat": {
"type": "string",
"default": "${working }${file}",
"markdownDescription": "Specifies the format of the status of a working or committed file in the views\n- Available tokens\n - `${directory}` — directory name\n - `${file}` — file name\n - `${filePath}` — formatted file name and path\n - `${path}` — full file path\n - `${working}` — optional indicator if the file is uncommitted",
"markdownDescription": "Specifies the format of the status of a working or committed file in the views\n- Available tokens\n - `${directory}` — directory name\n - `${file}` — file name\n - `${filePath}` — formatted file name and path\n - `${originalPath}` — full file path of the original file if renamed\n - `${path}` — full file path\n - `${working}` — optional indicator if the file is uncommitted",
"scope": "window"
},
"gitlens.views.statusFileDescriptionFormat": {
"type": "string",
"default": "${directory}",
"markdownDescription": "Specifies the description format of the status of a working or committed file in the views\n- Available tokens\n - `${directory}` — directory name\n - `${file}` — file name\n - `${filePath}` — formatted file name and path\n - `${path}` — full file path\n - `${working}` — optional indicator if the file is uncommitted",
"default": "${directory}${ ← originalPath}",
"markdownDescription": "Specifies the description format of the status of a working or committed file in the views\n- Available tokens\n - `${directory}` — directory name\n - `${file}` — file name\n - `${filePath}` — formatted file name and path\n - `${originalPath}` — full file path of the original file if renamed\n - `${path}` — full file path\n - `${working}` — optional indicator if the file is uncommitted",
"scope": "window"
},
"gitlens.advanced.abbreviatedShaLength": {

+ 14
- 0
src/git/formatters/statusFormatter.ts Ver arquivo

@ -12,6 +12,7 @@ export interface StatusFormatOptions extends FormatOptions {
directory?: Strings.TokenOptions;
file?: Strings.TokenOptions;
filePath?: Strings.TokenOptions;
originalPath?: Strings.TokenOptions;
path?: Strings.TokenOptions;
status?: Strings.TokenOptions;
working?: Strings.TokenOptions;
@ -34,6 +35,19 @@ export class StatusFileFormatter extends Formatter
return this._padOrTruncate(filePath, this._options.tokenOptions.filePath);
}
get originalPath() {
// if (
// // this._item.status !== 'R' ||
// this._item.originalFileName == null ||
// this._item.originalFileName.length === 0
// ) {
// return '';
// }
const originalPath = GitFile.getOriginalRelativePath(this._item, this._options.relativePath);
return this._padOrTruncate(originalPath, this._options.tokenOptions.originalPath);
}
get path() {
const directory = GitFile.getRelativePath(this._item, this._options.relativePath);
return this._padOrTruncate(directory, this._options.tokenOptions.path);

+ 6
- 0
src/git/models/file.ts Ver arquivo

@ -38,6 +38,12 @@ export namespace GitFile {
return GitUri.getFormattedPath(file.fileName, options);
}
export function getOriginalRelativePath(file: GitFile, relativeTo?: string): string {
if (file.originalFileName == null || file.originalFileName.length === 0) return '';
return GitUri.getRelativePath(file.originalFileName, relativeTo);
}
export function getRelativePath(file: GitFile, relativeTo?: string): string {
return GitUri.getRelativePath(file.fileName, relativeTo);
}

+ 15
- 0
src/system/string.ts Ver arquivo

@ -15,6 +15,21 @@ export namespace Strings {
Backslash = 92
}
export function getCommonBase(s1: string, s2: string, delimiter: string) {
let char;
let index = 0;
for (let i = 0; i < s1.length; i++) {
char = s1[i];
if (char !== s2[i]) break;
if (char === delimiter) {
index = i;
}
}
return index > 0 ? s1.substring(0, index + 1) : undefined;
}
export function getDurationMilliseconds(start: [number, number]) {
const [secs, nanosecs] = process.hrtime(start);
return secs * 1000 + Math.floor(nanosecs / 1000000);

+ 6
- 3
src/views/nodes/commitFileNode.ts Ver arquivo

@ -158,7 +158,7 @@ export class CommitFileNode extends ViewRefFileNode {
if (this._tooltip === undefined) {
if (this._displayAs & CommitFileNodeDisplayAs.CommitLabel) {
// eslint-disable-next-line no-template-curly-in-string
const status = StatusFileFormatter.fromTemplate('${status}', this.file);
const status = StatusFileFormatter.fromTemplate('${status}${ (originalPath)}', this.file);
this._tooltip = CommitFormatter.fromTemplate(
this.commit.isUncommitted
? `\${author} ${GlyphChars.Dash} \${id}\n${status}\n\${ago} (\${date})`
@ -170,8 +170,11 @@ export class CommitFileNode extends ViewRefFileNode {
);
}
else {
// eslint-disable-next-line no-template-curly-in-string
this._tooltip = StatusFileFormatter.fromTemplate('${file}\n${directory}/\n\n${status}', this.file);
this._tooltip = StatusFileFormatter.fromTemplate(
// eslint-disable-next-line no-template-curly-in-string
'${file}\n${directory}/\n\n${status}${ (originalPath)}',
this.file
);
}
}
return this._tooltip;

+ 12
- 6
src/views/nodes/resultsFileNode.ts Ver arquivo

@ -35,8 +35,11 @@ export class ResultsFileNode extends ViewRefFileNode {
const item = new TreeItem(this.label, TreeItemCollapsibleState.None);
item.contextValue = ResourceType.ResultsFile;
item.description = this.description;
// eslint-disable-next-line no-template-curly-in-string
item.tooltip = StatusFileFormatter.fromTemplate('${file}\n${directory}/\n\n${status}', this.file);
item.tooltip = StatusFileFormatter.fromTemplate(
// eslint-disable-next-line no-template-curly-in-string
'${file}\n${directory}/\n\n${status}${ (originalPath)}',
this.file
);
const statusIcon = GitFile.getStatusIcon(this.file.status);
item.iconPath = {
@ -51,10 +54,13 @@ export class ResultsFileNode extends ViewRefFileNode {
private _description: string | undefined;
get description() {
if (this._description === undefined) {
// eslint-disable-next-line no-template-curly-in-string
this._description = StatusFileFormatter.fromTemplate('${directory}', this.file, {
relativePath: this.relativePath
});
this._description = StatusFileFormatter.fromTemplate(
this.view.config.commitFileDescriptionFormat,
this.file,
{
relativePath: this.relativePath
}
);
}
return this._description;
}

+ 3
- 3
src/views/nodes/statusFileNode.ts Ver arquivo

@ -60,7 +60,7 @@ export class StatusFileNode extends ViewNode {
item.contextValue += '+staged';
item.tooltip = StatusFileFormatter.fromTemplate(
// eslint-disable-next-line no-template-curly-in-string
'${file}\n${directory}/\n\n${status} in Index (staged)',
'${file}\n${directory}/\n\n${status}${ (originalPath)} in Index (staged)',
this.file
);
}
@ -68,7 +68,7 @@ export class StatusFileNode extends ViewNode {
item.contextValue += '+unstaged';
item.tooltip = StatusFileFormatter.fromTemplate(
// eslint-disable-next-line no-template-curly-in-string
'${file}\n${directory}/\n\n${status} in Working Tree',
'${file}\n${directory}/\n\n${status}${ (originalPath)} in Working Tree',
this.file
);
}
@ -108,7 +108,7 @@ export class StatusFileNode extends ViewNode {
}
item.tooltip = StatusFileFormatter.fromTemplate(
`\${file}\n\${directory}/\n\n\${status} in ${this.getChangedIn()}`,
`\${file}\n\${directory}/\n\n\${status}\${ (originalPath)} in ${this.getChangedIn()}`,
this.file
);
}

Carregando…
Cancelar
Salvar