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
This commit is contained in:
Родитель
8c53c027ca
Коммит
bb962b91e8
|
@ -1,5 +1,7 @@
|
|||
# C/C++ for Visual Studio Code Change Log
|
||||
|
||||
* Add refresh button to process picker. [#2885](https://github.com/Microsoft/vscode-cpptools/issues/2885)
|
||||
|
||||
## Version 0.21.0-insiders2: November 20, 2018
|
||||
* Fix some IntelliSense process crashes. [#1785](https://github.com/Microsoft/vscode-cpptools/issues/1785)
|
||||
* Fix incorrect IntelliSense error with Mac clang 10.0 libraries. [#2608](https://github.com/Microsoft/vscode-cpptools/issues/2608)
|
||||
|
|
|
@ -0,0 +1 @@
|
|||
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16"><path d="M13.451 5.609l-.579-.939-1.068.812-.076.094c-.335.415-.927 1.341-1.124 2.876l-.021.165.033.163.071.345c0 1.654-1.346 3-3 3-.795 0-1.545-.311-2.107-.868-.563-.567-.873-1.317-.873-2.111 0-1.431 1.007-2.632 2.351-2.929v2.926s2.528-2.087 2.984-2.461h.012l3.061-2.582-4.919-4.1h-1.137v2.404c-3.429.318-6.121 3.211-6.121 6.721 0 1.809.707 3.508 1.986 4.782 1.277 1.282 2.976 1.988 4.784 1.988 3.722 0 6.75-3.028 6.75-6.75 0-1.245-.349-2.468-1.007-3.536z" fill="#F6F6F6"/><path d="M12.6 6.134l-.094.071c-.269.333-.746 1.096-.91 2.375.057.277.092.495.092.545 0 2.206-1.794 4-4 4-1.098 0-2.093-.445-2.817-1.164-.718-.724-1.163-1.718-1.163-2.815 0-2.206 1.794-4 4-4l.351.025v1.85s1.626-1.342 1.631-1.339l1.869-1.577-3.5-2.917v2.218l-.371-.03c-3.176 0-5.75 2.574-5.75 5.75 0 1.593.648 3.034 1.695 4.076 1.042 1.046 2.482 1.694 4.076 1.694 3.176 0 5.75-2.574 5.75-5.75-.001-1.106-.318-2.135-.859-3.012z" fill="#424242"/></svg>
|
После Ширина: | Высота: | Размер: 986 B |
|
@ -0,0 +1 @@
|
|||
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16"><path d="M13.451 5.609l-.579-.939-1.068.812-.076.094c-.335.415-.927 1.341-1.124 2.876l-.021.165.033.163.071.345c0 1.654-1.346 3-3 3-.795 0-1.545-.311-2.107-.868-.563-.567-.873-1.317-.873-2.111 0-1.431 1.007-2.632 2.351-2.929v2.926s2.528-2.087 2.984-2.461h.012l3.061-2.582-4.919-4.1h-1.137v2.404c-3.429.318-6.121 3.211-6.121 6.721 0 1.809.707 3.508 1.986 4.782 1.277 1.282 2.976 1.988 4.784 1.988 3.722 0 6.75-3.028 6.75-6.75 0-1.245-.349-2.468-1.007-3.536z" fill="#2D2D30"/><path d="M12.6 6.134l-.094.071c-.269.333-.746 1.096-.91 2.375.057.277.092.495.092.545 0 2.206-1.794 4-4 4-1.098 0-2.093-.445-2.817-1.164-.718-.724-1.163-1.718-1.163-2.815 0-2.206 1.794-4 4-4l.351.025v1.85s1.626-1.342 1.631-1.339l1.869-1.577-3.5-2.917v2.218l-.371-.03c-3.176 0-5.75 2.574-5.75 5.75 0 1.593.648 3.034 1.695 4.076 1.042 1.046 2.482 1.694 4.076 1.694 3.176 0 5.75-2.574 5.75-5.75-.001-1.106-.318-2.135-.859-3.012z" fill="#C5C5C5"/></svg>
|
После Ширина: | Высота: | Размер: 986 B |
|
@ -12,7 +12,7 @@
|
|||
},
|
||||
"license": "SEE LICENSE IN LICENSE.txt",
|
||||
"engines": {
|
||||
"vscode": "^1.23.0"
|
||||
"vscode": "^1.26.0"
|
||||
},
|
||||
"bugs": {
|
||||
"url": "https://github.com/Microsoft/vscode-cpptools/issues",
|
||||
|
|
|
@ -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();
|
||||
});
|
||||
});
|
||||
}
|
|
@ -5,6 +5,7 @@
|
|||
|
||||
import { execChildProcess } from '../common';
|
||||
import { PsProcessParser } from './nativeAttach';
|
||||
import { AttachItem, showQuickPick } from './attachQuickPick';
|
||||
|
||||
import * as debugUtils from './utils';
|
||||
import * as fs from 'fs';
|
||||
|
@ -13,10 +14,6 @@ import * as path from 'path';
|
|||
import * as util from '../common';
|
||||
import * as vscode from 'vscode';
|
||||
|
||||
export interface AttachItem extends vscode.QuickPickItem {
|
||||
id: string;
|
||||
}
|
||||
|
||||
export interface AttachItemsProvider {
|
||||
getAttachItems(): Promise<AttachItem[]>;
|
||||
}
|
||||
|
@ -29,19 +26,7 @@ export class AttachPicker {
|
|||
if (!ready) {
|
||||
util.displayExtensionNotReadyPrompt();
|
||||
} else {
|
||||
return this.attachItemsProvider.getAttachItems()
|
||||
.then(processEntries => {
|
||||
let attachPickOptions: vscode.QuickPickOptions = {
|
||||
matchOnDescription: true,
|
||||
matchOnDetail: true,
|
||||
placeHolder: "Select the process to attach to"
|
||||
};
|
||||
|
||||
return vscode.window.showQuickPick(processEntries, attachPickOptions)
|
||||
.then(chosenProcess => {
|
||||
return chosenProcess ? chosenProcess.id : Promise.reject<string>(new Error("Process not selected."));
|
||||
});
|
||||
});
|
||||
return showQuickPick(() => this.attachItemsProvider.getAttachItems());
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -74,7 +59,7 @@ export class RemoteAttachPicker {
|
|||
!fs.existsSync(pipeTransport.pipeProgram)) {
|
||||
const pipeProgramStr: string = pipeTransport.pipeProgram.toLowerCase().trim();
|
||||
const expectedArch: debugUtils.ArchType = debugUtils.ArchType[process.arch];
|
||||
|
||||
|
||||
// Check for pipeProgram
|
||||
if (!fs.existsSync(config.pipeTransport.pipeProgram)) {
|
||||
pipeProgram = debugUtils.ArchitectureReplacer.checkAndReplaceWSLPipeProgram(pipeProgramStr, expectedArch);
|
||||
|
@ -84,7 +69,7 @@ export class RemoteAttachPicker {
|
|||
if (!pipeProgram && config.pipeTransport.pipeCwd) {
|
||||
const pipeCwdStr: string = config.pipeTransport.pipeCwd.toLowerCase().trim();
|
||||
const newPipeProgramStr: string = path.join(pipeCwdStr, pipeProgramStr);
|
||||
|
||||
|
||||
if (!fs.existsSync(newPipeProgramStr)) {
|
||||
pipeProgram = debugUtils.ArchitectureReplacer.checkAndReplaceWSLPipeProgram(newPipeProgramStr, expectedArch);
|
||||
}
|
||||
|
|
|
@ -5,7 +5,8 @@
|
|||
|
||||
import * as child_process from 'child_process';
|
||||
import * as os from 'os';
|
||||
import { AttachItem, AttachItemsProvider } from './attachToProcess';
|
||||
import { AttachItemsProvider } from './attachToProcess';
|
||||
import { AttachItem } from './attachQuickPick';
|
||||
|
||||
class Process {
|
||||
constructor(public name: string, public pid: string, public commandLine: string) { }
|
||||
|
|
Загрузка…
Ссылка в новой задаче