Procházet zdrojové kódy

Cleans up "welcome" views

Makes them conditional on state
main
Eric Amodio před 4 roky
rodič
revize
81d5137409
22 změnil soubory, kde provedl 123 přidání a 138 odebrání
  1. +12
    -28
      package.json
  2. +3
    -3
      src/annotations/annotationProvider.ts
  3. +6
    -6
      src/annotations/fileAnnotationController.ts
  4. +2
    -2
      src/codelens/codeLensController.ts
  5. +6
    -3
      src/commands/closeView.ts
  6. +4
    -4
      src/commands/showView.ts
  7. +0
    -10
      src/config.ts
  8. +6
    -2
      src/constants.ts
  9. +25
    -20
      src/extension.ts
  10. +4
    -4
      src/git/gitService.ts
  11. +4
    -4
      src/keyboard.ts
  12. +16
    -17
      src/messages.ts
  13. +2
    -2
      src/trackers/documentTracker.ts
  14. +3
    -3
      src/trackers/trackedDocument.ts
  15. +2
    -2
      src/views/commitsView.ts
  16. +5
    -5
      src/views/fileHistoryView.ts
  17. +3
    -3
      src/views/lineHistoryView.ts
  18. +2
    -2
      src/views/repositoriesView.ts
  19. +5
    -5
      src/views/searchAndCompareView.ts
  20. +3
    -3
      src/views/viewCommands.ts
  21. +3
    -3
      src/vsls/guest.ts
  22. +7
    -7
      src/vsls/vsls.ts

+ 12
- 28
package.json Zobrazit soubor

@ -2120,18 +2120,6 @@
"markdownDescription": "Specifies when to switch between displaying files as a `tree` or `list` based on the number of files in a nesting level in the _Tags_ view. Only applies when `#gitlens.views.tags.files.layout#` is set to `auto`",
"scope": "window"
},
"gitlens.views.updates.enabled": {
"type": "boolean",
"default": true,
"markdownDescription": "Specifies whether to show the _Updates_ view",
"scope": "window"
},
"gitlens.views.welcome.enabled": {
"type": "boolean",
"default": true,
"markdownDescription": "Specifies whether to show the _Welcome_ view",
"scope": "window"
},
"gitlens.advanced.abbreviatedShaLength": {
"type": "number",
"default": "7",
@ -7714,58 +7702,54 @@
"viewsWelcome": [
{
"view": "gitlens.views.welcome",
"contents": "GitLens 11 is powerful, feature rich, and highly customizable to meet your needs. You can use the GitLens Welcome experience to get setup quickly.\n\n[Welcome (Quick Setup)](command:gitlens.showWelcomePage \"Opens the GitLens Welcome (Quick Setup)\")\n\nFor more options, use the [GitLens: Open Settings](command:gitlens.showSettingsPage \"Opens the GitLens Interactive Settings\") command from the Command Palette, to open the interactive GitLens settings editor."
"contents": "GitLens 11 is powerful, feature rich, and highly customizable to meet your needs. You can use the GitLens Welcome experience to get setup quickly.\n\n[Welcome (Quick Setup)](command:gitlens.showWelcomePage \"Opens the GitLens Welcome (Quick Setup)\")\n\nFor more options, run [GitLens: Open Settings](command:gitlens.showSettingsPage \"Opens the GitLens Interactive Settings\") from the Command Palette to open the interactive GitLens settings editor."
},
{
"view": "gitlens.views.welcome",
"contents": "You can also quickly switch between different side bar layouts for GitLens views to best match your workflow, via the [GitLens: Set Views Layout](command:gitlens.setViewsLayout \"Changes the GitLens Views Layout\") command from the Command Palette."
"contents": "[GitLens views](command:gitlens.showSettingsPage%23views) are shown on the Source Control side bar, by default. Run [GitLens: Set Views Layout](command:gitlens.setViewsLayout \"Changes the GitLens Views Layout\") from the Command Palette to switch to an alternate side bar layout, or drag & drop them."
},
{
"view": "gitlens.views.welcome",
"contents": "And if you find GitLens useful, please consider sponsoring it.\n\n[Sponsor GitLens ❤](command:gitlens.supportGitLens)"
"contents": "[Sponsor GitLens ❤](command:gitlens.supportGitLens)\n\nIf you find GitLens useful, please consider sponsoring it."
},
{
"view": "gitlens.views.welcome",
"contents": "Once you are satisfied, feel free to [close this view](command:gitlens.closeWelcomeView \"Closes the Welcome view\")."
},
{
"view": "gitlens.views.updates",
"contents": "[What's New in GitLens 11](https://gitlens.amod.io/#whats-new \"Opens the What's New page on the GitLens website\")\n\n[Sponsor GitLens ❤](command:gitlens.supportGitLens)\n\nSee the [release notes](https://github.com/eamodio/vscode-gitlens/blob/master/CHANGELOG.md \"Opens the Release Notes\") for the full set of changes."
"contents": "[Close](command:gitlens.closeWelcomeView \"Closes the Welcome view\")"
},
{
"view": "gitlens.views.updates",
"contents": "VIEW CHANGES (🧀 has been moved)"
"contents": "[GitLens views](command:gitlens.showSettingsPage%23views) have moved to the Source Control side bar.\nRun [GitLens: Set Views Layout](command:gitlens.setViewsLayout \"Changes the GitLens Views Layout\") from the Command Palette to switch to an alternate side bar layout, or drag & drop them."
},
{
"view": "gitlens.views.updates",
"contents": "All [GitLens views](command:gitlens.showSettingsPage%23views) have been moved to the Source Control side bar, by default. You can easily switch between different side bar layouts for GitLens views to best match your workflow, via the [GitLens: Set Views Layout](command:gitlens.setViewsLayout \"Changes the GitLens Views Layout\") command from the Command Palette."
"contents": "★ [Repositories](command:gitlens.showSettingsPage%23repositories-view) — replaced by [Commits](command:gitlens.showSettingsPage%23commits-view), [Branches](command:gitlens.showSettingsPage%23branches-view), [Remotes](command:gitlens.showSettingsPage%23remotes-view), [Stashes](command:gitlens.showSettingsPage%23stashes-view), [Tags](command:gitlens.showSettingsPage%23tags-view), and [Contributors](command:gitlens.showSettingsPage%23contributors-view) views. If you want it back, [click here](command:gitlens.showRepositoriesView)."
},
{
"view": "gitlens.views.updates",
"contents": "The [Repositories](command:gitlens.showSettingsPage%23repositories-view) view has been superseded by many new views: [Commits](command:gitlens.showSettingsPage%23commits-view), [Branches](command:gitlens.showSettingsPage%23branches-view), [Remotes](command:gitlens.showSettingsPage%23remotes-view), [Stashes](command:gitlens.showSettingsPage%23stashes-view), [Tags](command:gitlens.showSettingsPage%23tags-view), and [Contributors](command:gitlens.showSettingsPage%23contributors-view). Although, if you want to continue using the Repositories view, you can [click here](command:gitlens.showRepositoriesView) to re-enable it."
"contents": "★ [File History](command:gitlens.showSettingsPage%23file-history-view) — combines file and line history into a single view"
},
{
"view": "gitlens.views.updates",
"contents": "The Line History view has been integrated directly into the [File History](command:gitlens.showSettingsPage%23file-history-view) view."
"contents": "★ [Search & Compare](command:gitlens.showSettingsPage%23search-compare-view) — combines Search Commits and Compare Commits into a single view"
},
{
"view": "gitlens.views.updates",
"contents": "The Search Commits and Compare Commits views have been combined into a more powerful and user-friendly [Search & Compare](command:gitlens.showSettingsPage%23search-compare-view) view."
"contents": "[Close](command:gitlens.closeUpdatesView)"
}
],
"views": {
"gitlens": [
{
"id": "gitlens.views.updates",
"name": "What's New in GitLens 11",
"when": "config.gitlens.views.updates.enabled",
"name": "Where did my views go?",
"when": "gitlens:views:updates:visible != false",
"contextualTitle": "GitLens",
"icon": "images/gitlens-activitybar.svg"
},
{
"id": "gitlens.views.welcome",
"name": "Welcome",
"when": "config.gitlens.views.welcome.enabled",
"when": "gitlens:views:welcome:visible != false",
"contextualTitle": "GitLens",
"icon": "images/gitlens-activitybar.svg"
}

+ 3
- 3
src/annotations/annotationProvider.ts Zobrazit soubor

@ -11,7 +11,7 @@ import {
window,
} from 'vscode';
import { FileAnnotationType } from '../configuration';
import { CommandContext, setCommandContext } from '../constants';
import { ContextKeys, setContext } from '../constants';
import { Logger } from '../logger';
import { GitDocumentState, TrackedDocument } from '../trackers/gitDocumentTracker';
@ -90,7 +90,7 @@ export abstract class AnnotationProviderBase implements Disposable {
this.status = AnnotationStatus.Computing;
if (editor === window.activeTextEditor) {
await setCommandContext(CommandContext.AnnotationStatus, this.status);
await setContext(ContextKeys.AnnotationStatus, this.status);
}
this.editor = editor;
@ -105,7 +105,7 @@ export abstract class AnnotationProviderBase implements Disposable {
this.status = AnnotationStatus.Computed;
if (editor === window.activeTextEditor) {
await setCommandContext(CommandContext.AnnotationStatus, this.status);
await setContext(ContextKeys.AnnotationStatus, this.status);
}
}

+ 6
- 6
src/annotations/fileAnnotationController.ts Zobrazit soubor

@ -26,7 +26,7 @@ import {
configuration,
FileAnnotationType,
} from '../configuration';
import { CommandContext, isTextEditor, setCommandContext } from '../constants';
import { ContextKeys, isTextEditor, setContext } from '../constants';
import { Container } from '../container';
import { GutterBlameAnnotationProvider } from './gutterBlameAnnotationProvider';
import { GutterChangesAnnotationProvider } from './gutterChangesAnnotationProvider';
@ -238,10 +238,10 @@ export class FileAnnotationController implements Disposable {
const provider = this.getProvider(editor);
if (provider == null) {
void setCommandContext(CommandContext.AnnotationStatus, undefined);
void setContext(ContextKeys.AnnotationStatus, undefined);
void this.detachKeyboardHook();
} else {
void setCommandContext(CommandContext.AnnotationStatus, provider.status);
void setContext(ContextKeys.AnnotationStatus, provider.status);
void this.attachKeyboardHook();
}
}
@ -385,7 +385,7 @@ export class FileAnnotationController implements Disposable {
const provider = await window.withProgress(
{ location: ProgressLocation.Window },
async (progress: Progress<{ message: string }>) => {
await setCommandContext(CommandContext.AnnotationStatus, AnnotationStatus.Computing);
await setContext(ContextKeys.AnnotationStatus, AnnotationStatus.Computing);
const computingAnnotations = this.showAnnotationsCore(
currentProvider,
@ -397,7 +397,7 @@ export class FileAnnotationController implements Disposable {
const provider = await computingAnnotations;
if (editor === this._editor) {
await setCommandContext(CommandContext.AnnotationStatus, provider?.status);
await setContext(ContextKeys.AnnotationStatus, provider?.status);
}
return computingAnnotations;
@ -465,7 +465,7 @@ export class FileAnnotationController implements Disposable {
provider.dispose();
if (this._annotationProviders.size === 0 || key === AnnotationProviderBase.getCorrelationKey(this._editor)) {
await setCommandContext(CommandContext.AnnotationStatus, undefined);
await setContext(ContextKeys.AnnotationStatus, undefined);
await this.detachKeyboardHook();
}

+ 2
- 2
src/codelens/codeLensController.ts Zobrazit soubor

@ -1,7 +1,7 @@
'use strict';
import { ConfigurationChangeEvent, Disposable, languages } from 'vscode';
import { configuration } from '../configuration';
import { CommandContext, setCommandContext } from '../constants';
import { ContextKeys, setContext } from '../constants';
import { Container } from '../container';
import { Logger } from '../logger';
import {
@ -47,7 +47,7 @@ export class GitCodeLensController implements Disposable {
}
this._canToggle = cfg.recentChange.enabled || cfg.authors.enabled;
void setCommandContext(CommandContext.CanToggleCodeLens, this._canToggle);
void setContext(ContextKeys.CanToggleCodeLens, this._canToggle);
}
}

+ 6
- 3
src/commands/closeView.ts Zobrazit soubor

@ -1,6 +1,7 @@
'use strict';
import { configuration } from '../configuration';
import { command, Command, CommandContext, Commands } from './common';
import { ContextKeys, GlobalState, setContext } from '../constants';
import { Container } from '../container';
@command()
export class CloseViewCommand extends Command {
@ -15,10 +16,12 @@ export class CloseViewCommand extends Command {
async execute(command: Commands) {
switch (command) {
case Commands.CloseWelcomeView:
void (await configuration.updateEffective('views', 'welcome', 'enabled', false));
await Container.context.globalState.update(GlobalState.WelcomeViewVisible, false);
await setContext(ContextKeys.ViewsWelcomeVisible, false);
break;
case Commands.CloseUpdatesView:
void (await configuration.updateEffective('views', 'updates', 'enabled', false));
await Container.context.globalState.update(GlobalState.UpdatesViewVisible, false);
await setContext(ContextKeys.ViewsUpdatesVisible, false);
break;
}
}

+ 4
- 4
src/commands/showView.ts Zobrazit soubor

@ -1,8 +1,9 @@
'use strict';
import { commands } from 'vscode';
import { command, Command, CommandContext, Commands } from './common';
import { configuration } from '../configuration';
import { ContextKeys, GlobalState, setContext } from '../constants';
import { Container } from '../container';
import { command, Command, CommandContext, Commands } from './common';
@command()
export class ShowViewCommand extends Command {
@ -55,9 +56,8 @@ export class ShowViewCommand extends Command {
case Commands.ShowTagsView:
return Container.tagsView.show();
case Commands.ShowWelcomeView:
if (!Container.config.views.welcome.enabled) {
await configuration.updateEffective('views', 'welcome', 'enabled', true);
}
await setContext(ContextKeys.ViewsWelcomeVisible, true);
void Container.context.globalState.update(GlobalState.WelcomeViewVisible, true);
void (await commands.executeCommand('gitlens.views.welcome.focus'));
}

+ 0
- 10
src/config.ts Zobrazit soubor

@ -439,8 +439,6 @@ interface ViewsConfigs {
searchAndCompare: SearchAndCompareViewConfig;
stashes: StashesViewConfig;
tags: TagsViewConfig;
updates: UpdatesViewConfig;
welcome: WelcomeViewConfig;
}
export type ViewsConfigKeys = keyof ViewsConfigs;
@ -556,14 +554,6 @@ export interface TagsViewConfig {
files: ViewsFilesConfig;
}
export interface UpdatesViewConfig {
enabled: boolean;
}
export interface WelcomeViewConfig {
enabled: boolean;
}
export interface ViewsFilesConfig {
compact: boolean;
layout: ViewFilesLayout;

+ 6
- 2
src/constants.ts Zobrazit soubor

@ -31,7 +31,7 @@ export enum BuiltInCommands {
ShowReferences = 'editor.action.showReferences',
}
export enum CommandContext {
export enum ContextKeys {
ActiveFileStatus = 'gitlens:activeFileStatus',
AnnotationStatus = 'gitlens:annotationStatus',
CanToggleCodeLens = 'gitlens:canToggleCodeLens',
@ -49,10 +49,12 @@ export enum CommandContext {
ViewsLineHistoryEditorFollowing = 'gitlens:views:lineHistory:editorFollowing',
ViewsRepositoriesAutoRefresh = 'gitlens:views:repositories:autoRefresh',
ViewsSearchAndCompareKeepResults = 'gitlens:views:searchAndCompare:keepResults',
ViewsUpdatesVisible = 'gitlens:views:updates:visible',
ViewsWelcomeVisible = 'gitlens:views:welcome:visible',
Vsls = 'gitlens:vsls',
}
export function setCommandContext(key: CommandContext | string, value: any) {
export function setContext(key: ContextKeys | string, value: any) {
return commands.executeCommand(BuiltInCommands.SetContext, key, value);
}
@ -135,6 +137,8 @@ export enum GlobalState {
Avatars = 'gitlens:avatars',
DisallowConnectionPrefix = 'gitlens:disallow:connection:',
Version = 'gitlensVersion',
UpdatesViewVisible = 'gitlens:views:updates:visible',
WelcomeViewVisible = 'gitlens:views:welcome:visible',
}
export const ImageMimetypes: Record<string, string> = {

+ 25
- 20
src/extension.ts Zobrazit soubor

@ -3,7 +3,7 @@ import { commands, ExtensionContext, extensions, window, workspace } from 'vscod
import { Commands, registerCommands } from './commands';
import { ViewShowBranchComparison } from './config';
import { configuration, Configuration } from './configuration';
import { CommandContext, extensionQualifiedId, GlobalState, GlyphChars, setCommandContext } from './constants';
import { ContextKeys, extensionQualifiedId, GlobalState, GlyphChars, setContext } from './constants';
import { Container } from './container';
import { Git, GitCommit } from './git/git';
import { GitService } from './git/gitService';
@ -17,7 +17,24 @@ export async function activate(context: ExtensionContext) {
const start = process.hrtime();
// Pretend we are enabled (until we know otherwise) and set the view contexts to reduce flashing on load
void setCommandContext(CommandContext.Enabled, true);
void setContext(ContextKeys.Enabled, true);
const previousVersion = context.globalState.get<string>(GlobalState.Version);
if (previousVersion == null) {
void context.globalState.update(GlobalState.WelcomeViewVisible, true);
void setContext(ContextKeys.ViewsWelcomeVisible, true);
void setContext(ContextKeys.ViewsUpdatesVisible, false);
} else {
void setContext(
ContextKeys.ViewsWelcomeVisible,
context.globalState.get(GlobalState.WelcomeViewVisible) ?? false,
);
void setContext(
ContextKeys.ViewsUpdatesVisible,
context.globalState.get(GlobalState.UpdatesViewVisible) !== false,
);
}
Logger.configure(context, configuration.get('outputLevel'), o => {
if (GitUri.is(o)) {
@ -43,8 +60,8 @@ export async function activate(context: ExtensionContext) {
const enabled = workspace.getConfiguration('git', null).get<boolean>('enabled', true);
if (!enabled) {
Logger.log(`GitLens (v${gitlensVersion}) was NOT activated -- "git.enabled": false`);
void setCommandContext(CommandContext.Enabled, false);
void setCommandContext(CommandContext.Disabled, true);
void setContext(ContextKeys.Enabled, false);
void setContext(ContextKeys.Disabled, true);
void Messages.showGitDisabledErrorMessage();
@ -55,14 +72,13 @@ export async function activate(context: ExtensionContext) {
const cfg = configuration.get();
const previousVersion = context.globalState.get<string>(GlobalState.Version);
await migrateSettings(context, previousVersion);
try {
await GitService.initialize();
} catch (ex) {
Logger.error(ex, `GitLens (v${gitlensVersion}) activate`);
void setCommandContext(CommandContext.Enabled, false);
void setContext(ContextKeys.Enabled, false);
const msg: string = ex?.message ?? '';
if (msg.includes('Unable to find git')) {
@ -155,7 +171,7 @@ function notifyOnUnsupportedGitVersion(version: string) {
}
async function showWelcomeOrWhatsNew(version: string, previousVersion: string | undefined) {
if (previousVersion === undefined) {
if (previousVersion == null) {
Logger.log('GitLens first-time install');
await commands.executeCommand(Commands.ShowWelcomePage);
@ -177,18 +193,7 @@ async function showWelcomeOrWhatsNew(version: string, previousVersion: string |
return;
}
if (major !== prevMajor) {
if (Container.config.showWhatsNewAfterUpgrades && Container.config.views.welcome.enabled) {
await commands.executeCommand(Commands.ShowWelcomeView);
}
// if (Container.config.showWhatsNewAfterUpgrades) {
// await Messages.showWhatsNewMessage(version);
// }
// // Show a views upgrade notification
// if (major === 11) {
// await Messages.showViewsUpgradeMessage();
// }
if (major !== prevMajor && Container.config.showWhatsNewAfterUpgrades) {
await Messages.showWhatsNewMessage(version);
}
}

+ 4
- 4
src/git/gitService.ts Zobrazit soubor

@ -21,7 +21,7 @@ import {
import { API as BuiltInGitApi, Repository as BuiltInGitRepository, GitExtension } from '../@types/git';
import { resetAvatarCache } from '../avatars';
import { BranchSorting, configuration, TagSorting } from '../configuration';
import { CommandContext, DocumentSchemes, GlyphChars, setCommandContext } from '../constants';
import { ContextKeys, DocumentSchemes, GlyphChars, setContext } from '../constants';
import { Container } from '../container';
import { LogCorrelationContext, Logger } from '../logger';
import { Messages } from '../messages';
@ -437,7 +437,7 @@ export class GitService implements Disposable {
private async updateContext(repositoryTree: TernarySearchTree<Repository>) {
const hasRepository = repositoryTree.any();
await setCommandContext(CommandContext.Enabled, hasRepository);
await setContext(ContextKeys.Enabled, hasRepository);
let hasRemotes = false;
let hasConnectedRemotes = false;
@ -455,8 +455,8 @@ export class GitService implements Disposable {
}
}
await setCommandContext(CommandContext.HasRemotes, hasRemotes);
await setCommandContext(CommandContext.HasConnectedRemotes, hasConnectedRemotes);
await setContext(ContextKeys.HasRemotes, hasRemotes);
await setContext(ContextKeys.HasConnectedRemotes, hasConnectedRemotes);
// If we have no repositories setup a watcher in case one is initialized
if (!hasRepository) {

+ 4
- 4
src/keyboard.ts Zobrazit soubor

@ -1,6 +1,6 @@
'use strict';
import { commands, Disposable } from 'vscode';
import { CommandContext, extensionId, setCommandContext } from './constants';
import { ContextKeys, extensionId, setContext } from './constants';
import { Logger } from './logger';
import { log } from './system';
@ -84,7 +84,7 @@ export class KeyboardScope implements Disposable {
}
mapping[key] = undefined;
await setCommandContext(`${CommandContext.Key}:${key}`, false);
await setContext(`${ContextKeys.Key}:${key}`, false);
}
@log({
@ -138,12 +138,12 @@ export class KeyboardScope implements Disposable {
mapping[key] = command;
if (!set) {
await setCommandContext(`${CommandContext.Key}:${key}`, true);
await setContext(`${ContextKeys.Key}:${key}`, true);
}
}
private async updateKeyCommandsContext(mapping: KeyMapping) {
await Promise.all(keys.map(key => setCommandContext(`${CommandContext.Key}:${key}`, Boolean(mapping?.[key]))));
await Promise.all(keys.map(key => setContext(`${ContextKeys.Key}:${key}`, Boolean(mapping?.[key]))));
}
}

+ 16
- 17
src/messages.ts Zobrazit soubor

@ -1,6 +1,5 @@
'use strict';
import { commands, ConfigurationTarget, env, MessageItem, Uri, window } from 'vscode';
import { Commands } from './commands';
import { ConfigurationTarget, env, MessageItem, Uri, window } from 'vscode';
import { configuration } from './configuration';
import { GitCommit } from './git/git';
import { Logger } from './logger';
@ -95,21 +94,21 @@ export class Messages {
);
}
static async showViewsUpgradeMessage() {
const openSettings: MessageItem = { title: 'Open Settings' };
const result = await Messages.showMessage(
'info',
'GitLens 11 has replaced the Repositories view with many new views, and integrated the Line History view into the File History view. To re-enable either of these views, open the GitLens Interactive Settings.',
undefined,
null,
openSettings,
);
if (result === openSettings) {
await commands.executeCommand(Commands.ShowSettingsPageAndJumpToRepositoriesView);
}
}
// static async showViewsUpgradeMessage() {
// const openSettings: MessageItem = { title: 'Open Settings' };
// const result = await Messages.showMessage(
// 'info',
// 'GitLens 11 has replaced the Repositories view with many new views, and integrated the Line History view into the File History view. To re-enable either of these views, open the GitLens Interactive Settings.',
// undefined,
// null,
// openSettings,
// );
// if (result === openSettings) {
// await commands.executeCommand(Commands.ShowSettingsPageAndJumpToRepositoriesView);
// }
// }
static async showWhatsNewMessage(version: string) {
const actions: MessageItem[] = [{ title: "What's New" }, { title: 'Release Notes' }, { title: '❤' }];

+ 2
- 2
src/trackers/documentTracker.ts Zobrazit soubor

@ -17,7 +17,7 @@ import {
workspace,
} from 'vscode';
import { configuration } from '../configuration';
import { CommandContext, DocumentSchemes, isActiveDocument, isTextEditor, setCommandContext } from '../constants';
import { ContextKeys, DocumentSchemes, isActiveDocument, isTextEditor, setContext } from '../constants';
import { GitUri } from '../git/gitUri';
import { Functions } from '../system';
import { DocumentBlameStateChangeEvent, TrackedDocument } from './trackedDocument';
@ -120,7 +120,7 @@ export class DocumentTracker implements Disposable {
this._timer = setTimeout(() => {
this._timer = undefined;
void setCommandContext(CommandContext.ActiveFileStatus, undefined);
void setContext(ContextKeys.ActiveFileStatus, undefined);
}, 250);
return;

+ 3
- 3
src/trackers/trackedDocument.ts Zobrazit soubor

@ -1,6 +1,6 @@
'use strict';
import { Disposable, Event, EventEmitter, TextDocument, TextEditor, Uri } from 'vscode';
import { CommandContext, getEditorIfActive, isActiveDocument, setCommandContext } from '../constants';
import { ContextKeys, getEditorIfActive, isActiveDocument, setContext } from '../constants';
import { Container } from '../container';
import { GitRevision, Repository, RepositoryChange, RepositoryChangeEvent } from '../git/git';
import { GitUri } from '../git/gitUri';
@ -126,7 +126,7 @@ export class TrackedDocument implements Disposable {
}
activate() {
void setCommandContext(CommandContext.ActiveFileStatus, this.getStatus());
void setContext(ContextKeys.ActiveFileStatus, this.getStatus());
}
async ensureInitialized() {
@ -203,7 +203,7 @@ export class TrackedDocument implements Disposable {
if (active !== undefined) {
const blameable = this.isBlameable;
void setCommandContext(CommandContext.ActiveFileStatus, this.getStatus());
void setContext(ContextKeys.ActiveFileStatus, this.getStatus());
if (!options.initializing && wasBlameable !== blameable) {
const e: DocumentBlameStateChangeEvent<T> = { editor: active, document: this, blameable: blameable };

+ 2
- 2
src/views/commitsView.ts Zobrazit soubor

@ -9,7 +9,7 @@ import {
window,
} from 'vscode';
import { CommitsViewConfig, configuration, ViewFilesLayout, ViewShowBranchComparison } from '../configuration';
import { CommandContext, GlyphChars, setCommandContext } from '../constants';
import { ContextKeys, GlyphChars, setContext } from '../constants';
import { Container } from '../container';
import {
GitLogCommit,
@ -397,7 +397,7 @@ export class CommitsView extends ViewBase {
}
private setMyCommitsOnly(enabled: boolean) {
void setCommandContext(CommandContext.ViewsCommitsMyCommitsOnly, enabled);
void setContext(ContextKeys.ViewsCommitsMyCommitsOnly, enabled);
this.state.myCommitsOnly = enabled;
void this.refresh(true);
}

+ 5
- 5
src/views/fileHistoryView.ts Zobrazit soubor

@ -1,7 +1,7 @@
'use strict';
import { commands, ConfigurationChangeEvent } from 'vscode';
import { configuration, FileHistoryViewConfig } from '../configuration';
import { CommandContext, setCommandContext } from '../constants';
import { ContextKeys, setContext } from '../constants';
import { Container } from '../container';
import { GitUri } from '../git/gitUri';
import { FileHistoryTrackerNode, LineHistoryTrackerNode } from './nodes';
@ -95,8 +95,8 @@ export class FileHistoryView extends ViewBase
protected initialize(options: { showCollapseAll?: boolean } = {}) {
super.initialize(options);
void setCommandContext(CommandContext.ViewsFileHistoryEditorFollowing, this._followEditor);
void setCommandContext(CommandContext.ViewsFileHistoryCursorFollowing, this._followCursor);
void setContext(ContextKeys.ViewsFileHistoryEditorFollowing, this._followEditor);
void setContext(ContextKeys.ViewsFileHistoryCursorFollowing, this._followCursor);
}
async showHistoryForUri(uri: GitUri, baseRef?: string) {
@ -117,7 +117,7 @@ export class FileHistoryView extends ViewBase
private _followCursor: boolean = false;
private setCursorFollowing(enabled: boolean) {
this._followCursor = enabled;
void setCommandContext(CommandContext.ViewsFileHistoryCursorFollowing, enabled);
void setContext(ContextKeys.ViewsFileHistoryCursorFollowing, enabled);
this.title = this._followCursor ? 'Line History' : 'File History';
@ -130,7 +130,7 @@ export class FileHistoryView extends ViewBase
private _followEditor: boolean = true;
private setEditorFollowing(enabled: boolean) {
this._followEditor = enabled;
void setCommandContext(CommandContext.ViewsFileHistoryEditorFollowing, enabled);
void setContext(ContextKeys.ViewsFileHistoryEditorFollowing, enabled);
this.root?.setEditorFollowing(enabled);
if (this.description?.endsWith(pinnedSuffix)) {

+ 3
- 3
src/views/lineHistoryView.ts Zobrazit soubor

@ -1,7 +1,7 @@
'use strict';
import { commands, ConfigurationChangeEvent } from 'vscode';
import { configuration, LineHistoryViewConfig } from '../configuration';
import { CommandContext, setCommandContext } from '../constants';
import { ContextKeys, setContext } from '../constants';
import { Container } from '../container';
import { LineHistoryTrackerNode } from './nodes';
import { ViewBase } from './viewBase';
@ -61,7 +61,7 @@ export class LineHistoryView extends ViewBase
protected onConfigurationChanged(e: ConfigurationChangeEvent) {
if (configuration.changed(e, 'views', this.configKey, 'enabled')) {
void setCommandContext(CommandContext.ViewsLineHistoryEditorFollowing, true);
void setContext(ContextKeys.ViewsLineHistoryEditorFollowing, true);
}
super.onConfigurationChanged(e);
@ -72,7 +72,7 @@ export class LineHistoryView extends ViewBase
}
private setEditorFollowing(enabled: boolean) {
void setCommandContext(CommandContext.ViewsLineHistoryEditorFollowing, enabled);
void setContext(ContextKeys.ViewsLineHistoryEditorFollowing, enabled);
this.root?.setEditorFollowing(enabled);
if (this.description?.endsWith(pinnedSuffix)) {

+ 2
- 2
src/views/repositoriesView.ts Zobrazit soubor

@ -9,7 +9,7 @@ import {
window,
} from 'vscode';
import { configuration, RepositoriesViewConfig, ViewBranchesLayout, ViewFilesLayout } from '../configuration';
import { CommandContext, setCommandContext, WorkspaceState } from '../constants';
import { ContextKeys, setContext, WorkspaceState } from '../constants';
import { Container } from '../container';
import {
GitBranch,
@ -530,7 +530,7 @@ export class RepositoriesView extends ViewBase
}
}
void setCommandContext(CommandContext.ViewsRepositoriesAutoRefresh, enabled && workspaceEnabled);
void setContext(ContextKeys.ViewsRepositoriesAutoRefresh, enabled && workspaceEnabled);
this._onDidChangeAutoRefresh.fire();
}

+ 5
- 5
src/views/searchAndCompareView.ts Zobrazit soubor

@ -7,7 +7,7 @@ import {
TagSorting,
ViewFilesLayout,
} from '../configuration';
import { CommandContext, NamedRef, PinnedItem, PinnedItems, setCommandContext, WorkspaceState } from '../constants';
import { ContextKeys, NamedRef, PinnedItem, PinnedItems, setContext, WorkspaceState } from '../constants';
import { Container } from '../container';
import { GitLog, GitRevision, SearchPattern } from '../git/git';
import { CompareResultsNode, ContextValues, SearchResultsNode, unknownGitUri, ViewNode } from './nodes';
@ -219,7 +219,7 @@ export class SearchAndCompareViewNode extends ViewNode {
ref: ref,
});
this.children.splice(0, 0, this.comparePicker);
void setCommandContext(CommandContext.ViewsCanCompare, true);
void setContext(ContextKeys.ViewsCanCompare, true);
await this.triggerChange();
@ -237,7 +237,7 @@ export class SearchAndCompareViewNode extends ViewNode {
}
private removeComparePicker(silent: boolean = false) {
void setCommandContext(CommandContext.ViewsCanCompare, false);
void setContext(ContextKeys.ViewsCanCompare, false);
if (this.comparePicker != null) {
const index = this.children.indexOf(this.comparePicker);
if (index !== -1) {
@ -257,7 +257,7 @@ export class SearchAndCompareView extends ViewBase
constructor() {
super('gitlens.views.searchAndCompare', 'Search & Compare');
void setCommandContext(CommandContext.ViewsSearchAndCompareKeepResults, this.keepResults);
void setContext(ContextKeys.ViewsSearchAndCompareKeepResults, this.keepResults);
}
getRoot() {
@ -483,7 +483,7 @@ export class SearchAndCompareView extends ViewBase
private setKeepResults(enabled: boolean) {
void Container.context.workspaceState.update(WorkspaceState.ViewsSearchAndCompareKeepResults, enabled);
void setCommandContext(CommandContext.ViewsSearchAndCompareKeepResults, enabled);
void setContext(ContextKeys.ViewsSearchAndCompareKeepResults, enabled);
}
private setShowAvatars(enabled: boolean) {

+ 3
- 3
src/views/viewCommands.ts Zobrazit soubor

@ -12,7 +12,7 @@ import {
OpenFileOnRemoteCommandArgs,
} from '../commands';
import { configuration, FileAnnotationType, ViewShowBranchComparison } from '../configuration';
import { BuiltInCommands, CommandContext, setCommandContext } from '../constants';
import { BuiltInCommands, ContextKeys, setContext } from '../constants';
import { Container } from '../container';
import { GitReference, GitRevision } from '../git/git';
import { GitUri } from '../git/gitUri';
@ -633,7 +633,7 @@ export class ViewCommands {
const selected = this._selectedFile;
this._selectedFile = undefined;
void setCommandContext(CommandContext.ViewsCanCompareFile, false);
void setContext(ContextKeys.ViewsCanCompareFile, false);
return executeCommand<DiffWithCommandArgs>(Commands.DiffWith, {
repoPath: selected.repoPath,
@ -659,7 +659,7 @@ export class ViewCommands {
repoPath: node.repoPath,
uri: node.uri,
};
void setCommandContext(CommandContext.ViewsCanCompareFile, true);
void setContext(ContextKeys.ViewsCanCompareFile, true);
}
@debug()

+ 3
- 3
src/vsls/guest.ts Zobrazit soubor

@ -1,7 +1,7 @@
'use strict';
import { CancellationToken, Disposable, window, WorkspaceFolder } from 'vscode';
import { LiveShare, SharedServiceProxy } from 'vsls';
import { CommandContext, setCommandContext } from '../constants';
import { ContextKeys, setContext } from '../constants';
import { GitCommandOptions, Repository, RepositoryChangeEvent } from '../git/git';
import { Logger } from '../logger';
import { debug, log } from '../system';
@ -38,11 +38,11 @@ export class VslsGuestService implements Disposable {
@log()
private onAvailabilityChanged(available: boolean) {
if (available) {
void setCommandContext(CommandContext.Enabled, true);
void setContext(ContextKeys.Enabled, true);
return;
}
void setCommandContext(CommandContext.Enabled, false);
void setContext(ContextKeys.Enabled, false);
void window.showWarningMessage(
'GitLens features will be unavailable. Unable to connect to the host GitLens service. The host may have disabled GitLens guest access or may not have GitLens installed.',
);

+ 7
- 7
src/vsls/vsls.ts Zobrazit soubor

@ -1,7 +1,7 @@
'use strict';
import { Disposable, workspace } from 'vscode';
import { getApi, LiveShare, Role, SessionChangeEvent } from 'vsls';
import { CommandContext, DocumentSchemes, setCommandContext } from '../constants';
import { ContextKeys, DocumentSchemes, setContext } from '../constants';
import { Container } from '../container';
import { Logger } from '../logger';
import { VslsGuestService } from './guest';
@ -63,7 +63,7 @@ export class VslsController implements Disposable {
this._api = getApi();
const api = await this._api;
if (api == null) {
void setCommandContext(CommandContext.Vsls, false);
void setContext(ContextKeys.Vsls, false);
// Tear it down if we can't talk to live share
if (this._onReady !== undefined) {
this._onReady();
@ -73,7 +73,7 @@ export class VslsController implements Disposable {
return;
}
void setCommandContext(CommandContext.Vsls, true);
void setContext(ContextKeys.Vsls, true);
this._disposable = Disposable.from(
api.onDidChangeSession(e => this.onLiveShareSessionChanged(api, e), this),
@ -93,7 +93,7 @@ export class VslsController implements Disposable {
}
private setReadonly(value: boolean) {
this._readonly = value;
void setCommandContext(CommandContext.Readonly, value ? true : undefined);
void setContext(ContextKeys.Readonly, value ? true : undefined);
}
@debug()
@ -189,20 +189,20 @@ export class VslsController implements Disposable {
switch (e.session.role) {
case Role.Host:
this.setReadonly(false);
void setCommandContext(CommandContext.Vsls, 'host');
void setContext(ContextKeys.Vsls, 'host');
if (Container.config.liveshare.allowGuestAccess) {
this._host = await VslsHostService.share(api);
}
break;
case Role.Guest:
this.setReadonly(true);
void setCommandContext(CommandContext.Vsls, 'guest');
void setContext(ContextKeys.Vsls, 'guest');
this._guest = await VslsGuestService.connect(api);
break;
default:
this.setReadonly(false);
void setCommandContext(CommandContext.Vsls, true);
void setContext(ContextKeys.Vsls, true);
break;
}

Načítá se…
Zrušit
Uložit