Skip to content
This repository was archived by the owner on Jun 30, 2020. It is now read-only.

Commit 1aa30d6

Browse files
committed
caching
1 parent d06599d commit 1aa30d6

File tree

3 files changed

+262
-48
lines changed

3 files changed

+262
-48
lines changed

package.json

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,13 +37,29 @@
3737
"onFileSystemAccess:slack",
3838
"onFileSystem:webdav",
3939
"onFileSystemAccess:webdav",
40+
"onCommand:extension.remote.workspace.clearSearchCache",
4041
"onCommand:extension.remote.workspace.openURI",
4142
"onCommand:extension.remote.workspace.receiveWorkspaceURI",
4243
"onCommand:extension.remote.workspace.sendWorkspaceURI"
4344
],
4445
"main": "./out/extension",
4546
"contributes": {
4647
"commands": [
48+
{
49+
"command": "extension.remote.workspace.clearSearchCache",
50+
"title": "Clear All Search Caches ...",
51+
"category": "Remote Workspace"
52+
},
53+
{
54+
"command": "extension.remote.workspace.clearFileSearchCache",
55+
"title": "Clear File Search Cache ...",
56+
"category": "Remote Workspace"
57+
},
58+
{
59+
"command": "extension.remote.workspace.clearTextSearchCache",
60+
"title": "Clear Text Search Cache ...",
61+
"category": "Remote Workspace"
62+
},
4763
{
4864
"command": "extension.remote.workspace.openURI",
4965
"title": "Open URI ...",

src/extension.ts

Lines changed: 44 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,18 @@ interface WorkspaceQuickPickItem extends vscode.QuickPickItem {
7474
}
7575

7676
const DEFAULT_SHARE_URI_PORT = 1248;
77+
/**
78+
* Name, which tells search providers to clear their file search caches.
79+
*/
80+
export const EVENT_CLEAR_FILE_SEARCH_CACHE = 'vscrwClearFileSearchCache';
81+
/**
82+
* Name, which tells search providers to clear all of their search caches.
83+
*/
84+
export const EVENT_CLEAR_SEARCH_CACHE = 'vscrwClearSearchCache';
85+
/**
86+
* Name, which tells search providers to clear their text search caches.
87+
*/
88+
export const EVENT_CLEAR_TEXT_SEARCH_CACHE = 'vscrwClearTextSearchCache';
7789
/**
7890
* The name of the extension's directory inside the user's home directory.
7991
*/
@@ -183,6 +195,36 @@ export async function activate(context: vscode.ExtensionContext) {
183195
// commands
184196
WF.next(() => {
185197
context.subscriptions.push(
198+
// clearFileSearchCache
199+
vscode.commands.registerCommand('extension.remote.workspace.clearFileSearchCache', async () => {
200+
try {
201+
vscode_helpers.EVENTS.emit(EVENT_CLEAR_FILE_SEARCH_CACHE,
202+
null);
203+
} catch (e) {
204+
showError(e);
205+
}
206+
}),
207+
208+
// clearSearchCache
209+
vscode.commands.registerCommand('extension.remote.workspace.clearSearchCache', async () => {
210+
try {
211+
vscode_helpers.EVENTS.emit(EVENT_CLEAR_SEARCH_CACHE,
212+
null);
213+
} catch (e) {
214+
showError(e);
215+
}
216+
}),
217+
218+
// clearTextSearchCache
219+
vscode.commands.registerCommand('extension.remote.workspace.clearTextSearchCache', async () => {
220+
try {
221+
vscode_helpers.EVENTS.emit(EVENT_CLEAR_TEXT_SEARCH_CACHE,
222+
null);
223+
} catch (e) {
224+
showError(e);
225+
}
226+
}),
227+
186228
// openURI
187229
vscode.commands.registerCommand('extension.remote.workspace.openURI', async () => {
188230
try {
@@ -537,8 +579,9 @@ export function deactivate() {
537579
if (isDeactivating) {
538580
return;
539581
}
540-
541582
isDeactivating = true;
583+
584+
vscode_helpers.EVENTS.removeAllListeners();
542585
}
543586

544587
/**

0 commit comments

Comments
 (0)