@theia/search-in-workspace 1.53.0-next.4 → 1.53.0-next.55
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +40 -40
- package/lib/browser/search-in-workspace-frontend-contribution.js +4 -4
- package/lib/node/ripgrep-search-in-workspace-server.slow-spec.js +28 -28
- package/package.json +9 -9
- package/src/browser/components/search-in-workspace-input.tsx +139 -139
- package/src/browser/components/search-in-workspace-textarea.tsx +153 -153
- package/src/browser/search-in-workspace-context-key-service.ts +93 -93
- package/src/browser/search-in-workspace-factory.ts +59 -59
- package/src/browser/search-in-workspace-frontend-contribution.ts +510 -510
- package/src/browser/search-in-workspace-frontend-module.ts +83 -83
- package/src/browser/search-in-workspace-label-provider.ts +48 -48
- package/src/browser/search-in-workspace-preferences.ts +96 -96
- package/src/browser/search-in-workspace-result-tree-widget.tsx +1318 -1318
- package/src/browser/search-in-workspace-service.ts +152 -152
- package/src/browser/search-in-workspace-widget.tsx +727 -727
- package/src/browser/search-layout-migrations.ts +53 -53
- package/src/browser/styles/index.css +400 -400
- package/src/browser/styles/search.svg +6 -6
- package/src/common/search-in-workspace-interface.ts +153 -153
- package/src/node/ripgrep-search-in-workspace-server.slow-spec.ts +1073 -1073
- package/src/node/ripgrep-search-in-workspace-server.ts +490 -490
- package/src/node/search-in-workspace-backend-module.ts +33 -33
|
@@ -1,153 +1,153 @@
|
|
|
1
|
-
// *****************************************************************************
|
|
2
|
-
// Copyright (C) 2021 Ericsson and others.
|
|
3
|
-
//
|
|
4
|
-
// This program and the accompanying materials are made available under the
|
|
5
|
-
// terms of the Eclipse Public License v. 2.0 which is available at
|
|
6
|
-
// http://www.eclipse.org/legal/epl-2.0.
|
|
7
|
-
//
|
|
8
|
-
// This Source Code may also be made available under the following Secondary
|
|
9
|
-
// Licenses when the conditions for such availability set forth in the Eclipse
|
|
10
|
-
// Public License v. 2.0 are satisfied: GNU General Public License, version 2
|
|
11
|
-
// with the GNU Classpath Exception which is available at
|
|
12
|
-
// https://www.gnu.org/software/classpath/license.html.
|
|
13
|
-
//
|
|
14
|
-
// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
|
|
15
|
-
// *****************************************************************************
|
|
16
|
-
|
|
17
|
-
import { Key, KeyCode } from '@theia/core/lib/browser';
|
|
18
|
-
import * as React from '@theia/core/shared/react';
|
|
19
|
-
import TextareaAutosize from 'react-autosize-textarea';
|
|
20
|
-
import debounce = require('@theia/core/shared/lodash.debounce');
|
|
21
|
-
|
|
22
|
-
interface HistoryState {
|
|
23
|
-
history: string[];
|
|
24
|
-
index: number;
|
|
25
|
-
};
|
|
26
|
-
type TextareaAttributes = React.TextareaHTMLAttributes<HTMLTextAreaElement>;
|
|
27
|
-
|
|
28
|
-
export class SearchInWorkspaceTextArea extends React.Component<TextareaAttributes, HistoryState> {
|
|
29
|
-
static LIMIT = 100;
|
|
30
|
-
|
|
31
|
-
private textarea = React.createRef<HTMLTextAreaElement>();
|
|
32
|
-
|
|
33
|
-
constructor(props: TextareaAttributes) {
|
|
34
|
-
super(props);
|
|
35
|
-
this.state = {
|
|
36
|
-
history: [],
|
|
37
|
-
index: 0,
|
|
38
|
-
};
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
updateState(index: number, history?: string[]): void {
|
|
42
|
-
this.value = history ? history[index] : this.state.history[index];
|
|
43
|
-
this.setState(prevState => {
|
|
44
|
-
const newState = {
|
|
45
|
-
...prevState,
|
|
46
|
-
index,
|
|
47
|
-
};
|
|
48
|
-
if (history) {
|
|
49
|
-
newState.history = history;
|
|
50
|
-
}
|
|
51
|
-
return newState;
|
|
52
|
-
});
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
get value(): string {
|
|
56
|
-
return this.textarea.current?.value ?? '';
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
set value(value: string) {
|
|
60
|
-
if (this.textarea.current) {
|
|
61
|
-
this.textarea.current.value = value;
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
/**
|
|
66
|
-
* Handle history navigation without overriding the parent's onKeyDown handler, if any.
|
|
67
|
-
*/
|
|
68
|
-
protected readonly onKeyDown = (e: React.KeyboardEvent<HTMLTextAreaElement>): void => {
|
|
69
|
-
// Navigate history only when cursor is at first or last position of the textarea
|
|
70
|
-
if (Key.ARROW_UP.keyCode === KeyCode.createKeyCode(e.nativeEvent).key?.keyCode && e.currentTarget.selectionStart === 0) {
|
|
71
|
-
e.preventDefault();
|
|
72
|
-
this.previousValue();
|
|
73
|
-
} else if (Key.ARROW_DOWN.keyCode === KeyCode.createKeyCode(e.nativeEvent).key?.keyCode && e.currentTarget.selectionEnd === e.currentTarget.value.length) {
|
|
74
|
-
e.preventDefault();
|
|
75
|
-
this.nextValue();
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
// Prevent newline on enter
|
|
79
|
-
if (Key.ENTER.keyCode === KeyCode.createKeyCode(e.nativeEvent).key?.keyCode && !e.nativeEvent.shiftKey) {
|
|
80
|
-
e.preventDefault();
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
this.props.onKeyDown?.(e);
|
|
84
|
-
};
|
|
85
|
-
|
|
86
|
-
/**
|
|
87
|
-
* Switch the textarea's text to the previous value, if any.
|
|
88
|
-
*/
|
|
89
|
-
previousValue(): void {
|
|
90
|
-
const { history, index } = this.state;
|
|
91
|
-
if (!this.value) {
|
|
92
|
-
this.value = history[index];
|
|
93
|
-
} else if (index > 0 && index < history.length) {
|
|
94
|
-
this.updateState(index - 1);
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
/**
|
|
99
|
-
* Switch the textarea's text to the next value, if any.
|
|
100
|
-
*/
|
|
101
|
-
nextValue(): void {
|
|
102
|
-
const { history, index } = this.state;
|
|
103
|
-
if (index === history.length - 1) {
|
|
104
|
-
this.value = '';
|
|
105
|
-
} else if (!this.value) {
|
|
106
|
-
this.value = history[index];
|
|
107
|
-
} else if (index >= 0 && index < history.length - 1) {
|
|
108
|
-
this.updateState(index + 1);
|
|
109
|
-
}
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
/**
|
|
113
|
-
* Handle history collection and textarea resizing without overriding the parent's onChange handler, if any.
|
|
114
|
-
*/
|
|
115
|
-
protected readonly onChange = (e: React.ChangeEvent<HTMLTextAreaElement>): void => {
|
|
116
|
-
this.addToHistory();
|
|
117
|
-
this.props.onChange?.(e);
|
|
118
|
-
};
|
|
119
|
-
|
|
120
|
-
/**
|
|
121
|
-
* Add a nonempty current value to the history, if not already present. (Debounced, 1 second delay.)
|
|
122
|
-
*/
|
|
123
|
-
readonly addToHistory = debounce(this.doAddToHistory, 1000);
|
|
124
|
-
|
|
125
|
-
private doAddToHistory(): void {
|
|
126
|
-
if (!this.value) {
|
|
127
|
-
return;
|
|
128
|
-
}
|
|
129
|
-
const history = this.state.history
|
|
130
|
-
.filter(term => term !== this.value)
|
|
131
|
-
.concat(this.value)
|
|
132
|
-
.slice(-SearchInWorkspaceTextArea.LIMIT);
|
|
133
|
-
this.updateState(history.length - 1, history);
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
override render(): React.ReactNode {
|
|
137
|
-
const { onResize, ...filteredProps } = this.props;
|
|
138
|
-
return (
|
|
139
|
-
<TextareaAutosize
|
|
140
|
-
{...filteredProps}
|
|
141
|
-
autoCapitalize="off"
|
|
142
|
-
autoCorrect="off"
|
|
143
|
-
maxRows={7} /* from VS Code */
|
|
144
|
-
onChange={this.onChange}
|
|
145
|
-
onKeyDown={this.onKeyDown}
|
|
146
|
-
ref={this.textarea}
|
|
147
|
-
rows={1}
|
|
148
|
-
spellCheck={false}
|
|
149
|
-
>
|
|
150
|
-
</TextareaAutosize>
|
|
151
|
-
);
|
|
152
|
-
}
|
|
153
|
-
}
|
|
1
|
+
// *****************************************************************************
|
|
2
|
+
// Copyright (C) 2021 Ericsson and others.
|
|
3
|
+
//
|
|
4
|
+
// This program and the accompanying materials are made available under the
|
|
5
|
+
// terms of the Eclipse Public License v. 2.0 which is available at
|
|
6
|
+
// http://www.eclipse.org/legal/epl-2.0.
|
|
7
|
+
//
|
|
8
|
+
// This Source Code may also be made available under the following Secondary
|
|
9
|
+
// Licenses when the conditions for such availability set forth in the Eclipse
|
|
10
|
+
// Public License v. 2.0 are satisfied: GNU General Public License, version 2
|
|
11
|
+
// with the GNU Classpath Exception which is available at
|
|
12
|
+
// https://www.gnu.org/software/classpath/license.html.
|
|
13
|
+
//
|
|
14
|
+
// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
|
|
15
|
+
// *****************************************************************************
|
|
16
|
+
|
|
17
|
+
import { Key, KeyCode } from '@theia/core/lib/browser';
|
|
18
|
+
import * as React from '@theia/core/shared/react';
|
|
19
|
+
import TextareaAutosize from 'react-autosize-textarea';
|
|
20
|
+
import debounce = require('@theia/core/shared/lodash.debounce');
|
|
21
|
+
|
|
22
|
+
interface HistoryState {
|
|
23
|
+
history: string[];
|
|
24
|
+
index: number;
|
|
25
|
+
};
|
|
26
|
+
type TextareaAttributes = React.TextareaHTMLAttributes<HTMLTextAreaElement>;
|
|
27
|
+
|
|
28
|
+
export class SearchInWorkspaceTextArea extends React.Component<TextareaAttributes, HistoryState> {
|
|
29
|
+
static LIMIT = 100;
|
|
30
|
+
|
|
31
|
+
private textarea = React.createRef<HTMLTextAreaElement>();
|
|
32
|
+
|
|
33
|
+
constructor(props: TextareaAttributes) {
|
|
34
|
+
super(props);
|
|
35
|
+
this.state = {
|
|
36
|
+
history: [],
|
|
37
|
+
index: 0,
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
updateState(index: number, history?: string[]): void {
|
|
42
|
+
this.value = history ? history[index] : this.state.history[index];
|
|
43
|
+
this.setState(prevState => {
|
|
44
|
+
const newState = {
|
|
45
|
+
...prevState,
|
|
46
|
+
index,
|
|
47
|
+
};
|
|
48
|
+
if (history) {
|
|
49
|
+
newState.history = history;
|
|
50
|
+
}
|
|
51
|
+
return newState;
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
get value(): string {
|
|
56
|
+
return this.textarea.current?.value ?? '';
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
set value(value: string) {
|
|
60
|
+
if (this.textarea.current) {
|
|
61
|
+
this.textarea.current.value = value;
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* Handle history navigation without overriding the parent's onKeyDown handler, if any.
|
|
67
|
+
*/
|
|
68
|
+
protected readonly onKeyDown = (e: React.KeyboardEvent<HTMLTextAreaElement>): void => {
|
|
69
|
+
// Navigate history only when cursor is at first or last position of the textarea
|
|
70
|
+
if (Key.ARROW_UP.keyCode === KeyCode.createKeyCode(e.nativeEvent).key?.keyCode && e.currentTarget.selectionStart === 0) {
|
|
71
|
+
e.preventDefault();
|
|
72
|
+
this.previousValue();
|
|
73
|
+
} else if (Key.ARROW_DOWN.keyCode === KeyCode.createKeyCode(e.nativeEvent).key?.keyCode && e.currentTarget.selectionEnd === e.currentTarget.value.length) {
|
|
74
|
+
e.preventDefault();
|
|
75
|
+
this.nextValue();
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
// Prevent newline on enter
|
|
79
|
+
if (Key.ENTER.keyCode === KeyCode.createKeyCode(e.nativeEvent).key?.keyCode && !e.nativeEvent.shiftKey) {
|
|
80
|
+
e.preventDefault();
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
this.props.onKeyDown?.(e);
|
|
84
|
+
};
|
|
85
|
+
|
|
86
|
+
/**
|
|
87
|
+
* Switch the textarea's text to the previous value, if any.
|
|
88
|
+
*/
|
|
89
|
+
previousValue(): void {
|
|
90
|
+
const { history, index } = this.state;
|
|
91
|
+
if (!this.value) {
|
|
92
|
+
this.value = history[index];
|
|
93
|
+
} else if (index > 0 && index < history.length) {
|
|
94
|
+
this.updateState(index - 1);
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
/**
|
|
99
|
+
* Switch the textarea's text to the next value, if any.
|
|
100
|
+
*/
|
|
101
|
+
nextValue(): void {
|
|
102
|
+
const { history, index } = this.state;
|
|
103
|
+
if (index === history.length - 1) {
|
|
104
|
+
this.value = '';
|
|
105
|
+
} else if (!this.value) {
|
|
106
|
+
this.value = history[index];
|
|
107
|
+
} else if (index >= 0 && index < history.length - 1) {
|
|
108
|
+
this.updateState(index + 1);
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
/**
|
|
113
|
+
* Handle history collection and textarea resizing without overriding the parent's onChange handler, if any.
|
|
114
|
+
*/
|
|
115
|
+
protected readonly onChange = (e: React.ChangeEvent<HTMLTextAreaElement>): void => {
|
|
116
|
+
this.addToHistory();
|
|
117
|
+
this.props.onChange?.(e);
|
|
118
|
+
};
|
|
119
|
+
|
|
120
|
+
/**
|
|
121
|
+
* Add a nonempty current value to the history, if not already present. (Debounced, 1 second delay.)
|
|
122
|
+
*/
|
|
123
|
+
readonly addToHistory = debounce(this.doAddToHistory, 1000);
|
|
124
|
+
|
|
125
|
+
private doAddToHistory(): void {
|
|
126
|
+
if (!this.value) {
|
|
127
|
+
return;
|
|
128
|
+
}
|
|
129
|
+
const history = this.state.history
|
|
130
|
+
.filter(term => term !== this.value)
|
|
131
|
+
.concat(this.value)
|
|
132
|
+
.slice(-SearchInWorkspaceTextArea.LIMIT);
|
|
133
|
+
this.updateState(history.length - 1, history);
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
override render(): React.ReactNode {
|
|
137
|
+
const { onResize, ...filteredProps } = this.props;
|
|
138
|
+
return (
|
|
139
|
+
<TextareaAutosize
|
|
140
|
+
{...filteredProps}
|
|
141
|
+
autoCapitalize="off"
|
|
142
|
+
autoCorrect="off"
|
|
143
|
+
maxRows={7} /* from VS Code */
|
|
144
|
+
onChange={this.onChange}
|
|
145
|
+
onKeyDown={this.onKeyDown}
|
|
146
|
+
ref={this.textarea}
|
|
147
|
+
rows={1}
|
|
148
|
+
spellCheck={false}
|
|
149
|
+
>
|
|
150
|
+
</TextareaAutosize>
|
|
151
|
+
);
|
|
152
|
+
}
|
|
153
|
+
}
|
|
@@ -1,93 +1,93 @@
|
|
|
1
|
-
// *****************************************************************************
|
|
2
|
-
// Copyright (C) 2019 TypeFox and others.
|
|
3
|
-
//
|
|
4
|
-
// This program and the accompanying materials are made available under the
|
|
5
|
-
// terms of the Eclipse Public License v. 2.0 which is available at
|
|
6
|
-
// http://www.eclipse.org/legal/epl-2.0.
|
|
7
|
-
//
|
|
8
|
-
// This Source Code may also be made available under the following Secondary
|
|
9
|
-
// Licenses when the conditions for such availability set forth in the Eclipse
|
|
10
|
-
// Public License v. 2.0 are satisfied: GNU General Public License, version 2
|
|
11
|
-
// with the GNU Classpath Exception which is available at
|
|
12
|
-
// https://www.gnu.org/software/classpath/license.html.
|
|
13
|
-
//
|
|
14
|
-
// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
|
|
15
|
-
// *****************************************************************************
|
|
16
|
-
|
|
17
|
-
import { injectable, inject, postConstruct } from '@theia/core/shared/inversify';
|
|
18
|
-
import { ContextKeyService, ContextKey } from '@theia/core/lib/browser/context-key-service';
|
|
19
|
-
|
|
20
|
-
@injectable()
|
|
21
|
-
export class SearchInWorkspaceContextKeyService {
|
|
22
|
-
|
|
23
|
-
@inject(ContextKeyService)
|
|
24
|
-
protected readonly contextKeyService: ContextKeyService;
|
|
25
|
-
|
|
26
|
-
protected _searchViewletVisible: ContextKey<boolean>;
|
|
27
|
-
get searchViewletVisible(): ContextKey<boolean> {
|
|
28
|
-
return this._searchViewletVisible;
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
protected _searchViewletFocus: ContextKey<boolean>;
|
|
32
|
-
get searchViewletFocus(): ContextKey<boolean> {
|
|
33
|
-
return this._searchViewletFocus;
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
protected searchInputBoxFocus: ContextKey<boolean>;
|
|
37
|
-
setSearchInputBoxFocus(searchInputBoxFocus: boolean): void {
|
|
38
|
-
this.searchInputBoxFocus.set(searchInputBoxFocus);
|
|
39
|
-
this.updateInputBoxFocus();
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
protected replaceInputBoxFocus: ContextKey<boolean>;
|
|
43
|
-
setReplaceInputBoxFocus(replaceInputBoxFocus: boolean): void {
|
|
44
|
-
this.replaceInputBoxFocus.set(replaceInputBoxFocus);
|
|
45
|
-
this.updateInputBoxFocus();
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
protected patternIncludesInputBoxFocus: ContextKey<boolean>;
|
|
49
|
-
setPatternIncludesInputBoxFocus(patternIncludesInputBoxFocus: boolean): void {
|
|
50
|
-
this.patternIncludesInputBoxFocus.set(patternIncludesInputBoxFocus);
|
|
51
|
-
this.updateInputBoxFocus();
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
protected patternExcludesInputBoxFocus: ContextKey<boolean>;
|
|
55
|
-
setPatternExcludesInputBoxFocus(patternExcludesInputBoxFocus: boolean): void {
|
|
56
|
-
this.patternExcludesInputBoxFocus.set(patternExcludesInputBoxFocus);
|
|
57
|
-
this.updateInputBoxFocus();
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
protected inputBoxFocus: ContextKey<boolean>;
|
|
61
|
-
protected updateInputBoxFocus(): void {
|
|
62
|
-
this.inputBoxFocus.set(
|
|
63
|
-
this.searchInputBoxFocus.get() ||
|
|
64
|
-
this.replaceInputBoxFocus.get() ||
|
|
65
|
-
this.patternIncludesInputBoxFocus.get() ||
|
|
66
|
-
this.patternExcludesInputBoxFocus.get()
|
|
67
|
-
);
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
protected _replaceActive: ContextKey<boolean>;
|
|
71
|
-
get replaceActive(): ContextKey<boolean> {
|
|
72
|
-
return this._replaceActive;
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
protected _hasSearchResult: ContextKey<boolean>;
|
|
76
|
-
get hasSearchResult(): ContextKey<boolean> {
|
|
77
|
-
return this._hasSearchResult;
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
@postConstruct()
|
|
81
|
-
protected init(): void {
|
|
82
|
-
this._searchViewletVisible = this.contextKeyService.createKey<boolean>('searchViewletVisible', false);
|
|
83
|
-
this._searchViewletFocus = this.contextKeyService.createKey<boolean>('searchViewletFocus', false);
|
|
84
|
-
this.inputBoxFocus = this.contextKeyService.createKey<boolean>('inputBoxFocus', false);
|
|
85
|
-
this.searchInputBoxFocus = this.contextKeyService.createKey<boolean>('searchInputBoxFocus', false);
|
|
86
|
-
this.replaceInputBoxFocus = this.contextKeyService.createKey<boolean>('replaceInputBoxFocus', false);
|
|
87
|
-
this.patternIncludesInputBoxFocus = this.contextKeyService.createKey<boolean>('patternIncludesInputBoxFocus', false);
|
|
88
|
-
this.patternExcludesInputBoxFocus = this.contextKeyService.createKey<boolean>('patternExcludesInputBoxFocus', false);
|
|
89
|
-
this._replaceActive = this.contextKeyService.createKey<boolean>('replaceActive', false);
|
|
90
|
-
this._hasSearchResult = this.contextKeyService.createKey<boolean>('hasSearchResult', false);
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
}
|
|
1
|
+
// *****************************************************************************
|
|
2
|
+
// Copyright (C) 2019 TypeFox and others.
|
|
3
|
+
//
|
|
4
|
+
// This program and the accompanying materials are made available under the
|
|
5
|
+
// terms of the Eclipse Public License v. 2.0 which is available at
|
|
6
|
+
// http://www.eclipse.org/legal/epl-2.0.
|
|
7
|
+
//
|
|
8
|
+
// This Source Code may also be made available under the following Secondary
|
|
9
|
+
// Licenses when the conditions for such availability set forth in the Eclipse
|
|
10
|
+
// Public License v. 2.0 are satisfied: GNU General Public License, version 2
|
|
11
|
+
// with the GNU Classpath Exception which is available at
|
|
12
|
+
// https://www.gnu.org/software/classpath/license.html.
|
|
13
|
+
//
|
|
14
|
+
// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
|
|
15
|
+
// *****************************************************************************
|
|
16
|
+
|
|
17
|
+
import { injectable, inject, postConstruct } from '@theia/core/shared/inversify';
|
|
18
|
+
import { ContextKeyService, ContextKey } from '@theia/core/lib/browser/context-key-service';
|
|
19
|
+
|
|
20
|
+
@injectable()
|
|
21
|
+
export class SearchInWorkspaceContextKeyService {
|
|
22
|
+
|
|
23
|
+
@inject(ContextKeyService)
|
|
24
|
+
protected readonly contextKeyService: ContextKeyService;
|
|
25
|
+
|
|
26
|
+
protected _searchViewletVisible: ContextKey<boolean>;
|
|
27
|
+
get searchViewletVisible(): ContextKey<boolean> {
|
|
28
|
+
return this._searchViewletVisible;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
protected _searchViewletFocus: ContextKey<boolean>;
|
|
32
|
+
get searchViewletFocus(): ContextKey<boolean> {
|
|
33
|
+
return this._searchViewletFocus;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
protected searchInputBoxFocus: ContextKey<boolean>;
|
|
37
|
+
setSearchInputBoxFocus(searchInputBoxFocus: boolean): void {
|
|
38
|
+
this.searchInputBoxFocus.set(searchInputBoxFocus);
|
|
39
|
+
this.updateInputBoxFocus();
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
protected replaceInputBoxFocus: ContextKey<boolean>;
|
|
43
|
+
setReplaceInputBoxFocus(replaceInputBoxFocus: boolean): void {
|
|
44
|
+
this.replaceInputBoxFocus.set(replaceInputBoxFocus);
|
|
45
|
+
this.updateInputBoxFocus();
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
protected patternIncludesInputBoxFocus: ContextKey<boolean>;
|
|
49
|
+
setPatternIncludesInputBoxFocus(patternIncludesInputBoxFocus: boolean): void {
|
|
50
|
+
this.patternIncludesInputBoxFocus.set(patternIncludesInputBoxFocus);
|
|
51
|
+
this.updateInputBoxFocus();
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
protected patternExcludesInputBoxFocus: ContextKey<boolean>;
|
|
55
|
+
setPatternExcludesInputBoxFocus(patternExcludesInputBoxFocus: boolean): void {
|
|
56
|
+
this.patternExcludesInputBoxFocus.set(patternExcludesInputBoxFocus);
|
|
57
|
+
this.updateInputBoxFocus();
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
protected inputBoxFocus: ContextKey<boolean>;
|
|
61
|
+
protected updateInputBoxFocus(): void {
|
|
62
|
+
this.inputBoxFocus.set(
|
|
63
|
+
this.searchInputBoxFocus.get() ||
|
|
64
|
+
this.replaceInputBoxFocus.get() ||
|
|
65
|
+
this.patternIncludesInputBoxFocus.get() ||
|
|
66
|
+
this.patternExcludesInputBoxFocus.get()
|
|
67
|
+
);
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
protected _replaceActive: ContextKey<boolean>;
|
|
71
|
+
get replaceActive(): ContextKey<boolean> {
|
|
72
|
+
return this._replaceActive;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
protected _hasSearchResult: ContextKey<boolean>;
|
|
76
|
+
get hasSearchResult(): ContextKey<boolean> {
|
|
77
|
+
return this._hasSearchResult;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
@postConstruct()
|
|
81
|
+
protected init(): void {
|
|
82
|
+
this._searchViewletVisible = this.contextKeyService.createKey<boolean>('searchViewletVisible', false);
|
|
83
|
+
this._searchViewletFocus = this.contextKeyService.createKey<boolean>('searchViewletFocus', false);
|
|
84
|
+
this.inputBoxFocus = this.contextKeyService.createKey<boolean>('inputBoxFocus', false);
|
|
85
|
+
this.searchInputBoxFocus = this.contextKeyService.createKey<boolean>('searchInputBoxFocus', false);
|
|
86
|
+
this.replaceInputBoxFocus = this.contextKeyService.createKey<boolean>('replaceInputBoxFocus', false);
|
|
87
|
+
this.patternIncludesInputBoxFocus = this.contextKeyService.createKey<boolean>('patternIncludesInputBoxFocus', false);
|
|
88
|
+
this.patternExcludesInputBoxFocus = this.contextKeyService.createKey<boolean>('patternExcludesInputBoxFocus', false);
|
|
89
|
+
this._replaceActive = this.contextKeyService.createKey<boolean>('replaceActive', false);
|
|
90
|
+
this._hasSearchResult = this.contextKeyService.createKey<boolean>('hasSearchResult', false);
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
}
|
|
@@ -1,59 +1,59 @@
|
|
|
1
|
-
// *****************************************************************************
|
|
2
|
-
// Copyright (C) 2021 SAP SE or an SAP affiliate company and others.
|
|
3
|
-
//
|
|
4
|
-
// This program and the accompanying materials are made available under the
|
|
5
|
-
// terms of the Eclipse Public License v. 2.0 which is available at
|
|
6
|
-
// http://www.eclipse.org/legal/epl-2.0.
|
|
7
|
-
//
|
|
8
|
-
// This Source Code may also be made available under the following Secondary
|
|
9
|
-
// Licenses when the conditions for such availability set forth in the Eclipse
|
|
10
|
-
// Public License v. 2.0 are satisfied: GNU General Public License, version 2
|
|
11
|
-
// with the GNU Classpath Exception which is available at
|
|
12
|
-
// https://www.gnu.org/software/classpath/license.html.
|
|
13
|
-
//
|
|
14
|
-
// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
|
|
15
|
-
// *****************************************************************************
|
|
16
|
-
|
|
17
|
-
import { inject, injectable } from '@theia/core/shared/inversify';
|
|
18
|
-
import {
|
|
19
|
-
codicon,
|
|
20
|
-
ViewContainer,
|
|
21
|
-
ViewContainerTitleOptions,
|
|
22
|
-
WidgetFactory,
|
|
23
|
-
WidgetManager
|
|
24
|
-
} from '@theia/core/lib/browser';
|
|
25
|
-
import { SearchInWorkspaceWidget } from './search-in-workspace-widget';
|
|
26
|
-
import { nls } from '@theia/core/lib/common/nls';
|
|
27
|
-
|
|
28
|
-
export const SEARCH_VIEW_CONTAINER_ID = 'search-view-container';
|
|
29
|
-
export const SEARCH_VIEW_CONTAINER_TITLE_OPTIONS: ViewContainerTitleOptions = {
|
|
30
|
-
label: nls.localizeByDefault('Search'),
|
|
31
|
-
iconClass: codicon('search'),
|
|
32
|
-
closeable: true
|
|
33
|
-
};
|
|
34
|
-
|
|
35
|
-
@injectable()
|
|
36
|
-
export class SearchInWorkspaceFactory implements WidgetFactory {
|
|
37
|
-
|
|
38
|
-
readonly id = SEARCH_VIEW_CONTAINER_ID;
|
|
39
|
-
|
|
40
|
-
protected searchWidgetOptions: ViewContainer.Factory.WidgetOptions = {
|
|
41
|
-
canHide: false,
|
|
42
|
-
initiallyCollapsed: false
|
|
43
|
-
};
|
|
44
|
-
|
|
45
|
-
@inject(ViewContainer.Factory)
|
|
46
|
-
protected readonly viewContainerFactory: ViewContainer.Factory;
|
|
47
|
-
@inject(WidgetManager) protected readonly widgetManager: WidgetManager;
|
|
48
|
-
|
|
49
|
-
async createWidget(): Promise<ViewContainer> {
|
|
50
|
-
const viewContainer = this.viewContainerFactory({
|
|
51
|
-
id: SEARCH_VIEW_CONTAINER_ID,
|
|
52
|
-
progressLocationId: 'search'
|
|
53
|
-
});
|
|
54
|
-
viewContainer.setTitleOptions(SEARCH_VIEW_CONTAINER_TITLE_OPTIONS);
|
|
55
|
-
const widget = await this.widgetManager.getOrCreateWidget(SearchInWorkspaceWidget.ID);
|
|
56
|
-
viewContainer.addWidget(widget, this.searchWidgetOptions);
|
|
57
|
-
return viewContainer;
|
|
58
|
-
}
|
|
59
|
-
}
|
|
1
|
+
// *****************************************************************************
|
|
2
|
+
// Copyright (C) 2021 SAP SE or an SAP affiliate company and others.
|
|
3
|
+
//
|
|
4
|
+
// This program and the accompanying materials are made available under the
|
|
5
|
+
// terms of the Eclipse Public License v. 2.0 which is available at
|
|
6
|
+
// http://www.eclipse.org/legal/epl-2.0.
|
|
7
|
+
//
|
|
8
|
+
// This Source Code may also be made available under the following Secondary
|
|
9
|
+
// Licenses when the conditions for such availability set forth in the Eclipse
|
|
10
|
+
// Public License v. 2.0 are satisfied: GNU General Public License, version 2
|
|
11
|
+
// with the GNU Classpath Exception which is available at
|
|
12
|
+
// https://www.gnu.org/software/classpath/license.html.
|
|
13
|
+
//
|
|
14
|
+
// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
|
|
15
|
+
// *****************************************************************************
|
|
16
|
+
|
|
17
|
+
import { inject, injectable } from '@theia/core/shared/inversify';
|
|
18
|
+
import {
|
|
19
|
+
codicon,
|
|
20
|
+
ViewContainer,
|
|
21
|
+
ViewContainerTitleOptions,
|
|
22
|
+
WidgetFactory,
|
|
23
|
+
WidgetManager
|
|
24
|
+
} from '@theia/core/lib/browser';
|
|
25
|
+
import { SearchInWorkspaceWidget } from './search-in-workspace-widget';
|
|
26
|
+
import { nls } from '@theia/core/lib/common/nls';
|
|
27
|
+
|
|
28
|
+
export const SEARCH_VIEW_CONTAINER_ID = 'search-view-container';
|
|
29
|
+
export const SEARCH_VIEW_CONTAINER_TITLE_OPTIONS: ViewContainerTitleOptions = {
|
|
30
|
+
label: nls.localizeByDefault('Search'),
|
|
31
|
+
iconClass: codicon('search'),
|
|
32
|
+
closeable: true
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
@injectable()
|
|
36
|
+
export class SearchInWorkspaceFactory implements WidgetFactory {
|
|
37
|
+
|
|
38
|
+
readonly id = SEARCH_VIEW_CONTAINER_ID;
|
|
39
|
+
|
|
40
|
+
protected searchWidgetOptions: ViewContainer.Factory.WidgetOptions = {
|
|
41
|
+
canHide: false,
|
|
42
|
+
initiallyCollapsed: false
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
@inject(ViewContainer.Factory)
|
|
46
|
+
protected readonly viewContainerFactory: ViewContainer.Factory;
|
|
47
|
+
@inject(WidgetManager) protected readonly widgetManager: WidgetManager;
|
|
48
|
+
|
|
49
|
+
async createWidget(): Promise<ViewContainer> {
|
|
50
|
+
const viewContainer = this.viewContainerFactory({
|
|
51
|
+
id: SEARCH_VIEW_CONTAINER_ID,
|
|
52
|
+
progressLocationId: 'search'
|
|
53
|
+
});
|
|
54
|
+
viewContainer.setTitleOptions(SEARCH_VIEW_CONTAINER_TITLE_OPTIONS);
|
|
55
|
+
const widget = await this.widgetManager.getOrCreateWidget(SearchInWorkspaceWidget.ID);
|
|
56
|
+
viewContainer.addWidget(widget, this.searchWidgetOptions);
|
|
57
|
+
return viewContainer;
|
|
58
|
+
}
|
|
59
|
+
}
|