Skip to content

Commit d532279

Browse files
author
Benjamin Pasero
committed
"Retry as sudo" claims it "failed to save" but it actually succeeded (fix microsoft#93602)
1 parent 3813586 commit d532279

3 files changed

Lines changed: 18 additions & 8 deletions

File tree

src/vs/workbench/services/textfile/electron-browser/nativeTextFileService.ts

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ import { ICodeEditorService } from 'vs/editor/browser/services/codeEditorService
4040
import { IRemotePathService } from 'vs/workbench/services/path/common/remotePathService';
4141
import { IWorkingCopyFileService } from 'vs/workbench/services/workingCopy/common/workingCopyFileService';
4242
import { INativeWorkbenchEnvironmentService } from 'vs/workbench/services/environment/electron-browser/environmentService';
43+
import { ILogService } from 'vs/platform/log/common/log';
4344

4445
export class NativeTextFileService extends AbstractTextFileService {
4546

@@ -58,7 +59,8 @@ export class NativeTextFileService extends AbstractTextFileService {
5859
@ITextModelService textModelService: ITextModelService,
5960
@ICodeEditorService codeEditorService: ICodeEditorService,
6061
@IRemotePathService remotePathService: IRemotePathService,
61-
@IWorkingCopyFileService workingCopyFileService: IWorkingCopyFileService
62+
@IWorkingCopyFileService workingCopyFileService: IWorkingCopyFileService,
63+
@ILogService private readonly logService: ILogService
6264
) {
6365
super(fileService, untitledTextEditorService, lifecycleService, instantiationService, modelService, environmentService, dialogService, fileDialogService, textResourceConfigurationService, filesConfigurationService, textModelService, codeEditorService, remotePathService, workingCopyFileService);
6466
}
@@ -298,8 +300,16 @@ export class NativeTextFileService extends AbstractTextFileService {
298300
sudoCommand.push('--file-write', `"${source}"`, `"${target}"`);
299301

300302
sudoPrompt.exec(sudoCommand.join(' '), promptOptions, (error: string, stdout: string, stderr: string) => {
301-
if (error || stderr) {
302-
reject(error || stderr);
303+
if (stdout) {
304+
this.logService.trace(`[sudo-prompt] received stdout: ${stdout}`);
305+
}
306+
307+
if (stderr) {
308+
this.logService.trace(`[sudo-prompt] received stderr: ${stderr}`);
309+
}
310+
311+
if (error) {
312+
reject(error);
303313
} else {
304314
resolve(undefined);
305315
}

src/vs/workbench/services/workspaces/electron-browser/workspaceEditingService.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -140,8 +140,6 @@ export class NativeWorkspaceEditingService extends AbstractWorkspaceEditingServi
140140
return false;
141141
}
142142
}
143-
144-
return false;
145143
}
146144

147145
async isValidTargetWorkspacePath(path: URI): Promise<boolean> {

src/vs/workbench/test/electron-browser/workbenchTestServices.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ import { IReadTextFileOptions, ITextFileStreamContent, ITextFileService } from '
2727
import { createTextBufferFactoryFromStream } from 'vs/editor/common/model/textModel';
2828
import { IOpenedWindow, IOpenEmptyWindowOptions, IWindowOpenable, IOpenWindowOptions } from 'vs/platform/windows/common/windows';
2929
import { parseArgs, OPTIONS } from 'vs/platform/environment/node/argv';
30-
import { LogLevel } from 'vs/platform/log/common/log';
30+
import { LogLevel, ILogService } from 'vs/platform/log/common/log';
3131
import { IRemotePathService } from 'vs/workbench/services/path/common/remotePathService';
3232
import { IWorkingCopyFileService } from 'vs/workbench/services/workingCopy/common/workingCopyFileService';
3333
import { UTF16le, UTF16be, UTF8_with_bom } from 'vs/base/node/encoding';
@@ -74,7 +74,8 @@ export class TestTextFileService extends NativeTextFileService {
7474
@ITextModelService textModelService: ITextModelService,
7575
@ICodeEditorService codeEditorService: ICodeEditorService,
7676
@IRemotePathService remotePathService: IRemotePathService,
77-
@IWorkingCopyFileService workingCopyFileService: IWorkingCopyFileService
77+
@IWorkingCopyFileService workingCopyFileService: IWorkingCopyFileService,
78+
@ILogService logService: ILogService
7879
) {
7980
super(
8081
fileService,
@@ -91,7 +92,8 @@ export class TestTextFileService extends NativeTextFileService {
9192
textModelService,
9293
codeEditorService,
9394
remotePathService,
94-
workingCopyFileService
95+
workingCopyFileService,
96+
logService
9597
);
9698
}
9799

0 commit comments

Comments
 (0)