mirror of
https://github.com/getcompanion-ai/co-mono.git
synced 2026-04-21 03:04:28 +00:00
fix(tui): expand paste markers when opening external editor (#444)
* fix(tui): expand paste markers when opening external editor Add getExpandedText() method to Editor that substitutes paste markers with actual content. Use it in Ctrl-G external editor flow so users see full pasted content instead of [paste #N ...] placeholders. * docs: add changelog entries for #444
This commit is contained in:
parent
6ddfd1be13
commit
0d477d39f9
4 changed files with 20 additions and 1 deletions
|
|
@ -1,9 +1,11 @@
|
||||||
# Changelog
|
# Changelog
|
||||||
|
|
||||||
## [Unreleased]
|
## [Unreleased]
|
||||||
|
|
||||||
### Fixed
|
### Fixed
|
||||||
|
|
||||||
- Fixed potential text decoding issues in bash executor by using streaming TextDecoder instead of Buffer.toString()
|
- Fixed potential text decoding issues in bash executor by using streaming TextDecoder instead of Buffer.toString()
|
||||||
|
- External editor (Ctrl-G) now shows full pasted content instead of `[paste #N ...]` placeholders ([#444](https://github.com/badlogic/pi-mono/pull/444) by [@aliou](https://github.com/aliou))
|
||||||
|
|
||||||
## [0.33.0] - 2026-01-04
|
## [0.33.0] - 2026-01-04
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1627,7 +1627,7 @@ export class InteractiveMode {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const currentText = this.editor.getText();
|
const currentText = this.editor.getExpandedText();
|
||||||
const tmpFile = path.join(os.tmpdir(), `pi-editor-${Date.now()}.pi.md`);
|
const tmpFile = path.join(os.tmpdir(), `pi-editor-${Date.now()}.pi.md`);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,10 @@
|
||||||
|
|
||||||
## [Unreleased]
|
## [Unreleased]
|
||||||
|
|
||||||
|
### Added
|
||||||
|
|
||||||
|
- `Editor.getExpandedText()` method that returns text with paste markers expanded to their actual content ([#444](https://github.com/badlogic/pi-mono/pull/444) by [@aliou](https://github.com/aliou))
|
||||||
|
|
||||||
## [0.33.0] - 2026-01-04
|
## [0.33.0] - 2026-01-04
|
||||||
|
|
||||||
### Breaking Changes
|
### Breaking Changes
|
||||||
|
|
|
||||||
|
|
@ -696,6 +696,19 @@ export class Editor implements Component {
|
||||||
return this.state.lines.join("\n");
|
return this.state.lines.join("\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get text with paste markers expanded to their actual content.
|
||||||
|
* Use this when you need the full content (e.g., for external editor).
|
||||||
|
*/
|
||||||
|
getExpandedText(): string {
|
||||||
|
let result = this.state.lines.join("\n");
|
||||||
|
for (const [pasteId, pasteContent] of this.pastes) {
|
||||||
|
const markerRegex = new RegExp(`\\[paste #${pasteId}( (\\+\\d+ lines|\\d+ chars))?\\]`, "g");
|
||||||
|
result = result.replace(markerRegex, pasteContent);
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
getLines(): string[] {
|
getLines(): string[] {
|
||||||
return [...this.state.lines];
|
return [...this.state.lines];
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue