Skip to content

Commit

Permalink
Fix issue with disabled compiler path in config UI if none detected (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
Colengms authored Jan 30, 2020
1 parent 4a8802a commit e01071a
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 12 deletions.
4 changes: 2 additions & 2 deletions Extension/ui/settings.html
Original file line number Diff line number Diff line change
Expand Up @@ -480,7 +480,7 @@
<!-- input compilerPath -->
<div class="section-note" data-loc-id="specify.a.compiler">Specify a compiler path or select a detected compiler path from the drop-down list.</div>
<div class="select-editable">
<span id="noCompilerPathsDetected" class="error" style="display: none" data-loc-id="no.compiler.paths.detected">(No compiler paths detected)</span>
<span id="noCompilerPathsDetected" style="display: none" data-loc-id="no.compiler.paths.detected">(No compiler paths detected)</span>
<select id="knownCompilers" style="width: 810px; display: none"></select>
<input name="inputValue" id="compilerPath" style="width: 777px; display: none" type="text"/>
</div>
Expand All @@ -489,7 +489,7 @@
</div>

<div class="section">
<div class="section-title">Compiler arguments</div>
<div class="section-title" data-loc-id="compiler.args">Compiler arguments</div>
<div class="section-text" data-loc-id="compiler.arguments">Compiler arguments to modify the includes or defines used, e.g. <code>-nostdinc++</code>, <code>-m32</code>, etc.</div>
<div>
<div class="section-note" data-loc-id="one.argument.per.line">One argument per line.</div>
Expand Down
25 changes: 15 additions & 10 deletions Extension/ui/settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ const elementId: { [key: string]: string } = {
compilerPath: "compilerPath",
compilerPathInvalid: "compilerPathInvalid",
knownCompilers: "knownCompilers",
noCompilerPathsDetected: "noCompilerPathsDetected",
compilerArgs: "compilerArgs",

intelliSenseMode: "intelliSenseMode",
Expand Down Expand Up @@ -338,20 +339,24 @@ class SettingsApp {
}

if (compilers.length === 0) {
this.showElement("noCompilerPathsDetected", true);
return;
}

this.showElement("compilerPath", true);
this.showElement("knownCompilers", true);

for (let path of compilers) {
// Get HTML element containing the string, as we can't localize strings in HTML js
let noCompilerSpan: HTMLSpanElement = <HTMLSpanElement>document.getElementById(elementId.noCompilerPathsDetected);
let option: HTMLOptionElement = document.createElement("option");
option.text = path;
option.value = path;
option.text = noCompilerSpan.textContent;
option.disabled = true;
list.append(option);
} else {
for (let path of compilers) {
let option: HTMLOptionElement = document.createElement("option");
option.text = path;
option.value = path;
list.append(option);
}
}

this.showElement(elementId.compilerPath, true);
this.showElement(elementId.knownCompilers, true);

// Initialize list with no selected item
list.value = "";
} finally {
Expand Down

0 comments on commit e01071a

Please sign in to comment.