forked from gitkraken/vscode-gitlens
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconstants.search.ts
49 lines (44 loc) · 1.3 KB
/
constants.search.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
type SearchOperatorsShortForm = '' | '=:' | '@:' | '#:' | '?:' | '~:' | 'is:';
export type SearchOperatorsLongForm = 'message:' | 'author:' | 'commit:' | 'file:' | 'change:' | 'type:';
export type SearchOperators = SearchOperatorsShortForm | SearchOperatorsLongForm;
export const searchOperators = new Set<string>([
'',
'=:',
'message:',
'@:',
'author:',
'#:',
'commit:',
'?:',
'file:',
'~:',
'change:',
'is:',
'type:',
]);
export const searchOperatorsToLongFormMap = new Map<SearchOperators, SearchOperatorsLongForm>([
['', 'message:'],
['=:', 'message:'],
['message:', 'message:'],
['@:', 'author:'],
['author:', 'author:'],
['#:', 'commit:'],
['commit:', 'commit:'],
['?:', 'file:'],
['file:', 'file:'],
['~:', 'change:'],
['change:', 'change:'],
['is:', 'type:'],
['type:', 'type:'],
]);
export const searchOperationRegex =
/(?:(?<op>=:|message:|@:|author:|#:|commit:|\?:|file:|~:|change:|is:|type:)\s?(?<value>".+?"|\S+}?))|(?<text>\S+)(?!(?:=|message|@|author|#|commit|\?|file|~|change|is|type):)/g;
export const searchOperationHelpRegex =
/(?:^|(\b|\s)*)((=:|message:|@:|author:|#:|commit:|\?:|file:|~:|change:|is:|type:)(?:"[^"]*"?|\w*))(?:$|(\b|\s))/g;
export interface SearchQuery {
query: string;
filter?: boolean;
matchAll?: boolean;
matchCase?: boolean;
matchRegex?: boolean;
}