pi-powerline 0.8.0 → 0.8.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/CHANGELOG.md CHANGED
@@ -1,3 +1,10 @@
1
+ ## [0.8.1](https://github.com/jwu/pi-powerline/compare/v0.8.0...v0.8.1) (2026-06-28)
2
+
3
+
4
+ ### Bug Fixes
5
+
6
+ * **editor:** prevent over-wide lines in narrow terminals ([12c8ced](https://github.com/jwu/pi-powerline/commit/12c8ced96573d76480d52ffafc7addd6516bac66))
7
+
1
8
  # [0.8.0](https://github.com/jwu/pi-powerline/compare/v0.7.1...v0.8.0) (2026-06-09)
2
9
 
3
10
 
@@ -76,16 +76,34 @@ export interface PromptPrefixColorTokens {
76
76
 
77
77
  /** Custom editor with a ❯ prompt prefix. Colors use `PromptPrefixColorTokens`. */
78
78
  export class PromptPrefixEditor extends CustomEditor {
79
+ private readonly tuiRef: any;
80
+
79
81
  static colorTokens: PromptPrefixColorTokens = {
80
82
  border: 'borderAccent',
81
83
  prefix: 'dim',
82
84
  indent: 'border',
83
85
  };
84
86
 
87
+ constructor(tui: any, theme: EditorTheme, keybindings: any) {
88
+ super(tui, theme, keybindings);
89
+ this.tuiRef = tui;
90
+ }
91
+
85
92
  render(width: number): string[] {
86
- const contentWidth = Math.max(1, width - 2);
93
+ const terminalColumns = Number(this.tuiRef?.terminal?.columns);
94
+ const renderWidth = Math.max(
95
+ 1,
96
+ Math.floor(
97
+ Number.isFinite(terminalColumns) && terminalColumns > 0
98
+ ? Math.min(width, terminalColumns)
99
+ : width,
100
+ ),
101
+ );
102
+ const contentWidth = Math.max(1, renderWidth - 2);
87
103
  const lines = super.render(contentWidth);
88
- if (lines.length < 3) return lines;
104
+ if (lines.length < 3) {
105
+ return lines.map((line) => truncateToWidth(line, renderWidth, ''));
106
+ }
89
107
 
90
108
  const theme = currentTheme;
91
109
  const color = (token: ThemeColor | undefined, text: string) =>
@@ -103,7 +121,7 @@ export class PromptPrefixEditor extends CustomEditor {
103
121
 
104
122
  const result = renderPromptPrefix(
105
123
  lines,
106
- width,
124
+ renderWidth,
107
125
  color(tokens.border, '─'),
108
126
  color(tokens.prefix, '❯'),
109
127
  tokens.indent ? color(tokens.indent, ' ') : ' ',
@@ -118,16 +136,16 @@ export class PromptPrefixEditor extends CustomEditor {
118
136
 
119
137
  const infoWidth = visibleWidth(infoPart);
120
138
  // '─ ' (2) + info + ' ' (1) + dashes → total width
121
- let paddingLen = width - 3 - infoWidth;
139
+ let paddingLen = renderWidth - 3 - infoWidth;
122
140
  let displayInfo = infoPart;
123
141
 
124
142
  if (paddingLen < 2) {
125
143
  // info too wide or not enough dashes, truncate with ellipsis, keep at least 2 dashes
126
144
  const minDashes = 2;
127
- const availForInfo = width - 3 - minDashes;
145
+ const availForInfo = renderWidth - 3 - minDashes;
128
146
  if (availForInfo > 0) {
129
147
  displayInfo = truncateToWidth(infoPart, availForInfo, '...');
130
- paddingLen = width - 3 - visibleWidth(displayInfo);
148
+ paddingLen = renderWidth - 3 - visibleWidth(displayInfo);
131
149
  }
132
150
  }
133
151
 
@@ -139,7 +157,7 @@ export class PromptPrefixEditor extends CustomEditor {
139
157
  }
140
158
  }
141
159
 
142
- return result;
160
+ return result.map((line) => truncateToWidth(line, renderWidth, ''));
143
161
  }
144
162
  }
145
163
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pi-powerline",
3
- "version": "0.8.0",
3
+ "version": "0.8.1",
4
4
  "description": "Powerline-style UI extensions for pi coding agent (custom editor, breadcrumb, footer, header)",
5
5
  "homepage": "https://github.com/jwu/pi-powerline#readme",
6
6
  "repository": {