Fix debug widget dropdown is changed unnecessarily when continuing/stepping

fixes #16761
This commit is contained in:
isidor
2016-12-23 14:44:45 +01:00
parent aca935aa01
commit 9ebf0dfb80
3 changed files with 18 additions and 9 deletions
@@ -705,7 +705,7 @@ export class SelectActionItem extends BaseActionItem {
this.registerListeners();
}
public setOptions(options: string[], selected: number): void {
public setOptions(options: string[], selected?: number): void {
this.selectBox.setOptions(options, selected);
}
@@ -9,6 +9,7 @@ import { IDisposable, dispose } from 'vs/base/common/lifecycle';
import Event, { Emitter } from 'vs/base/common/event';
import { Widget } from 'vs/base/browser/ui/widget';
import * as dom from 'vs/base/browser/dom';
import * as arrays from 'vs/base/common/arrays';
export class SelectBox extends Widget {
@@ -40,13 +41,15 @@ export class SelectBox extends Widget {
return this._onDidSelect.event;
}
public setOptions(options: string[], selected: number): void {
this.options = options;
public setOptions(options: string[], selected?: number): void {
if (!arrays.equals(this.options, options)) {
this.options = options;
this.selectElement.options.length = 0;
this.options.forEach((option) => {
this.selectElement.add(this.createOption(option));
});
this.selectElement.options.length = 0;
this.options.forEach((option) => {
this.selectElement.add(this.createOption(option));
});
}
this.select(selected);
}
@@ -130,8 +130,14 @@ export class FocusProcessActionItem extends SelectActionItem {
this.debugService.getViewModel().onDidFocusStackFrame(() => {
const process = this.debugService.getViewModel().focusedProcess;
const names = this.debugService.getModel().getProcesses().map(p => p.name);
this.setOptions(names, process ? names.indexOf(process.name) : 0);
if (process) {
const names = this.debugService.getModel().getProcesses().map(p => p.name);
this.select(names.indexOf(process.name));
}
});
this.debugService.getModel().onDidChangeCallStack(() => {
this.setOptions(this.debugService.getModel().getProcesses().map(p => p.name));
});
}
}