Skip to content

Commit 1649cc2

Browse files
committed
fixed stuffs
1 parent 293dcd9 commit 1649cc2

File tree

5 files changed

+92
-24
lines changed

5 files changed

+92
-24
lines changed

src/components/settingsPage.js

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ import searchBar from "./searchbar";
2727
* @property {string} [pageClassName] - Extra classes to apply to the page element
2828
* @property {string} [listClassName] - Extra classes to apply to the list element
2929
* @property {string} [defaultSearchGroup] - Default search result group label for this page
30-
* @property {boolean} [infoAsDescription] - Prefer item.info as subtitle instead of item.value
30+
* @property {boolean} [infoAsDescription] - Override subtitle behavior; defaults to true when valueInTail is enabled
3131
* @property {boolean} [valueInTail] - Render item.value as a trailing control/value instead of subtitle
3232
* @property {boolean} [groupByDefault] - Wrap uncategorized settings in a grouped section shell
3333
* @property {"top"|"bottom"} [notePosition] - Render note before or after the settings list
@@ -237,6 +237,8 @@ function listItems($list, items, callback, options = {}) {
237237
const renderedItems = [];
238238
const $searchItems = [];
239239
const $content = [];
240+
const useInfoAsDescription =
241+
options.infoAsDescription ?? Boolean(options.valueInTail);
240242
/** @type {HTMLElement | null} */
241243
let $currentSectionCard = null;
242244
let currentCategory = null;
@@ -275,9 +277,9 @@ function listItems($list, items, callback, options = {}) {
275277

276278
let $checkbox, $valueText;
277279
let $trailingValueText;
278-
const subtitle = getSubtitleText(item, options);
280+
const subtitle = getSubtitleText(item, useInfoAsDescription);
279281
const showInfoAsSubtitle =
280-
options.infoAsDescription || (item.value === undefined && item.info);
282+
useInfoAsDescription || (item.value === undefined && item.info);
281283
const searchGroup =
282284
item.searchGroup || item.category || options.defaultSearchGroup;
283285
const hasSubtitle =
@@ -476,8 +478,8 @@ function listItems($list, items, callback, options = {}) {
476478
}
477479
}
478480

479-
function getSubtitleText(item, options) {
480-
if (options.infoAsDescription) {
481+
function getSubtitleText(item, useInfoAsDescription) {
482+
if (useInfoAsDescription) {
481483
return item.info;
482484
}
483485

src/components/settingsPage.scss

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -258,6 +258,7 @@ wc-page.detail-settings-page {
258258
min-width: 0;
259259
overflow: visible;
260260
gap: 0.14rem;
261+
padding-right: 0.35rem;
261262

262263
> .text {
263264
display: flex;
@@ -290,14 +291,15 @@ wc-page.detail-settings-page {
290291
flex-shrink: 0;
291292
min-height: 1.65rem;
292293
gap: 0.32rem;
293-
margin-left: auto;
294+
margin-left: 0.9rem;
294295
align-self: center;
295296
}
296297
}
297298

298299
.detail-settings-list > .list-item.has-subtitle > .container,
299300
.settings-section-card > .list-item.has-subtitle > .container {
300301
padding-top: 0.12rem;
302+
padding-right: 0.55rem;
301303
}
302304

303305
.detail-settings-list > .list-item.compact > .container,

src/lib/acode.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -675,7 +675,6 @@ export default class Acode {
675675
preserveOrder: true,
676676
pageClassName: "detail-settings-page",
677677
listClassName: "detail-settings-list",
678-
infoAsDescription: true,
679678
valueInTail: true,
680679
groupByDefault: true,
681680
},

src/settings/lspServerDetail.js

Lines changed: 77 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,48 @@ function formatInstallStatus(result) {
115115
}
116116
}
117117

118+
function formatStartupTimeoutValue(timeout) {
119+
return typeof timeout === "number" ? `${timeout} ms` : "Default";
120+
}
121+
122+
function sanitizeInstallMessage(message) {
123+
const lines = String(message || "")
124+
.split("\n")
125+
.map((line) => line.trim())
126+
.filter(Boolean)
127+
.filter(
128+
(line) =>
129+
!/^proot warning:/i.test(line) &&
130+
!line.includes(`"/proc/self/fd/0"`) &&
131+
!line.includes(`"/proc/self/fd/1"`) &&
132+
!line.includes(`"/proc/self/fd/2"`),
133+
);
134+
135+
return lines.join(" ");
136+
}
137+
138+
function formatInstallInfo(result) {
139+
const cleanedMessage = sanitizeInstallMessage(result?.message);
140+
141+
switch (result?.status) {
142+
case "present":
143+
return result.version
144+
? `Version ${result.version} is available.`
145+
: "Language server is installed and ready.";
146+
case "missing":
147+
return "Language server is not installed in the terminal environment.";
148+
case "failed":
149+
return (
150+
cleanedMessage || "Acode could not verify the installation status."
151+
);
152+
default:
153+
return (
154+
cleanedMessage ||
155+
"Installation status could not be checked automatically."
156+
);
157+
}
158+
}
159+
118160
function formatValue(value) {
119161
if (value === undefined || value === null || value === "") return "";
120162
let text = String(value);
@@ -154,9 +196,16 @@ function updateItemDisplay($list, itemsByKey, key, value, extras = {}) {
154196
const $item = $list?.querySelector?.(`[data-key="${key}"]`);
155197
if (!$item) return;
156198

157-
const $value = $item.querySelector(".value");
158-
if ($value) {
159-
$value.textContent = formatValue(item.value);
199+
const $subtitle = $item.querySelector(".value");
200+
if ($subtitle) {
201+
$subtitle.textContent = $subtitle.classList.contains("setting-info")
202+
? String(item.info || "")
203+
: formatValue(item.value);
204+
}
205+
206+
const $trailingValue = $item.querySelector(".setting-trailing-value");
207+
if ($trailingValue) {
208+
$trailingValue.textContent = formatValue(item.value);
160209
}
161210

162211
const $checkbox = $item.querySelector(".input-checkbox");
@@ -200,38 +249,44 @@ function createItems(snapshot) {
200249
text: "Enabled",
201250
checkbox: snapshot.merged.enabled !== false,
202251
info: "Enable or disable this language server",
252+
category: "General",
203253
},
204254
{
205255
key: "install_status",
206256
text: "Installed",
207257
value: formatInstallStatus(snapshot.installResult),
208-
info:
209-
snapshot.installResult.message ||
210-
"Current installation state for this language server",
258+
info: formatInstallInfo(snapshot.installResult),
259+
category: "Installation",
260+
chevron: true,
211261
},
212262
{
213263
key: "install_server",
214264
text: "Install / Repair",
215265
info: "Install or repair this language server",
266+
category: "Installation",
267+
chevron: true,
216268
},
217269
{
218270
key: "update_server",
219271
text: "Update Server",
220272
info: "Update this language server if an update flow exists",
273+
category: "Installation",
274+
chevron: true,
221275
},
222276
{
223277
key: "uninstall_server",
224278
text: "Uninstall Server",
225279
info: "Remove installed packages or binaries for this server",
280+
category: "Installation",
281+
chevron: true,
226282
},
227283
{
228284
key: "startup_timeout",
229285
text: "Startup Timeout",
230-
value:
231-
typeof snapshot.merged.startupTimeout === "number"
232-
? `${snapshot.merged.startupTimeout} ms`
233-
: "Default (5000 ms)",
286+
value: formatStartupTimeoutValue(snapshot.merged.startupTimeout),
234287
info: "Configure how long Acode waits for the server to start",
288+
category: "Advanced",
289+
chevron: true,
235290
},
236291
{
237292
key: "edit_init_options",
@@ -240,11 +295,15 @@ function createItems(snapshot) {
240295
? "Configured"
241296
: "Empty",
242297
info: "Edit initialization options as JSON",
298+
category: "Advanced",
299+
chevron: true,
243300
},
244301
{
245302
key: "view_init_options",
246303
text: "View Initialization Options",
247304
info: "View the effective initialization options as JSON",
305+
category: "Advanced",
306+
chevron: true,
248307
},
249308
];
250309

@@ -254,6 +313,7 @@ function createItems(snapshot) {
254313
text,
255314
checkbox: snapshot.builtinExts[extKey] !== false,
256315
info,
316+
category: "Features",
257317
});
258318
});
259319

@@ -275,9 +335,7 @@ async function refreshVisibleState($list, itemsByKey, serverId) {
275335
"install_status",
276336
formatInstallStatus(snapshot.installResult),
277337
{
278-
info:
279-
snapshot.installResult.message ||
280-
"Current installation state for this language server",
338+
info: formatInstallInfo(snapshot.installResult),
281339
},
282340
);
283341
updateItemDisplay($list, itemsByKey, "install_server", "");
@@ -287,9 +345,7 @@ async function refreshVisibleState($list, itemsByKey, serverId) {
287345
$list,
288346
itemsByKey,
289347
"startup_timeout",
290-
typeof snapshot.merged.startupTimeout === "number"
291-
? `${snapshot.merged.startupTimeout} ms`
292-
: "Default (5000 ms)",
348+
formatStartupTimeoutValue(snapshot.merged.startupTimeout),
293349
);
294350
updateItemDisplay(
295351
$list,
@@ -379,6 +435,9 @@ export default function lspServerDetail(serverId) {
379435
undefined,
380436
{
381437
preserveOrder: true,
438+
pageClassName: "detail-settings-page",
439+
listClassName: "detail-settings-list",
440+
valueInTail: true,
382441
},
383442
);
384443

@@ -414,7 +473,8 @@ export default function lspServerDetail(serverId) {
414473
const result = await checkServerInstallation(snapshot.merged);
415474
const lines = [
416475
`Status: ${formatInstallStatus(result)}`,
417-
result.message ? `Details: ${result.message}` : null,
476+
result.version ? `Version: ${result.version}` : null,
477+
`Details: ${formatInstallInfo(result)}`,
418478
].filter(Boolean);
419479
alert("Installation Status", lines.join("<br>"));
420480
break;

src/settings/lspSettings.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,7 @@ export default function lspSettings() {
124124
text: "Add Custom Server",
125125
info: "Register a user-defined language server with install, update, and launch commands",
126126
index: 0,
127+
chevron: true,
127128
},
128129
];
129130

@@ -140,6 +141,7 @@ export default function lspSettings() {
140141
key: `server:${server.id}`,
141142
text: server.label,
142143
info: languagesList || undefined,
144+
chevron: true,
143145
});
144146
}
145147

@@ -149,6 +151,9 @@ export default function lspSettings() {
149151

150152
return settingsPage(title, items, callback, undefined, {
151153
preserveOrder: true,
154+
pageClassName: "detail-settings-page",
155+
listClassName: "detail-settings-list",
156+
groupByDefault: true,
152157
});
153158

154159
async function callback(key) {

0 commit comments

Comments
 (0)