The compiler path selection control is not in sync with the textbox (#12678)

This commit is contained in:
Bob Brown 2024-09-04 13:06:23 -07:00 коммит произвёл GitHub
Родитель f077665994
Коммит 7006e18ea4
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: B5690EEEBB952194
1 изменённых файлов: 23 добавлений и 7 удалений

Просмотреть файл

@ -109,8 +109,8 @@ class SettingsApp {
document.getElementById(elementId.configName)?.addEventListener("change", this.onConfigNameChanged.bind(this));
document.getElementById(elementId.configSelection)?.addEventListener("change", this.onConfigSelect.bind(this));
document.getElementById(elementId.addConfigBtn)?.addEventListener("click", this.onAddConfigBtn.bind(this));
document.getElementById(elementId.addConfigOk)?.addEventListener("click", this.OnAddConfigConfirm.bind(this, true));
document.getElementById(elementId.addConfigCancel)?.addEventListener("click", this.OnAddConfigConfirm.bind(this, false));
document.getElementById(elementId.addConfigOk)?.addEventListener("click", this.onAddConfigConfirm.bind(this, true));
document.getElementById(elementId.addConfigCancel)?.addEventListener("click", this.onAddConfigConfirm.bind(this, false));
}
private onTabKeyDown(e: any): void {
@ -148,7 +148,7 @@ class SettingsApp {
this.showElement(elementId.addConfigInputDiv, true);
}
private OnAddConfigConfirm(request: boolean): void {
private onAddConfigConfirm(request: boolean): void {
this.showElement(elementId.addConfigInputDiv, false);
this.showElement(elementId.addConfigDiv, true);
@ -204,7 +204,7 @@ class SettingsApp {
if (this.updating) {
return;
}
const el: HTMLInputElement = <HTMLInputElement>document.getElementById(elementId.knownCompilers);
const el: HTMLSelectElement = <HTMLSelectElement>document.getElementById(elementId.knownCompilers);
(<HTMLInputElement>document.getElementById(elementId.compilerPath)).value = el.value;
this.onChanged(elementId.compilerPath);
@ -212,10 +212,22 @@ class SettingsApp {
this.vsCodeApi.postMessage({
command: "knownCompilerSelect"
});
// Reset selection to none
el.value = "";
}
// To enable custom entries, the compiler path control is a text box on top of a select control.
// This function ensures that the select control is updated when the text box is changed.
private fixKnownCompilerSelection(): void {
const compilerPath = (<HTMLInputElement>document.getElementById(elementId.compilerPath)).value.toLowerCase();
const knownCompilers = <HTMLSelectElement>document.getElementById(elementId.knownCompilers);
for (let n = 0; n < knownCompilers.options.length; n++) {
if (compilerPath === knownCompilers.options[n].value.toLowerCase()) {
knownCompilers.value = knownCompilers.options[n].value;
return;
}
}
knownCompilers.value = '';
}
private onChangedCheckbox(id: string): void {
if (this.updating) {
return;
@ -235,6 +247,9 @@ class SettingsApp {
}
const el: HTMLInputElement = <HTMLInputElement>document.getElementById(id);
if (id === elementId.compilerPath) {
this.fixKnownCompilerSelection();
}
this.vsCodeApi.postMessage({
command: "change",
key: id,
@ -268,6 +283,7 @@ class SettingsApp {
// Basic settings
(<HTMLInputElement>document.getElementById(elementId.configName)).value = config.name;
(<HTMLInputElement>document.getElementById(elementId.compilerPath)).value = config.compilerPath ? config.compilerPath : "";
this.fixKnownCompilerSelection();
(<HTMLInputElement>document.getElementById(elementId.compilerArgs)).value = joinEntries(config.compilerArgs);
(<HTMLInputElement>document.getElementById(elementId.intelliSenseMode)).value = config.intelliSenseMode ? config.intelliSenseMode : "${default}";