You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

225 lines
6.5 KiB

  1. 'use strict';
  2. import { commands, TextDocument, TextEditor, window } from 'vscode';
  3. import { ViewShowBranchComparison } from './config';
  4. import { SearchPattern } from './git/git';
  5. export const applicationInsightsKey = 'a9c302f8-6483-4d01-b92c-c159c799c679';
  6. export const extensionId = 'gitlens';
  7. export const extensionOutputChannelName = 'GitLens';
  8. export const extensionQualifiedId = `eamodio.${extensionId}`;
  9. export const extensionTerminalName = 'GitLens';
  10. export const quickPickTitleMaxChars = 80;
  11. export enum BuiltInCommands {
  12. CloseActiveEditor = 'workbench.action.closeActiveEditor',
  13. CloseAllEditors = 'workbench.action.closeAllEditors',
  14. CursorMove = 'cursorMove',
  15. Diff = 'vscode.diff',
  16. EditorScroll = 'editorScroll',
  17. ExecuteDocumentSymbolProvider = 'vscode.executeDocumentSymbolProvider',
  18. ExecuteCodeLensProvider = 'vscode.executeCodeLensProvider',
  19. FocusFilesExplorer = 'workbench.files.action.focusFilesExplorer',
  20. Open = 'vscode.open',
  21. OpenFolder = 'vscode.openFolder',
  22. OpenInTerminal = 'openInTerminal',
  23. NextEditor = 'workbench.action.nextEditor',
  24. PreviewHtml = 'vscode.previewHtml',
  25. RevealLine = 'revealLine',
  26. SetContext = 'setContext',
  27. ShowExplorerActivity = 'workbench.view.explorer',
  28. ShowReferences = 'editor.action.showReferences',
  29. }
  30. export enum ContextKeys {
  31. ActiveFileStatus = 'gitlens:activeFileStatus',
  32. AnnotationStatus = 'gitlens:annotationStatus',
  33. DisabledToggleCodeLens = 'gitlens:disabledToggleCodeLens',
  34. Disabled = 'gitlens:disabled',
  35. Enabled = 'gitlens:enabled',
  36. HasRemotes = 'gitlens:hasRemotes',
  37. HasConnectedRemotes = 'gitlens:hasConnectedRemotes',
  38. Key = 'gitlens:key',
  39. Readonly = 'gitlens:readonly',
  40. ViewsCanCompare = 'gitlens:views:canCompare',
  41. ViewsCanCompareFile = 'gitlens:views:canCompare:file',
  42. ViewsCommitsMyCommitsOnly = 'gitlens:views:commits:myCommitsOnly',
  43. ViewsFileHistoryCanPin = 'gitlens:views:fileHistory:canPin',
  44. ViewsFileHistoryCursorFollowing = 'gitlens:views:fileHistory:cursorFollowing',
  45. ViewsFileHistoryEditorFollowing = 'gitlens:views:fileHistory:editorFollowing',
  46. ViewsLineHistoryEditorFollowing = 'gitlens:views:lineHistory:editorFollowing',
  47. ViewsRepositoriesAutoRefresh = 'gitlens:views:repositories:autoRefresh',
  48. ViewsSearchAndCompareKeepResults = 'gitlens:views:searchAndCompare:keepResults',
  49. ViewsUpdatesVisible = 'gitlens:views:updates:visible',
  50. ViewsWelcomeVisible = 'gitlens:views:welcome:visible',
  51. Vsls = 'gitlens:vsls',
  52. }
  53. export function setContext(key: ContextKeys | string, value: any) {
  54. return commands.executeCommand(BuiltInCommands.SetContext, key, value);
  55. }
  56. export enum DocumentSchemes {
  57. DebugConsole = 'debug',
  58. File = 'file',
  59. Git = 'git',
  60. GitLens = 'gitlens',
  61. Output = 'output',
  62. PRs = 'pr',
  63. Vsls = 'vsls',
  64. }
  65. export function getEditorIfActive(document: TextDocument): TextEditor | undefined {
  66. const editor = window.activeTextEditor;
  67. return editor != null && editor.document === document ? editor : undefined;
  68. }
  69. export function isActiveDocument(document: TextDocument): boolean {
  70. const editor = window.activeTextEditor;
  71. return editor != null && editor.document === document;
  72. }
  73. export function isTextEditor(editor: TextEditor): boolean {
  74. const scheme = editor.document.uri.scheme;
  75. return scheme !== DocumentSchemes.Output && scheme !== DocumentSchemes.DebugConsole;
  76. }
  77. export function hasVisibleTextEditor(): boolean {
  78. if (window.visibleTextEditors.length === 0) return false;
  79. return window.visibleTextEditors.some(e => isTextEditor(e));
  80. }
  81. export enum GlyphChars {
  82. AngleBracketLeftHeavy = '\u2770',
  83. AngleBracketRightHeavy = '\u2771',
  84. ArrowBack = '\u21a9',
  85. ArrowDown = '\u2193',
  86. ArrowDropRight = '\u2937',
  87. ArrowHeadRight = '\u27A4',
  88. ArrowLeft = '\u2190',
  89. ArrowLeftDouble = '\u21d0',
  90. ArrowLeftRight = '\u2194',
  91. ArrowLeftRightDouble = '\u21d4',
  92. ArrowLeftRightDoubleStrike = '\u21ce',
  93. ArrowLeftRightLong = '\u27f7',
  94. ArrowRight = '\u2192',
  95. ArrowRightDouble = '\u21d2',
  96. ArrowRightHollow = '\u21e8',
  97. ArrowUp = '\u2191',
  98. ArrowUpRight = '\u2197',
  99. ArrowsHalfLeftRight = '\u21cb',
  100. ArrowsHalfRightLeft = '\u21cc',
  101. ArrowsLeftRight = '\u21c6',
  102. ArrowsRightLeft = '\u21c4',
  103. Asterisk = '\u2217',
  104. Check = '\u2713',
  105. Dash = '\u2014',
  106. Dot = '\u2022',
  107. Ellipsis = '\u2026',
  108. EnDash = '\u2013',
  109. Envelope = '\u2709',
  110. EqualsTriple = '\u2261',
  111. Flag = '\u2691',
  112. FlagHollow = '\u2690',
  113. MiddleEllipsis = '\u22EF',
  114. MuchLessThan = '\u226A',
  115. MuchGreaterThan = '\u226B',
  116. Pencil = '\u270E',
  117. Space = '\u00a0',
  118. SpaceThin = '\u2009',
  119. SpaceThinnest = '\u200A',
  120. SquareWithBottomShadow = '\u274F',
  121. SquareWithTopShadow = '\u2750',
  122. ZeroWidthSpace = '\u200b',
  123. }
  124. export enum SyncedState {
  125. Version = 'gitlens:synced:version',
  126. UpdatesViewVisible = 'gitlens:views:updates:visible',
  127. WelcomeViewVisible = 'gitlens:views:welcome:visible',
  128. }
  129. export enum GlobalState {
  130. DeprecatedVersion = 'gitlensVersion',
  131. Avatars = 'gitlens:avatars',
  132. DisallowConnectionPrefix = 'gitlens:disallow:connection:',
  133. Version = 'gitlens:version',
  134. }
  135. export const ImageMimetypes: Record<string, string> = {
  136. '.png': 'image/png',
  137. '.gif': 'image/gif',
  138. '.jpg': 'image/jpeg',
  139. '.jpeg': 'image/jpeg',
  140. '.jpe': 'image/jpeg',
  141. '.webp': 'image/webp',
  142. '.tif': 'image/tiff',
  143. '.tiff': 'image/tiff',
  144. '.bmp': 'image/bmp',
  145. };
  146. export interface BranchComparison {
  147. ref: string;
  148. notation: '..' | '...' | undefined;
  149. type: Exclude<ViewShowBranchComparison, false> | undefined;
  150. }
  151. export interface BranchComparisons {
  152. [id: string]: string | BranchComparison;
  153. }
  154. export interface NamedRef {
  155. label?: string;
  156. ref: string;
  157. }
  158. export interface PinnedComparison {
  159. type: 'comparison';
  160. timestamp: number;
  161. path: string;
  162. ref1: NamedRef;
  163. ref2: NamedRef;
  164. notation?: '..' | '...';
  165. }
  166. export interface PinnedSearch {
  167. type: 'search';
  168. timestamp: number;
  169. path: string;
  170. labels: {
  171. label: string;
  172. queryLabel:
  173. | string
  174. | {
  175. label: string;
  176. resultsType?: { singular: string; plural: string };
  177. };
  178. };
  179. search: SearchPattern;
  180. }
  181. export type PinnedItem = PinnedComparison | PinnedSearch;
  182. export interface PinnedItems {
  183. [id: string]: PinnedItem;
  184. }
  185. export interface StarredBranches {
  186. [id: string]: boolean;
  187. }
  188. export interface StarredRepositories {
  189. [id: string]: boolean;
  190. }
  191. export enum WorkspaceState {
  192. BranchComparisons = 'gitlens:branch:comparisons',
  193. DefaultRemote = 'gitlens:remote:default',
  194. DeprecatedPinnedComparisons = 'gitlens:pinned:comparisons',
  195. StarredBranches = 'gitlens:starred:branches',
  196. StarredRepositories = 'gitlens:starred:repositories',
  197. ViewsRepositoriesAutoRefresh = 'gitlens:views:repositories:autoRefresh',
  198. ViewsSearchAndCompareKeepResults = 'gitlens:views:searchAndCompare:keepResults',
  199. ViewsSearchAndComparePinnedItems = 'gitlens:views:searchAndCompare:pinned',
  200. }