Skip to content

Commit 3db7b4e

Browse files
author
Benjamin Pasero
committed
Buttons are cropped on the files save confirmation dialog while quitting VS Code (fixes microsoft#8008)
1 parent 068dc85 commit 3db7b4e

1 file changed

Lines changed: 16 additions & 5 deletions

File tree

src/vs/workbench/parts/files/electron-browser/textFileServices.ts

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@ import {IModelService} from 'vs/editor/common/services/modelService';
3333

3434
export class TextFileService extends AbstractTextFileService {
3535

36+
private static MAX_CONFIRM_FILES = 10;
37+
3638
constructor(
3739
@IWorkspaceContextService contextService: IWorkspaceContextService,
3840
@IInstantiationService instantiationService: IInstantiationService,
@@ -90,7 +92,7 @@ export class TextFileService extends AbstractTextFileService {
9092
// Save
9193
if (confirm === ConfirmResult.SAVE) {
9294
return this.saveAll(true /* includeUntitled */).then(result => {
93-
if (result.results.some((r) => !r.success)) {
95+
if (result.results.some(r => !r.success)) {
9496
return true; // veto if some saves failed
9597
}
9698

@@ -147,7 +149,7 @@ export class TextFileService extends AbstractTextFileService {
147149
return true;
148150
}
149151

150-
return this.untitledEditorService.getDirty().some((dirty) => !resource || dirty.toString() === resource.toString());
152+
return this.untitledEditorService.getDirty().some(dirty => !resource || dirty.toString() === resource.toString());
151153
}
152154

153155
public confirmSave(resources?: URI[]): ConfirmResult {
@@ -161,12 +163,21 @@ export class TextFileService extends AbstractTextFileService {
161163
}
162164

163165
let message = [
164-
resourcesToConfirm.length === 1 ? nls.localize('saveChangesMessage', "Do you want to save the changes you made to {0}?", paths.basename(resourcesToConfirm[0].fsPath)) : nls.localize('saveChangesMessages', "Do you want to save the changes to the following files?")
166+
resourcesToConfirm.length === 1 ? nls.localize('saveChangesMessage', "Do you want to save the changes you made to {0}?", paths.basename(resourcesToConfirm[0].fsPath)) : nls.localize('saveChangesMessages', "Do you want to save the changes to the following {0} files?", resourcesToConfirm.length)
165167
];
166168

167169
if (resourcesToConfirm.length > 1) {
168170
message.push('');
169-
message.push(...resourcesToConfirm.map((r) => paths.basename(r.fsPath)));
171+
message.push(...resourcesToConfirm.slice(0, TextFileService.MAX_CONFIRM_FILES).map(r => paths.basename(r.fsPath)));
172+
173+
if (resourcesToConfirm.length > TextFileService.MAX_CONFIRM_FILES) {
174+
if (resourcesToConfirm.length - TextFileService.MAX_CONFIRM_FILES === 1) {
175+
message.push(nls.localize('moreFile', "...1 additional file not shown"));
176+
} else {
177+
message.push(nls.localize('moreFiles', "...{0} additional files not shown", resourcesToConfirm.length - TextFileService.MAX_CONFIRM_FILES));
178+
}
179+
}
180+
170181
message.push('');
171182
}
172183

@@ -230,7 +241,7 @@ export class TextFileService extends AbstractTextFileService {
230241
// split up between files and untitled
231242
let filesToSave: URI[] = [];
232243
let untitledToSave: URI[] = [];
233-
toSave.forEach((s) => {
244+
toSave.forEach(s => {
234245
if (s.scheme === 'file') {
235246
filesToSave.push(s);
236247
} else if ((Array.isArray(arg1) || arg1 === true /* includeUntitled */) && s.scheme === 'untitled') {

0 commit comments

Comments
 (0)