-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add refresh button to process picker (#2895)
* Add attach QuickView with refresh * vscode engine 1.23 -> 1.26 * Clean up disposables * Add entry to CHANGELOG * Provide refresh image for dark and light themes * Add title to QuickPick
- Loading branch information
1 parent
8c53c02
commit bb962b9
Showing
7 changed files
with
81 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
/* -------------------------------------------------------------------------------------------- | ||
* Copyright (c) Microsoft Corporation. All Rights Reserved. | ||
* See 'LICENSE' in the project root for license information. | ||
* ------------------------------------------------------------------------------------------ */ | ||
|
||
import * as util from '../common'; | ||
import * as vscode from 'vscode'; | ||
|
||
class RefreshButton implements vscode.QuickInputButton { | ||
get iconPath(): { dark: vscode.Uri; light: vscode.Uri } { | ||
const refreshImagePathDark: string = util.getExtensionFilePath("assets/Refresh_inverse.svg"); | ||
const refreshImagePathLight: string = util.getExtensionFilePath("assets/Refresh.svg"); | ||
|
||
return { | ||
dark: vscode.Uri.file(refreshImagePathDark), | ||
light: vscode.Uri.file(refreshImagePathLight) | ||
}; | ||
} | ||
|
||
get tooltip(): string { | ||
return "Refresh process list"; | ||
} | ||
} | ||
|
||
export interface AttachItem extends vscode.QuickPickItem { | ||
id: string; | ||
} | ||
|
||
export function showQuickPick(getAttachItems: () => Promise<AttachItem[]>): Promise<string> { | ||
return getAttachItems().then(processEntries => { | ||
return new Promise<string>((resolve, reject) => { | ||
let quickPick: vscode.QuickPick<AttachItem> = vscode.window.createQuickPick<AttachItem>(); | ||
quickPick.title = "Attach to process"; | ||
quickPick.canSelectMany = false; | ||
quickPick.matchOnDescription = true; | ||
quickPick.matchOnDetail = true; | ||
quickPick.placeholder = "Select the process to attach to"; | ||
quickPick.items = processEntries; | ||
quickPick.buttons = [new RefreshButton()]; | ||
|
||
let disposables: vscode.Disposable[] = []; | ||
|
||
quickPick.onDidTriggerButton(button => { | ||
getAttachItems().then(processEntries => quickPick.items = processEntries); | ||
}, undefined, disposables); | ||
|
||
quickPick.onDidAccept(() => { | ||
if (quickPick.selectedItems.length !== 1) { | ||
reject(new Error("Process not selected")); | ||
} | ||
|
||
let selectedId: string = quickPick.selectedItems[0].id; | ||
|
||
disposables.forEach(item => item.dispose()); | ||
quickPick.dispose(); | ||
|
||
resolve(selectedId); | ||
}, undefined, disposables); | ||
|
||
quickPick.onDidHide(() => { | ||
disposables.forEach(item => item.dispose()); | ||
quickPick.dispose(); | ||
|
||
reject(new Error("Process not selected.")); | ||
}, undefined, disposables); | ||
|
||
quickPick.show(); | ||
}); | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters