@xynogen/pix-pretty 1.37.0 → 1.37.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/command-preview.ts +17 -13
package/package.json
CHANGED
package/src/command-preview.ts
CHANGED
|
@@ -14,25 +14,29 @@ export function commandPreview(
|
|
|
14
14
|
expanded = false,
|
|
15
15
|
/** Body column: under the tool name (2-col status glyph + space). */
|
|
16
16
|
indent = 3,
|
|
17
|
-
/** Renderer context:
|
|
18
|
-
ctx?: ExpandHintCtx,
|
|
17
|
+
/** Renderer context: expand key and whether streamed arguments are ready to highlight. */
|
|
18
|
+
ctx?: ExpandHintCtx & { executionStarted?: boolean },
|
|
19
19
|
) {
|
|
20
|
+
if (ctx?.executionStarted === false) language = undefined;
|
|
20
21
|
type Slot = { code: string; language: string | undefined; theme: typeof theme; styled: string };
|
|
21
22
|
let slot = state.commandPreview as Slot | undefined;
|
|
22
23
|
if (!slot || slot.code !== code || slot.language !== language || slot.theme !== theme) {
|
|
23
|
-
slot = { code, language, theme, styled: theme.fg("dim", code) };
|
|
24
|
+
slot = { code, language, theme, styled: language ? theme.fg("dim", code) : code };
|
|
24
25
|
state.commandPreview = slot;
|
|
25
26
|
const pending = slot;
|
|
26
|
-
|
|
27
|
-
(
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
27
|
+
if (language)
|
|
28
|
+
void hlBlock(code, language, theme).then(
|
|
29
|
+
(lines) => {
|
|
30
|
+
if (state.commandPreview !== pending) return;
|
|
31
|
+
const styled = lines.join("\n");
|
|
32
|
+
if (pending.styled === styled) return;
|
|
33
|
+
pending.styled = styled;
|
|
34
|
+
invalidate();
|
|
35
|
+
},
|
|
36
|
+
() => {
|
|
37
|
+
/* Plain text remains available if highlighting fails. */
|
|
38
|
+
},
|
|
39
|
+
);
|
|
36
40
|
}
|
|
37
41
|
const current = slot;
|
|
38
42
|
let replacement: string | undefined;
|