Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add refresh button to process picker #2895

Merged
merged 6 commits into from
Dec 10, 2018
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions Extension/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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)
Expand Down
1 change: 1 addition & 0 deletions Extension/assets/Refresh_inverse.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion Extension/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
64 changes: 64 additions & 0 deletions Extension/src/Debugger/attachQuickPick.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
/* --------------------------------------------------------------------------------------------
* 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(): vscode.Uri {
const refreshImagePath: string = util.getExtensionFilePath("assets/Refresh_inverse.svg");
WardenGnaw marked this conversation as resolved.
Show resolved Hide resolved
return vscode.Uri.file(refreshImagePath);
}

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.canSelectMany = false;
quickPick.matchOnDescription = true;
quickPick.matchOnDetail = true;
WardenGnaw marked this conversation as resolved.
Show resolved Hide resolved
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();
});
});
}
23 changes: 4 additions & 19 deletions Extension/src/Debugger/attachToProcess.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand All @@ -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[]>;
}
Expand All @@ -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());
}
});
}
Expand Down Expand Up @@ -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);
Expand All @@ -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);
}
Expand Down
3 changes: 2 additions & 1 deletion Extension/src/Debugger/nativeAttach.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) { }
Expand Down