Skip to content

Commit 33ac9ec

Browse files
authored
Merge pull request microsoft#250063 from microsoft/osortega/limit-replace-display-value
Limit replace display value to 10 lines
2 parents c892e65 + d2b0379 commit 33ac9ec

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
@@ -825,32 +825,46 @@ export class SearchView extends ViewPane {
825825
}
826826

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

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

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

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

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

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

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

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

0 commit comments

Comments
 (0)