Browse Source

Fixes #792 - Adds tips token to commit formatting

main
Eric Amodio 5 years ago
parent
commit
9b9d10f5d1
12 changed files with 232 additions and 521 deletions
  1. +1
    -0
      CHANGELOG.md
  2. +1
    -1
      package.json
  3. +3
    -1
      src/annotations/annotations.ts
  4. +7
    -1
      src/annotations/gutterBlameAnnotationProvider.ts
  5. +8
    -1
      src/annotations/lineAnnotationController.ts
  6. +1
    -1
      src/configuration.ts
  7. +9
    -159
      src/extension.ts
  8. +28
    -4
      src/git/formatters/commitFormatter.ts
  9. +7
    -12
      src/views/nodes/commitNode.ts
  10. +11
    -1
      src/webviews/apps/scss/popup.scss
  11. +146
    -337
      src/webviews/apps/settings/index.html
  12. +10
    -3
      src/webviews/apps/shared/appWithConfigBase.ts

+ 1
- 0
CHANGELOG.md View File

@ -9,6 +9,7 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/) and this p
### Fixed
- Fixes [#791](https://github.com/eamodio/vscode-gitlens/issues/791) - Notification of unstashed changes in working directory on failed checkout
- Fixes [#792](https://github.com/eamodio/vscode-gitlens/issues/792) - Show last commit message on repositories view instead of Git reference
## [9.8.5] - 2019-07-10

+ 1
- 1
package.json View File

@ -1277,7 +1277,7 @@
},
"gitlens.views.commitFormat": {
"type": "string",
"default": "${message}",
"default": "${❰ tips ❱➤ }${message}",
"markdownDescription": "Specifies the format of committed changes in the views. See [_Commit Tokens_](https://github.com/eamodio/vscode-gitlens/wiki/Custom-Formatting#commit-tokens) in the GitLens docs",
"scope": "window"
},

+ 3
- 1
src/annotations/annotations.ts View File

@ -326,7 +326,8 @@ export class Annotations {
// editorLine: number,
format: string,
dateFormat: string | null,
scrollable: boolean = true
scrollable: boolean = true,
getBranchAndTagTips?: (sha: string) => string | undefined
): Partial<DecorationOptions> {
// TODO: Enable this once there is better caching
// let diffUris;
@ -336,6 +337,7 @@ export class Annotations {
const message = CommitFormatter.fromTemplate(format, commit, {
dateFormat: dateFormat,
getBranchAndTagTips: getBranchAndTagTips,
// previousLineDiffUris: diffUris,
truncateMessageAtNewLine: true
});

+ 7
- 1
src/annotations/gutterBlameAnnotationProvider.ts View File

@ -3,7 +3,7 @@ import { DecorationOptions, Range, TextEditorDecorationType, window } from 'vsco
import { FileAnnotationType, GravatarDefaultStyle } from '../configuration';
import { GlyphChars } from '../constants';
import { Container } from '../container';
import { CommitFormatOptions, GitBlameCommit } from '../git/gitService';
import { CommitFormatOptions, CommitFormatter, GitBlameCommit } from '../git/gitService';
import { Logger } from '../logger';
import { log, Objects, Strings } from '../system';
import { Annotations } from './annotations';
@ -31,8 +31,14 @@ export class GutterBlameAnnotationProvider extends BlameAnnotationProviderBase {
return map;
}, Object.create(null));
let getBranchAndTagTips;
if (CommitFormatter.has(cfg.format, 'tips')) {
getBranchAndTagTips = await Container.git.getBranchesAndTagsTipsFn(blame.repoPath);
}
const options: CommitFormatOptions = {
dateFormat: cfg.dateFormat === null ? Container.config.defaultDateFormat : cfg.dateFormat,
getBranchAndTagTips: getBranchAndTagTips,
tokenOptions: tokenOptions
};

+ 8
- 1
src/annotations/lineAnnotationController.ts View File

@ -16,6 +16,7 @@ import { LinesChangeEvent } from '../trackers/gitLineTracker';
import { Annotations } from './annotations';
import { debug, log } from '../system';
import { Logger } from '../logger';
import { CommitFormatter } from '../git/gitService';
const annotationDecoration: TextEditorDecorationType = window.createTextEditorDecorationType({
after: {
@ -178,6 +179,11 @@ export class LineAnnotationController implements Disposable {
cc.exitDetails = ` ${GlyphChars.Dot} line(s)=${lines.join()}`;
}
let getBranchAndTagTips;
if (CommitFormatter.has(cfg.format, 'tips')) {
getBranchAndTagTips = await Container.git.getBranchesAndTagsTipsFn(trackedDocument.uri.repoPath);
}
const decorations = [];
for (const l of lines) {
const state = Container.lineTracker.getState(l);
@ -189,7 +195,8 @@ export class LineAnnotationController implements Disposable {
// l,
cfg.format,
cfg.dateFormat === null ? Container.config.defaultDateFormat : cfg.dateFormat,
cfg.scrollable
cfg.scrollable,
getBranchAndTagTips
) as DecorationOptions;
decoration.range = editor.document.validateRange(
new Range(l, Number.MAX_SAFE_INTEGER, l, Number.MAX_SAFE_INTEGER)

+ 1
- 1
src/configuration.ts View File

@ -71,7 +71,7 @@ export class Configuration {
affectsConfiguration: (section: string, resource?: Uri) => true
};
get<T>(section?: string, resource?: Uri | null, defaultValue?: T) {
get<T>(section?: string, resource?: Uri | null, defaultValue?: T): T {
return defaultValue === undefined
? workspace
.getConfiguration(section === undefined ? undefined : extensionId, resource!)

+ 9
- 159
src/extension.ts View File

@ -1,7 +1,7 @@
'use strict';
import { commands, ExtensionContext, extensions, window, workspace } from 'vscode';
import { Commands, registerCommands } from './commands';
import { ModeConfig, ViewShowBranchComparison } from './config';
import { ViewShowBranchComparison } from './config';
import { Config, configuration, Configuration } from './configuration';
import { CommandContext, extensionQualifiedId, GlobalState, GlyphChars, setCommandContext } from './constants';
import { Container } from './container';
@ -105,7 +105,14 @@ async function migrateSettings(context: ExtensionContext, previousVersion: strin
const previous = Versions.fromString(previousVersion);
try {
if (Versions.compare(previous, Versions.from(9, 8, 2)) !== 1) {
if (Versions.compare(previous, Versions.from(9, 8, 5)) !== 1) {
const name = configuration.name('views')('commitFormat').value;
const value = configuration.get<string>(name);
if (!/\btips\b/.test(value)) {
await configuration.updateEffective(name, `\${ tips }${value}`);
}
}
else if (Versions.compare(previous, Versions.from(9, 8, 2)) !== 1) {
const name = configuration.name('views')('repositories')('showBranchComparison').value;
await configuration.migrate(name, name, {
migrationFn: (v: boolean) => (v === false ? false : ViewShowBranchComparison.Working)
@ -141,163 +148,6 @@ async function migrateSettings(context: ExtensionContext, previousVersion: strin
)
);
}
else if (Versions.compare(previous, Versions.from(9, 2, 2)) !== 1) {
await configuration.migrate('views.avatars', configuration.name('views')('compare')('avatars').value);
await configuration.migrate('views.avatars', configuration.name('views')('repositories')('avatars').value);
await configuration.migrate('views.avatars', configuration.name('views')('search')('avatars').value);
}
else if (Versions.compare(previous, Versions.from(9, 0, 0)) !== 1) {
await configuration.migrate(
'gitExplorer.autoRefresh',
configuration.name('views')('repositories')('autoRefresh').value
);
await configuration.migrate(
'gitExplorer.branches.layout',
configuration.name('views')('repositories')('branches')('layout').value
);
await configuration.migrate(
'gitExplorer.enabled',
configuration.name('views')('repositories')('enabled').value
);
await configuration.migrate(
'gitExplorer.files.compact',
configuration.name('views')('repositories')('files')('compact').value
);
await configuration.migrate(
'gitExplorer.files.layout',
configuration.name('views')('repositories')('files')('layout').value
);
await configuration.migrate(
'gitExplorer.files.threshold',
configuration.name('views')('repositories')('files')('threshold').value
);
await configuration.migrate(
'gitExplorer.includeWorkingTree',
configuration.name('views')('repositories')('includeWorkingTree').value
);
await configuration.migrate(
'gitExplorer.location',
configuration.name('views')('repositories')('location').value
);
await configuration.migrate(
'gitExplorer.showTrackingBranch',
configuration.name('views')('repositories')('showTrackingBranch').value
);
await configuration.migrate(
'historyExplorer.avatars',
configuration.name('views')('fileHistory')('avatars').value
);
await configuration.migrate(
'historyExplorer.enabled',
configuration.name('views')('fileHistory')('enabled').value
);
await configuration.migrate(
'historyExplorer.location',
configuration.name('views')('fileHistory')('location').value
);
await configuration.migrate(
'historyExplorer.avatars',
configuration.name('views')('lineHistory')('avatars').value
);
await configuration.migrate(
'historyExplorer.enabled',
configuration.name('views')('lineHistory')('enabled').value
);
await configuration.migrate(
'historyExplorer.location',
configuration.name('views')('lineHistory')('location').value
);
await configuration.migrate(
'resultsExplorer.files.compact',
configuration.name('views')('compare')('files')('compact').value
);
await configuration.migrate(
'resultsExplorer.files.layout',
configuration.name('views')('compare')('files')('layout').value
);
await configuration.migrate(
'resultsExplorer.files.threshold',
configuration.name('views')('compare')('files')('threshold').value
);
await configuration.migrate(
'resultsExplorer.location',
configuration.name('views')('compare')('location').value
);
await configuration.migrate(
'resultsExplorer.files.compact',
configuration.name('views')('search')('files')('compact').value
);
await configuration.migrate(
'resultsExplorer.files.layout',
configuration.name('views')('search')('files')('layout').value
);
await configuration.migrate(
'resultsExplorer.files.threshold',
configuration.name('views')('search')('files')('threshold').value
);
await configuration.migrate(
'resultsExplorer.location',
configuration.name('views')('search')('location').value
);
await configuration.migrate('explorers.avatars', configuration.name('views')('compare')('avatars').value);
await configuration.migrate(
'explorers.avatars',
configuration.name('views')('repositories')('avatars').value
);
await configuration.migrate('explorers.avatars', configuration.name('views')('search')('avatars').value);
await configuration.migrate(
'explorers.commitFileFormat',
configuration.name('views')('commitFileFormat').value
);
await configuration.migrate('explorers.commitFormat', configuration.name('views')('commitFormat').value);
await configuration.migrate(
'explorers.defaultItemLimit',
configuration.name('views')('defaultItemLimit').value
);
await configuration.migrate(
'explorers.stashFileFormat',
configuration.name('views')('stashFileFormat').value
);
await configuration.migrate('explorers.stashFormat', configuration.name('views')('stashFormat').value);
await configuration.migrate(
'explorers.statusFileFormat',
configuration.name('views')('statusFileFormat').value
);
await configuration.migrate<
{
[key: string]: {
name: string;
statusBarItemName?: string;
description?: string;
codeLens?: boolean;
currentLine?: boolean;
explorers?: boolean;
hovers?: boolean;
statusBar?: boolean;
};
},
{
[key: string]: ModeConfig;
}
>('modes', configuration.name('modes').value, {
migrationFn: v => {
const modes = Object.create(null);
for (const k in v) {
const { explorers, ...mode } = v[k];
modes[k] = { ...mode, views: explorers };
}
return modes;
}
});
}
}
catch (ex) {
Logger.error(ex, 'migrateSettings');

+ 28
- 4
src/git/formatters/commitFormatter.ts View File

@ -22,10 +22,12 @@ const emptyStr = '';
const escapeMarkdownRegex = /[`>#*_\-+.]/g;
// const sampleMarkdown = '## message `not code` *not important* _no underline_ \n> don\'t quote me \n- don\'t list me \n+ don\'t list me \n1. don\'t list me \nnot h1 \n=== \nnot h2 \n---\n***\n---\n___';
const markdownHeaderReplacement = `${GlyphChars.ZeroWidthSpace}===`;
const hasTokenRegexMap = new Map<string, RegExp>();
export interface CommitFormatOptions extends FormatOptions {
annotationType?: FileAnnotationType;
dateStyle?: DateStyle;
getBranchAndTagTips?: (sha: string) => string | undefined;
line?: number;
markdown?: boolean;
presence?: ContactPresence;
@ -39,12 +41,17 @@ export interface CommitFormatOptions extends FormatOptions {
author?: Strings.TokenOptions;
authorAgo?: Strings.TokenOptions;
authorAgoOrDate?: Strings.TokenOptions;
authorDate?: Strings.TokenOptions;
changes?: Strings.TokenOptions;
changesShort?: Strings.TokenOptions;
committerAgo?: Strings.TokenOptions;
committerAgoOrDate?: Strings.TokenOptions;
committerDate?: Strings.TokenOptions;
date?: Strings.TokenOptions;
email?: Strings.TokenOptions;
id?: Strings.TokenOptions;
message?: Strings.TokenOptions;
tips?: Strings.TokenOptions;
};
}
@ -117,7 +124,7 @@ export class CommitFormatter extends Formatter {
}
get authorDate() {
return this._padOrTruncate(this._authorDate, this._options.tokenOptions.date);
return this._padOrTruncate(this._authorDate, this._options.tokenOptions.authorDate);
}
get avatar() {
@ -247,15 +254,15 @@ export class CommitFormatter extends Formatter {
}
get committerAgo() {
return this._padOrTruncate(this._committerDateAgo, this._options.tokenOptions.ago);
return this._padOrTruncate(this._committerDateAgo, this._options.tokenOptions.committerAgo);
}
get committerAgoOrDate() {
return this._padOrTruncate(this._committerDateOrAgo, this._options.tokenOptions.agoOrDate);
return this._padOrTruncate(this._committerDateOrAgo, this._options.tokenOptions.committerAgoOrDate);
}
get committerDate() {
return this._padOrTruncate(this._committerDate, this._options.tokenOptions.date);
return this._padOrTruncate(this._committerDate, this._options.tokenOptions.committerDate);
}
get date() {
@ -327,6 +334,13 @@ export class CommitFormatter extends Formatter {
return this.id;
}
get tips() {
const branchAndTagTips = this._options.getBranchAndTagTips && this._options.getBranchAndTagTips(this._item.sha);
if (branchAndTagTips === undefined) return emptyStr;
return this._padOrTruncate(branchAndTagTips, this._options.tokenOptions.tips);
}
static fromTemplate(template: string, commit: GitCommit, dateFormat: string | null): string;
static fromTemplate(template: string, commit: GitCommit, options?: CommitFormatOptions): string;
static fromTemplate(
@ -341,4 +355,14 @@ export class CommitFormatter extends Formatter {
): string {
return super.fromTemplateCore(this, template, commit, dateFormatOrOptions);
}
static has(format: string, token: string) {
let regex = hasTokenRegexMap.get(token);
if (regex === undefined) {
regex = new RegExp(`\\b${token}\\b`);
hasTokenRegexMap.set(token, regex);
}
return regex.test(format);
}
}

+ 7
- 12
src/views/nodes/commitNode.ts View File

@ -53,16 +53,12 @@ export class CommitNode extends ViewRefNode {
}
getTreeItem(): TreeItem {
let label = CommitFormatter.fromTemplate(this.view.config.commitFormat, this.commit, {
truncateMessageAtNewLine: true,
dateFormat: Container.config.defaultDateFormat
const label = CommitFormatter.fromTemplate(this.view.config.commitFormat, this.commit, {
dateFormat: Container.config.defaultDateFormat,
getBranchAndTagTips: this.getBranchAndTagTips,
truncateMessageAtNewLine: true
});
const branchAndTagTips = this.getBranchAndTagTips && this.getBranchAndTagTips(this.commit.sha);
if (branchAndTagTips !== undefined) {
label = `${GlyphChars.AngleBracketLeftHeavy}${GlyphChars.SpaceThin}${branchAndTagTips}${GlyphChars.SpaceThin}${GlyphChars.AngleBracketRightHeavy}${GlyphChars.ArrowHeadRight}${GlyphChars.Space} ${label}`;
}
const item = new TreeItem(label, TreeItemCollapsibleState.Collapsed);
item.contextValue = ResourceType.Commit;
if (this.branch !== undefined && this.branch.current) {
@ -86,12 +82,11 @@ export class CommitNode extends ViewRefNode {
item.tooltip = CommitFormatter.fromTemplate(
this.commit.isUncommitted
? `\${author} ${GlyphChars.Dash} \${id}\n\${ago} (\${date})`
: `\${author} \${(email) }${GlyphChars.Dash} \${id}${
branchAndTagTips !== undefined ? ` (${branchAndTagTips})` : ''
}\n\${ago} (\${date})\n\n\${message}`,
: `\${author} \${(email) }${GlyphChars.Dash} \${id}\${ (tips)}\n\${ago} (\${date})\n\n\${message}`,
this.commit,
{
dateFormat: Container.config.defaultDateFormat
dateFormat: Container.config.defaultDateFormat,
getBranchAndTagTips: this.getBranchAndTagTips
}
);

+ 11
- 1
src/webviews/apps/scss/popup.scss View File

@ -4,7 +4,9 @@
padding: 1em;
position: absolute;
top: 46px;
width: 410px;
width: 80vw;
min-width: 373px;
max-width: 472px;
z-index: 1;
&:before {
@ -35,6 +37,13 @@
}
}
.token-popup__scroller {
margin-right: -0.4em;
max-height: 35vh;
overflow-y: scroll;
padding-right: 0.4em;
}
.token-popup__hint {
color: var(--color-foreground--75);
display: inline-block;
@ -78,6 +87,7 @@
& td:last-child {
padding-right: 12px;
text-align: end;
}
}

+ 146
- 337
src/webviews/apps/settings/index.html View File

@ -7,6 +7,118 @@
-->
</head>
<template id="token-popup">
<h3 class="token-popup__title">Available Tokens</h3>
<div class="token-popup__scroller">
<table class="token-popup__table">
<tbody>
<tr>
<td>Commit Id</td>
<td><span class="token" data-token="id">id</span></td>
</tr>
<tr>
<td>Commit Author</td>
<td><span class="token" data-token="author">author</span></td>
</tr>
<tr>
<td>Commit Author E-mail</td>
<td><span class="token" data-token="email">email</span></td>
</tr>
<tr>
<td>Commit Message</td>
<td><span class="token" data-token="message">message</span></td>
</tr>
<tr>
<td>
Commit or Authored Date<br /><i
>Relative, e.g. 1 day ago<br />Committed vs Authored based on setting</i
>
</td>
<td><span class="token" data-token="ago">ago</span></td>
</tr>
<tr>
<td>
Commit or Authored Date<br /><i
>Absolute, e.g. August 8th, 2016 10:48am<br />Committed vs Authored based on setting</i
>
</td>
<td><span class="token" data-token="date">date</span></td>
</tr>
<tr>
<td>
Commit or Authored Date<br /><i
>Relative or absolute based on date setting<br />Committed vs Authored based on
setting</i
>
</td>
<td><span class="token" data-token="agoOrDate">agoOrDate</span></td>
</tr>
<tr>
<td>Authored Date<br /><i>Relative date</i></td>
<td><span class="token" data-token="authorAgo">authorAgo</span></td>
</tr>
<tr>
<td>Authored Date<br /><i>Absolute, e.g. August 8th, 2016 10:48am</i></td>
<td><span class="token" data-token="authorDate">authorDate</span></td>
</tr>
<tr>
<td>Authored Date<br /><i>Relative or absolute date based on date setting</i></td>
<td><span class="token" data-token="authorAgoOrDate">authorAgoOrDate</span></td>
</tr>
<tr>
<td>Commit Date<br /><i>Relative date</i></td>
<td><span class="token" data-token="committerAgo">committerAgo</span></td>
</tr>
<tr>
<td>Commit Date<br /><i>Absolute, e.g. August 8th, 2016 10:48am</i></td>
<td><span class="token" data-token="committerDate">committerDate</span></td>
</tr>
<tr>
<td>Commit Date<br /><i>Relative or absolute date based on date setting</i></td>
<td><span class="token" data-token="committerAgoOrDate">committerAgoOrDate</span></td>
</tr>
<tr>
<td>Branch & Tag Tips<br /><i>Indicates if the commit is a tip of any branches or tags</i></td>
<td><span class="token" data-token="tips">tips</span></td>
</tr>
<!-- <tr>
<td>
Changes Indicator<br /><i
>Indicates adds, changes, renames, and deletes<br />e.g +1 ~3 -0</i
>
</td>
<td><span class="token" data-token="changes">changes</span></td>
</tr>
<tr>
<td>
Changes Indicator (short)<br /><i
>Indicates adds, changes, renames, and deletes<br />e.g +1~3</i
>
</td>
<td><span class="token" data-token="changesShort">changesShort</span></td>
</tr> -->
<!-- <tr>
<td>Author Avatar</td>
<td><span class="token" data-token="avatar">avatar</span></td>
</tr> -->
<!-- <tr>
<td>
Commands<br /><i>Set of commit command buttons<br />only valid in hovers</i>
</td>
<td><span class="token" data-token="commands">commands</span></td>
</tr> -->
</tbody>
</table>
</div>
<span class="token-popup__hint">
<i class="icon icon__info"></i>
<a href="https://github.com/eamodio/vscode-gitlens/wiki/Custom-Formatting" title="Open formatting docs"
>Learn more</a
>
about formatting options
</span>
</template>
<body class="preload">
<div class="container">
<div class="content">
@ -337,10 +449,7 @@
<label for="menus.editor">Add commands to the editor context menu</label>
</div>
<div
class="settings-group__setting nowrap ml-4"
data-enablement="menus.editor"
>
<div class="settings-group__setting nowrap ml-4" data-enablement="menus.editor">
<input
class="setting"
id="menus.editor.compare"
@ -352,10 +461,7 @@
<label for="menus.editor.compare">Add comparison commands</label>
</div>
<div
class="settings-group__setting nowrap ml-4"
data-enablement="menus.editor"
>
<div class="settings-group__setting nowrap ml-4" data-enablement="menus.editor">
<input
class="setting"
id="menus.editor.remote"
@ -367,10 +473,7 @@
<label for="menus.editor.remote">Add open on remote commands</label>
</div>
<div
class="settings-group__setting nowrap ml-4"
data-enablement="menus.editor"
>
<div class="settings-group__setting nowrap ml-4" data-enablement="menus.editor">
<input
class="setting"
id="menus.editor.details"
@ -382,10 +485,7 @@
<label for="menus.editor.details">Add commit details commands</label>
</div>
<div
class="settings-group__setting nowrap ml-4"
data-enablement="menus.editor"
>
<div class="settings-group__setting nowrap ml-4" data-enablement="menus.editor">
<input
class="setting"
id="menus.editor.history"
@ -397,10 +497,7 @@
<label for="menus.editor.history">Add file history commands</label>
</div>
<div
class="settings-group__setting nowrap ml-4"
data-enablement="menus.editor"
>
<div class="settings-group__setting nowrap ml-4" data-enablement="menus.editor">
<input
class="setting"
id="menus.editor.blame"
@ -412,10 +509,7 @@
<label for="menus.editor.blame">Add blame commands</label>
</div>
<div
class="settings-group__setting nowrap ml-4"
data-enablement="menus.editor"
>
<div class="settings-group__setting nowrap ml-4" data-enablement="menus.editor">
<input
class="setting"
id="menus.editor.clipboard"
@ -440,10 +534,7 @@
<label for="menus.editorTab">Add commands to the editor tab context menu</label>
</div>
<div
class="settings-group__setting nowrap ml-4"
data-enablement="menus.editorTab"
>
<div class="settings-group__setting nowrap ml-4" data-enablement="menus.editorTab">
<input
class="setting"
id="menus.editorTab.remote"
@ -455,10 +546,7 @@
<label for="menus.editorTab.remote">Add open on remote commands</label>
</div>
<div
class="settings-group__setting nowrap ml-4"
data-enablement="menus.editorTab"
>
<div class="settings-group__setting nowrap ml-4" data-enablement="menus.editorTab">
<input
class="setting"
id="menus.editorTab.compare"
@ -470,10 +558,7 @@
<label for="menus.editorTab.compare">Add comparison commands</label>
</div>
<div
class="settings-group__setting nowrap ml-4"
data-enablement="menus.editorTab"
>
<div class="settings-group__setting nowrap ml-4" data-enablement="menus.editorTab">
<input
class="setting"
id="menus.editorTab.history"
@ -485,10 +570,7 @@
<label for="menus.editorTab.history">Add file history commands</label>
</div>
<div
class="settings-group__setting nowrap ml-4"
data-enablement="menus.editorTab"
>
<div class="settings-group__setting nowrap ml-4" data-enablement="menus.editorTab">
<input
class="setting"
id="menus.editorTab.clipboard"
@ -558,10 +640,7 @@
>
</div>
<div
class="settings-group__setting nowrap ml-4"
data-enablement="menus.explorer"
>
<div class="settings-group__setting nowrap ml-4" data-enablement="menus.explorer">
<input
class="setting"
id="menus.explorer.remote"
@ -573,10 +652,7 @@
<label for="menus.explorer.remote">Add open on remote commands</label>
</div>
<div
class="settings-group__setting nowrap ml-4"
data-enablement="menus.explorer"
>
<div class="settings-group__setting nowrap ml-4" data-enablement="menus.explorer">
<input
class="setting"
id="menus.explorer.compare"
@ -588,10 +664,7 @@
<label for="menus.explorer.compare">Add comparison commands</label>
</div>
<div
class="settings-group__setting nowrap ml-4"
data-enablement="menus.explorer"
>
<div class="settings-group__setting nowrap ml-4" data-enablement="menus.explorer">
<input
class="setting"
id="menus.explorer.history"
@ -603,10 +676,7 @@
<label for="menus.explorer.history">Add file history commands</label>
</div>
<div
class="settings-group__setting nowrap ml-4"
data-enablement="menus.explorer"
>
<div class="settings-group__setting nowrap ml-4" data-enablement="menus.explorer">
<input
class="setting"
id="menus.explorer.clipboard"
@ -633,10 +703,7 @@
>
</div>
<div
class="settings-group__setting nowrap ml-4"
data-enablement="menus.scmGroup"
>
<div class="settings-group__setting nowrap ml-4" data-enablement="menus.scmGroup">
<input
class="setting"
id="menus.scmGroup.stashInline"
@ -650,10 +717,7 @@
>
</div>
<div
class="settings-group__setting nowrap ml-4"
data-enablement="menus.scmGroup"
>
<div class="settings-group__setting nowrap ml-4" data-enablement="menus.scmGroup">
<input
class="setting"
id="menus.scmGroup.openClose"
@ -667,10 +731,7 @@
>
</div>
<div
class="settings-group__setting nowrap ml-4"
data-enablement="menus.scmGroup"
>
<div class="settings-group__setting nowrap ml-4" data-enablement="menus.scmGroup">
<input
class="setting"
id="menus.scmGroup.compare"
@ -682,10 +743,7 @@
<label for="menus.scmGroup.compare">Add comparison commands</label>
</div>
<div
class="settings-group__setting nowrap ml-4"
data-enablement="menus.scmGroup"
>
<div class="settings-group__setting nowrap ml-4" data-enablement="menus.scmGroup">
<input
class="setting"
id="menus.scmGroup.stash"
@ -712,10 +770,7 @@
>
</div>
<div
class="settings-group__setting nowrap ml-4"
data-enablement="menus.scmItem"
>
<div class="settings-group__setting nowrap ml-4" data-enablement="menus.scmItem">
<input
class="setting"
id="menus.scmItem.remote"
@ -727,10 +782,7 @@
<label for="menus.scmItem.remote">Add open on remote commands</label>
</div>
<div
class="settings-group__setting nowrap ml-4"
data-enablement="menus.scmItem"
>
<div class="settings-group__setting nowrap ml-4" data-enablement="menus.scmItem">
<input
class="setting"
id="menus.scmItem.compare"
@ -742,10 +794,7 @@
<label for="menus.scmItem.compare">Add comparison commands</label>
</div>
<div
class="settings-group__setting nowrap ml-4"
data-enablement="menus.scmItem"
>
<div class="settings-group__setting nowrap ml-4" data-enablement="menus.scmItem">
<input
class="setting"
id="menus.scmItem.history"
@ -757,10 +806,7 @@
<label for="menus.scmItem.history">Add file history command</label>
</div>
<div
class="settings-group__setting nowrap ml-4"
data-enablement="menus.scmItem"
>
<div class="settings-group__setting nowrap ml-4" data-enablement="menus.scmItem">
<input
class="setting"
id="menus.scmItem.stash"
@ -772,10 +818,7 @@
<label for="menus.scmItem.stash">Add stash changes command</label>
</div>
<div
class="settings-group__setting nowrap ml-4"
data-enablement="menus.scmItem"
>
<div class="settings-group__setting nowrap ml-4" data-enablement="menus.scmItem">
<input
class="setting"
id="menus.scmItem.clipboard"
@ -850,77 +893,7 @@
<label for="currentLine.format" title="See available tokens">
<i class="icon icon__info"></i>
</label>
<div id="currentLine.format.popup" class="popup hidden">
<h3 class="token-popup__title">Available Tokens</h3>
<table class="token-popup__table">
<tbody>
<tr>
<td>Commit Id</td>
<td><span class="token" data-token="id">id</span></td>
</tr>
<tr>
<td>Commit Author</td>
<td><span class="token" data-token="author">author</span></td>
</tr>
<tr>
<td>Commit Message</td>
<td><span class="token" data-token="message">message</span></td>
</tr>
<tr>
<td>
Commit Date <br />
<i>Relative, e.g. 1 day ago</i>
</td>
<td><span class="token" data-token="ago">ago</span></td>
</tr>
<tr>
<td>
Commit Date <br />
<i>Absolute, e.g. August 8th, 2016 10:48am</i>
</td>
<td><span class="token" data-token="date">date</span></td>
</tr>
<tr>
<td>
Commit Date <br />
<i>Relative or absolute based on date setting</i>
</td>
<td>
<span class="token" data-token="agoOrDate">agoOrDate</span>
</td>
</tr>
<tr>
<td>
Commit Author, Commit Date <br />
<i>Relative date</i>
</td>
<td>
<span class="token" data-token="authorAgo">authorAgo</span>
</td>
</tr>
<tr>
<td>
Commit Author, Commit Date <br />
<i>Relative or absolute date</i>
</td>
<td>
<span class="token" data-token="authorAgoOrDate"
>authorAgoOrDate</span
>
</td>
</tr>
</tbody>
</table>
<span class="token-popup__hint">
<i class="icon icon__info"></i>
<a
href="https://github.com/eamodio/vscode-gitlens/wiki/Advanced-Formatting"
title="Open advanced formatting docs"
>Learn more</a
>
about advanced formatting options
</span>
</div>
<div id="currentLine.format.popup" class="popup hidden"></div>
</div>
<div
@ -1021,77 +994,7 @@
<label for="blame.format" title="See available tokens">
<i class="icon icon__info"></i>
</label>
<div id="blame.format.popup" class="popup hidden">
<h3 class="token-popup__title">Available Tokens</h3>
<table class="token-popup__table">
<tbody>
<tr>
<td>Commit Id</td>
<td><span class="token" data-token="id">id</span></td>
</tr>
<tr>
<td>Commit Author</td>
<td><span class="token" data-token="author">author</span></td>
</tr>
<tr>
<td>Commit Message</td>
<td><span class="token" data-token="message">message</span></td>
</tr>
<tr>
<td>
Commit Date <br />
<i>Relative, e.g. 1 day ago</i>
</td>
<td><span class="token" data-token="ago">ago</span></td>
</tr>
<tr>
<td>
Commit Date <br />
<i>Absolute, e.g. August 8th, 2016 10:48am</i>
</td>
<td><span class="token" data-token="date">date</span></td>
</tr>
<tr>
<td>
Commit Date <br />
<i>Relative or absolute based on date setting</i>
</td>
<td>
<span class="token" data-token="agoOrDate">agoOrDate</span>
</td>
</tr>
<tr>
<td>
Commit Author, Commit Date <br />
<i>Relative date</i>
</td>
<td>
<span class="token" data-token="authorAgo">authorAgo</span>
</td>
</tr>
<tr>
<td>
Commit Author, Commit Date <br />
<i>Relative or absolute date</i>
</td>
<td>
<span class="token" data-token="authorAgoOrDate"
>authorAgoOrDate</span
>
</td>
</tr>
</tbody>
</table>
<span class="token-popup__hint">
<i class="icon icon__info"></i>
<a
href="https://github.com/eamodio/vscode-gitlens/wiki/Advanced-Formatting"
title="Open advanced formatting docs"
>Learn more</a
>
about advanced formatting options
</span>
</div>
<div id="blame.format.popup" class="popup hidden"></div>
</div>
<div class="settings-group__setting nowrap">
@ -1324,10 +1227,7 @@
<label for="hovers.enabled">Show blame hovers</label>
</div>
<div
class="settings-group__setting nowrap ml-2"
data-enablement="hovers.enabled"
>
<div class="settings-group__setting nowrap ml-2" data-enablement="hovers.enabled">
<input
class="setting"
id="hovers.avatars"
@ -1784,16 +1684,10 @@
</select>
</div>
<div
class="settings-group__setting nowrap ml-2"
data-enablement="codeLens.enabled"
>
<div class="settings-group__setting nowrap ml-2" data-enablement="codeLens.enabled">
<label class="non-interactive">Add code lens to the following scopes</label>
</div>
<div
class="settings-group__setting nowrap ml-4"
data-enablement="codeLens.enabled"
>
<div class="settings-group__setting nowrap ml-4" data-enablement="codeLens.enabled">
<input
class="setting"
id="codeLens.scopes"
@ -1807,10 +1701,7 @@
>File scope &mdash; added at the top of the file</label
>
</div>
<div
class="settings-group__setting nowrap ml-4"
data-enablement="codeLens.enabled"
>
<div class="settings-group__setting nowrap ml-4" data-enablement="codeLens.enabled">
<input
class="setting"
id="codeLens.scopes-1"
@ -1825,10 +1716,7 @@
etc
</label>
</div>
<div
class="settings-group__setting nowrap ml-4"
data-enablement="codeLens.enabled"
>
<div class="settings-group__setting nowrap ml-4" data-enablement="codeLens.enabled">
<input
class="setting"
id="codeLens.scopes-2"
@ -2145,77 +2033,7 @@
<label for="statusBar.format" title="See available tokens">
<i class="icon icon__info"></i>
</label>
<div id="statusBar.format.popup" class="popup hidden">
<h3 class="token-popup__title">Available Tokens</h3>
<table class="token-popup__table">
<tbody>
<tr>
<td>Commit Id</td>
<td><span class="token" data-token="id">id</span></td>
</tr>
<tr>
<td>Commit Author</td>
<td><span class="token" data-token="author">author</span></td>
</tr>
<tr>
<td>Commit Message</td>
<td><span class="token" data-token="message">message</span></td>
</tr>
<tr>
<td>
Commit Date <br />
<i>Relative, e.g. 1 day ago</i>
</td>
<td><span class="token" data-token="ago">ago</span></td>
</tr>
<tr>
<td>
Commit Date <br />
<i>Absolute, e.g. August 8th, 2016 10:48am</i>
</td>
<td><span class="token" data-token="date">date</span></td>
</tr>
<tr>
<td>
Commit Date <br />
<i>Relative or absolute based on date setting</i>
</td>
<td>
<span class="token" data-token="agoOrDate">agoOrDate</span>
</td>
</tr>
<tr>
<td>
Commit Author, Commit Date <br />
<i>Relative date</i>
</td>
<td>
<span class="token" data-token="authorAgo">authorAgo</span>
</td>
</tr>
<tr>
<td>
Commit Author, Commit Date <br />
<i>Relative or absolute date</i>
</td>
<td>
<span class="token" data-token="authorAgoOrDate"
>authorAgoOrDate</span
>
</td>
</tr>
</tbody>
</table>
<span class="token-popup__hint">
<i class="icon icon__info"></i>
<a
href="https://github.com/eamodio/vscode-gitlens/wiki/Advanced-Formatting"
title="Open advanced formatting docs"
>Learn more</a
>
about advanced formatting options
</span>
</div>
<div id="statusBar.format.popup" class="popup hidden"></div>
</div>
<div class="settings-group__setting ml-2" data-enablement="statusBar.enabled">
@ -2231,10 +2049,7 @@
</select>
</div>
<div
class="settings-group__setting ml-2"
data-enablement="statusBar.enabled"
>
<div class="settings-group__setting ml-2" data-enablement="statusBar.enabled">
<label for="statusBar.command">When clicked</label>
<select
class="setting"
@ -2736,10 +2551,7 @@
</select>
</div>
<div
class="settings-group__setting ml-2"
data-enablement="views.search.enabled"
>
<div class="settings-group__setting ml-2" data-enablement="views.search.enabled">
<label for="views.search.files.layout">Layout files</label>
<select
class="setting"
@ -2867,10 +2679,7 @@
</select>
</div>
<div
class="settings-group__setting ml-2"
data-enablement="views.compare.enabled"
>
<div class="settings-group__setting ml-2" data-enablement="views.compare.enabled">
<label for="views.compare.files.layout">Layout files</label>
<select
class="setting"

+ 10
- 3
src/webviews/apps/shared/appWithConfigBase.ts View File

@ -37,9 +37,6 @@ export abstract class AppWithConfig e
DOM.listenAll('select.setting', 'change', function(this: HTMLSelectElement) {
return me.onInputSelected(this);
});
DOM.listenAll('[data-token]', 'mousedown', function(this: HTMLElement, e: Event) {
return me.onTokenMouseDown(this, e as MouseEvent);
});
DOM.listenAll('.popup', 'mousedown', function(this: HTMLElement, e: Event) {
return me.onPopupMouseDown(this, e as MouseEvent);
});
@ -165,6 +162,11 @@ export abstract class AppWithConfig e
const popup = document.getElementById(`${element.name}.popup`);
if (popup != null) {
if (popup.childElementCount === 0) {
const template = document.querySelector('#token-popup') as HTMLTemplateElement;
const instance = document.importNode(template.content, true);
popup.appendChild(instance);
}
popup.classList.remove('hidden');
}
}
@ -185,6 +187,11 @@ export abstract class AppWithConfig e
// e.stopPropagation();
// e.stopImmediatePropagation();
e.preventDefault();
const el = e.target as HTMLElement;
if (el && el.matches('[data-token]')) {
this.onTokenMouseDown(el, e);
}
}
protected onTokenMouseDown(element: HTMLElement, e: MouseEvent) {

Loading…
Cancel
Save