Quellcode durchsuchen

Fixes #31 - Disable gitlens if no `.git` folder

main
Eric Amodio vor 7 Jahren
Ursprung
Commit
4d0c18f330
3 geänderte Dateien mit 83 neuen und 18 gelöschten Zeilen
  1. +69
    -15
      package.json
  2. +2
    -1
      src/constants.ts
  3. +12
    -2
      src/extension.ts

+ 69
- 15
package.json Datei anzeigen

@ -378,87 +378,141 @@
}
],
"menus": {
"commandPalette": [
{
"command": "gitlens.diffWithPrevious",
"when": "gitlens:enabled"
},
{
"command": "gitlens.diffLineWithPrevious",
"when": "gitlens:enabled"
},
{
"command": "gitlens.diffWithWorking",
"when": "gitlens:enabled"
},
{
"command": "gitlens.diffLineWithWorking",
"when": "gitlens:enabled"
},
{
"command": "gitlens.showBlame",
"when": "gitlens:enabled"
},
{
"command": "gitlens.toggleBlame",
"when": "gitlens:enabled"
},
{
"command": "gitlens.toggleCodeLens",
"when": "gitlens:enabled"
},
{
"command": "gitlens.showBlameHistory",
"when": "gitlens:enabled"
},
{
"command": "gitlens.showFileHistory",
"when": "gitlens:enabled"
},
{
"command": "gitlens.showQuickCommitDetails",
"when": "gitlens:enabled"
},
{
"command": "gitlens.showQuickFileHistory",
"when": "gitlens:enabled"
},
{
"command": "gitlens.showQuickRepoHistory",
"when": "gitlens:enabled"
},
{
"command": "gitlens.copyShaToClipboard",
"when": "gitlens:enabled"
}
],
"explorer/context": [
{
"command": "gitlens.showQuickFileHistory",
"when": "config.git.enabled",
"when": "gitlens:enabled",
"group": "gitlens"
},
{
"command": "gitlens.diffWithPrevious",
"when": "config.gitlens.menus.diff.enabled && config.git.enabled",
"when": "config.gitlens.menus.diff.enabled && gitlens:enabled",
"group": "gitlens_diff"
},
{
"command": "gitlens.diffWithWorking",
"when": "config.gitlens.menus.diff.enabled && config.git.enabled",
"when": "config.gitlens.menus.diff.enabled && gitlens:enabled",
"group": "gitlens_diff"
}
],
"editor/title": [
{
"command": "gitlens.toggleBlame",
"when": "config.git.enabled",
"when": "gitlens:enabled",
"group": "navigation@100"
},
{
"command": "gitlens.showQuickFileHistory",
"when": "config.git.enabled",
"when": "gitlens:enabled",
"group": "1_gitlens"
},
{
"command": "gitlens.diffWithPrevious",
"when": "config.gitlens.menus.diff.enabled && config.git.enabled",
"when": "config.gitlens.menus.diff.enabled && gitlens:enabled",
"group": "1_gitlens_diff"
},
{
"command": "gitlens.diffWithWorking",
"when": "config.gitlens.menus.diff.enabled && config.git.enabled",
"when": "config.gitlens.menus.diff.enabled && gitlens:enabled",
"group": "1_gitlens_diff"
}
],
"editor/title/context": [
{
"command": "gitlens.toggleBlame",
"when": "config.git.enabled",
"when": "gitlens:enabled",
"group": "gitlens@1"
},
{
"command": "gitlens.showQuickFileHistory",
"when": "config.git.enabled",
"when": "gitlens:enabled",
"group": "gitlens@2"
}
],
"editor/context": [
{
"command": "gitlens.diffLineWithPrevious",
"when": "editorTextFocus && config.gitlens.menus.diff.enabled && config.git.enabled",
"when": "editorTextFocus && config.gitlens.menus.diff.enabled && gitlens:enabled",
"group": "1_gitlens@1"
},
{
"command": "gitlens.diffLineWithWorking",
"when": "editorTextFocus && config.gitlens.menus.diff.enabled && config.git.enabled",
"when": "editorTextFocus && config.gitlens.menus.diff.enabled && gitlens:enabled",
"group": "1_gitlens@2"
},
{
"command": "gitlens.showQuickCommitDetails",
"when": "editorTextFocus && config.git.enabled",
"when": "editorTextFocus && gitlens:enabled",
"group": "1_gitlens@3"
},
{
"command": "gitlens.toggleBlame",
"when": "editorTextFocus && config.git.enabled",
"when": "editorTextFocus && gitlens:enabled",
"group": "2_gitlens@1"
},
{
"command": "gitlens.showQuickFileHistory",
"alt": "gitlens.showFileHistory",
"when": "config.git.enabled",
"when": "gitlens:enabled",
"group": "2_gitlens@2"
},
{
"command": "gitlens.copyShaToClipboard",
"when": "editorTextFocus && config.git.enabled",
"when": "editorTextFocus && gitlens:enabled",
"group": "9_gitlens@1"
}
]

+ 2
- 1
src/constants.ts Datei anzeigen

@ -2,7 +2,7 @@
export const RepoPath = 'repoPath';
export type BuiltInCommands = 'cursorMove' | 'editor.action.showReferences' | 'editor.action.toggleRenderWhitespace' | 'editorScroll' | 'revealLine' | 'vscode.diff' | 'vscode.executeDocumentSymbolProvider' | 'vscode.executeCodeLensProvider';
export type BuiltInCommands = 'cursorMove' | 'editor.action.showReferences' | 'editor.action.toggleRenderWhitespace' | 'editorScroll' | 'revealLine' | 'vscode.diff' | 'vscode.executeDocumentSymbolProvider' | 'vscode.executeCodeLensProvider' | 'setContext';
export const BuiltInCommands = {
CursorMove: 'cursorMove' as BuiltInCommands,
Diff: 'vscode.diff' as BuiltInCommands,
@ -10,6 +10,7 @@ export const BuiltInCommands = {
ExecuteDocumentSymbolProvider: 'vscode.executeDocumentSymbolProvider' as BuiltInCommands,
ExecuteCodeLensProvider: 'vscode.executeCodeLensProvider' as BuiltInCommands,
RevealLine: 'revealLine' as BuiltInCommands,
SetContext: 'setContext' as BuiltInCommands,
ShowReferences: 'editor.action.showReferences' as BuiltInCommands,
ToggleRenderWhitespace: 'editor.action.toggleRenderWhitespace' as BuiltInCommands
};

+ 12
- 2
src/extension.ts Datei anzeigen

@ -1,5 +1,5 @@
'use strict';
import { ExtensionContext, languages, window, workspace } from 'vscode';
import { commands, ExtensionContext, languages, window, workspace } from 'vscode';
import BlameActiveLineController from './blameActiveLineController';
import BlameAnnotationController from './blameAnnotationController';
import { configureCssCharacters } from './blameAnnotationFormatter';
@ -17,7 +17,7 @@ import ShowQuickRepoHistoryCommand from './commands/showQuickRepoHistory';
import ToggleBlameCommand from './commands/toggleBlame';
import ToggleCodeLensCommand from './commands/toggleCodeLens';
import { IAdvancedConfig, IBlameConfig } from './configuration';
import { WorkspaceState } from './constants';
import { BuiltInCommands, WorkspaceState } from './constants';
import GitContentProvider from './gitContentProvider';
import GitProvider, { Git } from './gitProvider';
import GitRevisionCodeLensProvider from './gitRevisionCodeLensProvider';
@ -49,9 +49,19 @@ export async function activate(context: ExtensionContext) {
if (ex.message.includes('Unable to find git')) {
await window.showErrorMessage(`GitLens: Unable to find Git. Please make sure Git is installed. Also ensure that Git is either in the PATH, or that 'gitlens.advanced.git' is pointed to its installed location.`);
}
commands.executeCommand(BuiltInCommands.SetContext, 'gitlens:enabled', false);
return;
}
let gitEnabled = workspace.getConfiguration('git').get<boolean>('enabled');
commands.executeCommand(BuiltInCommands.SetContext, 'gitlens:enabled', gitEnabled);
context.subscriptions.push(workspace.onDidChangeConfiguration(() => {
if (gitEnabled !== workspace.getConfiguration('git').get<boolean>('enabled')) {
gitEnabled = !gitEnabled;
commands.executeCommand(BuiltInCommands.SetContext, 'gitlens:enabled', gitEnabled);
}
}, this));
context.workspaceState.update(WorkspaceState.RepoPath, repoPath);
const git = new GitProvider(context);

Laden…
Abbrechen
Speichern