Skip to content

Commit d2b0379

Browse files
committed
Limit replace display value to 10 lines
1 parent d4c6686 commit d2b0379

File tree

1 file changed

+22
-8
lines changed

1 file changed

+22
-8
lines changed

src/vs/workbench/contrib/search/browser/searchView.ts

Lines changed: 22 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -824,32 +824,46 @@ export class SearchView extends ViewPane {
824824
}
825825

826826
private buildReplaceAllConfirmationMessage(occurrences: number, fileCount: number, replaceValue?: string) {
827+
// Helper to truncate long values to 10 lines max
828+
const truncateValue = (value: string | undefined): string | undefined => {
829+
if (!value) {
830+
return value;
831+
}
832+
const lines = value.split('\n');
833+
if (lines.length > 10) {
834+
return lines.slice(0, 10).join('\n') + '\n...';
835+
}
836+
return value;
837+
};
838+
839+
const displayReplaceValue = truncateValue(replaceValue);
840+
827841
if (occurrences === 1) {
828842
if (fileCount === 1) {
829-
if (replaceValue) {
830-
return nls.localize('removeAll.occurrence.file.confirmation.message', "Replace {0} occurrence across {1} file with '{2}'?", occurrences, fileCount, replaceValue);
843+
if (displayReplaceValue) {
844+
return nls.localize('removeAll.occurrence.file.confirmation.message', "Replace {0} occurrence across {1} file with '{2}'?", occurrences, fileCount, displayReplaceValue);
831845
}
832846

833847
return nls.localize('replaceAll.occurrence.file.confirmation.message', "Replace {0} occurrence across {1} file?", occurrences, fileCount);
834848
}
835849

836-
if (replaceValue) {
837-
return nls.localize('removeAll.occurrence.files.confirmation.message', "Replace {0} occurrence across {1} files with '{2}'?", occurrences, fileCount, replaceValue);
850+
if (displayReplaceValue) {
851+
return nls.localize('removeAll.occurrence.files.confirmation.message', "Replace {0} occurrence across {1} files with '{2}'?", occurrences, fileCount, displayReplaceValue);
838852
}
839853

840854
return nls.localize('replaceAll.occurrence.files.confirmation.message', "Replace {0} occurrence across {1} files?", occurrences, fileCount);
841855
}
842856

843857
if (fileCount === 1) {
844-
if (replaceValue) {
845-
return nls.localize('removeAll.occurrences.file.confirmation.message', "Replace {0} occurrences across {1} file with '{2}'?", occurrences, fileCount, replaceValue);
858+
if (displayReplaceValue) {
859+
return nls.localize('removeAll.occurrences.file.confirmation.message', "Replace {0} occurrences across {1} file with '{2}'?", occurrences, fileCount, displayReplaceValue);
846860
}
847861

848862
return nls.localize('replaceAll.occurrences.file.confirmation.message', "Replace {0} occurrences across {1} file?", occurrences, fileCount);
849863
}
850864

851-
if (replaceValue) {
852-
return nls.localize('removeAll.occurrences.files.confirmation.message', "Replace {0} occurrences across {1} files with '{2}'?", occurrences, fileCount, replaceValue);
865+
if (displayReplaceValue) {
866+
return nls.localize('removeAll.occurrences.files.confirmation.message', "Replace {0} occurrences across {1} files with '{2}'?", occurrences, fileCount, displayReplaceValue);
853867
}
854868

855869
return nls.localize('replaceAll.occurrences.files.confirmation.message', "Replace {0} occurrences across {1} files?", occurrences, fileCount);

0 commit comments

Comments
 (0)