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

Commit

Permalink
caching
Browse files Browse the repository at this point in the history
  • Loading branch information
mkloubert committed Jun 11, 2018
1 parent d06599d commit 1aa30d6
Show file tree
Hide file tree
Showing 3 changed files with 262 additions and 48 deletions.
16 changes: 16 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,29 @@
"onFileSystemAccess:slack",
"onFileSystem:webdav",
"onFileSystemAccess:webdav",
"onCommand:extension.remote.workspace.clearSearchCache",
"onCommand:extension.remote.workspace.openURI",
"onCommand:extension.remote.workspace.receiveWorkspaceURI",
"onCommand:extension.remote.workspace.sendWorkspaceURI"
],
"main": "./out/extension",
"contributes": {
"commands": [
{
"command": "extension.remote.workspace.clearSearchCache",
"title": "Clear All Search Caches ...",
"category": "Remote Workspace"
},
{
"command": "extension.remote.workspace.clearFileSearchCache",
"title": "Clear File Search Cache ...",
"category": "Remote Workspace"
},
{
"command": "extension.remote.workspace.clearTextSearchCache",
"title": "Clear Text Search Cache ...",
"category": "Remote Workspace"
},
{
"command": "extension.remote.workspace.openURI",
"title": "Open URI ...",
Expand Down
45 changes: 44 additions & 1 deletion src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,18 @@ interface WorkspaceQuickPickItem extends vscode.QuickPickItem {
}

const DEFAULT_SHARE_URI_PORT = 1248;
/**
* Name, which tells search providers to clear their file search caches.
*/
export const EVENT_CLEAR_FILE_SEARCH_CACHE = 'vscrwClearFileSearchCache';
/**
* Name, which tells search providers to clear all of their search caches.
*/
export const EVENT_CLEAR_SEARCH_CACHE = 'vscrwClearSearchCache';
/**
* Name, which tells search providers to clear their text search caches.
*/
export const EVENT_CLEAR_TEXT_SEARCH_CACHE = 'vscrwClearTextSearchCache';
/**
* The name of the extension's directory inside the user's home directory.
*/
Expand Down Expand Up @@ -183,6 +195,36 @@ export async function activate(context: vscode.ExtensionContext) {
// commands
WF.next(() => {
context.subscriptions.push(
// clearFileSearchCache
vscode.commands.registerCommand('extension.remote.workspace.clearFileSearchCache', async () => {
try {
vscode_helpers.EVENTS.emit(EVENT_CLEAR_FILE_SEARCH_CACHE,
null);
} catch (e) {
showError(e);
}
}),

// clearSearchCache
vscode.commands.registerCommand('extension.remote.workspace.clearSearchCache', async () => {
try {
vscode_helpers.EVENTS.emit(EVENT_CLEAR_SEARCH_CACHE,
null);
} catch (e) {
showError(e);
}
}),

// clearTextSearchCache
vscode.commands.registerCommand('extension.remote.workspace.clearTextSearchCache', async () => {
try {
vscode_helpers.EVENTS.emit(EVENT_CLEAR_TEXT_SEARCH_CACHE,
null);
} catch (e) {
showError(e);
}
}),

// openURI
vscode.commands.registerCommand('extension.remote.workspace.openURI', async () => {
try {
Expand Down Expand Up @@ -537,8 +579,9 @@ export function deactivate() {
if (isDeactivating) {
return;
}

isDeactivating = true;

vscode_helpers.EVENTS.removeAllListeners();
}

/**
Expand Down
Loading

0 comments on commit 1aa30d6

Please sign in to comment.