mirror of https://github.com/openclaw/openclaw.git
refactor: share terminal note wrapping
This commit is contained in:
parent
827b166bbc
commit
f7f5c24786
|
|
@ -54,6 +54,21 @@ function isCopySensitiveToken(word: string): boolean {
|
|||
return word.includes("_") && FILE_LIKE_RE.test(word);
|
||||
}
|
||||
|
||||
function pushWrappedWordSegments(params: {
|
||||
word: string;
|
||||
available: number;
|
||||
firstPrefix: string;
|
||||
continuationPrefix: string;
|
||||
lines: string[];
|
||||
}) {
|
||||
const parts = splitLongWord(params.word, params.available);
|
||||
const first = parts.shift() ?? "";
|
||||
params.lines.push(params.firstPrefix + first);
|
||||
for (const part of parts) {
|
||||
params.lines.push(params.continuationPrefix + part);
|
||||
}
|
||||
}
|
||||
|
||||
function wrapLine(line: string, maxWidth: number): string[] {
|
||||
if (line.trim().length === 0) {
|
||||
return [line];
|
||||
|
|
@ -80,14 +95,15 @@ function wrapLine(line: string, maxWidth: number): string[] {
|
|||
current = word;
|
||||
continue;
|
||||
}
|
||||
const parts = splitLongWord(word, available);
|
||||
const first = parts.shift() ?? "";
|
||||
lines.push(prefix + first);
|
||||
pushWrappedWordSegments({
|
||||
word,
|
||||
available,
|
||||
firstPrefix: prefix,
|
||||
continuationPrefix: nextPrefix,
|
||||
lines,
|
||||
});
|
||||
prefix = nextPrefix;
|
||||
available = nextWidth;
|
||||
for (const part of parts) {
|
||||
lines.push(prefix + part);
|
||||
}
|
||||
continue;
|
||||
}
|
||||
current = word;
|
||||
|
|
@ -109,12 +125,13 @@ function wrapLine(line: string, maxWidth: number): string[] {
|
|||
current = word;
|
||||
continue;
|
||||
}
|
||||
const parts = splitLongWord(word, available);
|
||||
const first = parts.shift() ?? "";
|
||||
lines.push(prefix + first);
|
||||
for (const part of parts) {
|
||||
lines.push(prefix + part);
|
||||
}
|
||||
pushWrappedWordSegments({
|
||||
word,
|
||||
available,
|
||||
firstPrefix: prefix,
|
||||
continuationPrefix: prefix,
|
||||
lines,
|
||||
});
|
||||
current = "";
|
||||
continue;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue