提交 99249b59 编写于 作者: J Johannes Rieken

fix #8917

immediatly return focus to editor
show progress after 250ms
fix wording
上级 22606ac7
......@@ -14,6 +14,7 @@ import {IEditorService} from 'vs/platform/editor/common/editor';
import {IEventService} from 'vs/platform/event/common/event';
import {IKeybindingContextKey, IKeybindingService, KbExpr} from 'vs/platform/keybinding/common/keybinding';
import {IMessageService} from 'vs/platform/message/common/message';
import {IProgressService} from 'vs/platform/progress/common/progress';
import {EditorAction} from 'vs/editor/common/editorAction';
import {Behaviour} from 'vs/editor/common/editorActionEnablement';
import {IEditorActionDescriptorData, IRange} from 'vs/editor/common/editorCommon';
......@@ -35,20 +36,18 @@ export class RenameAction extends EditorAction {
public static ID: string = 'editor.action.rename';
private _messageService: IMessageService;
private _eventService: IEventService;
private _editorService: IEditorService;
private _renameInputField: RenameInputField;
private _renameInputVisible: IKeybindingContextKey<boolean>;
constructor(descriptor: IEditorActionDescriptorData, editor: ICodeEditor,
@IMessageService messageService: IMessageService, @IKeybindingService keybindingService: IKeybindingService,
@IEventService eventService: IEventService, @IEditorService editorService: IEditorService) {
@IMessageService private _messageService: IMessageService,
@IEventService private _eventService: IEventService,
@IEditorService private _editorService: IEditorService,
@IProgressService private _progressService: IProgressService,
@IKeybindingService keybindingService: IKeybindingService
) {
super(descriptor, editor, Behaviour.WidgetFocus | Behaviour.Writeable);
this._messageService = messageService;
this._eventService = eventService;
this._editorService = editorService;
this._renameInputField = new RenameInputField(editor);
this._renameInputVisible = keybindingService.createKey(CONTEXT_RENAME_INPUT_VISIBLE, false);
}
......@@ -90,10 +89,11 @@ export class RenameAction extends EditorAction {
this._renameInputVisible.set(true);
return this._renameInputField.getInput(wordRange, word.word, selectionStart, selectionEnd).then(newName => {
this._renameInputVisible.reset();
return this._prepareRename(newName).then(edit => {
this.editor.focus();
const renameOperation = this._prepareRename(newName).then(edit => {
return edit.finish().then(selection => {
this.editor.focus();
if (selection) {
this.editor.setSelection(selection);
}
......@@ -103,10 +103,14 @@ export class RenameAction extends EditorAction {
if (typeof err === 'string') {
this._messageService.show(Severity.Info, err);
} else {
this._messageService.show(Severity.Error, nls.localize('rename.failed', "Sorry, rename failed with to execute."));
this._messageService.show(Severity.Error, nls.localize('rename.failed', "Sorry, rename failed to execute."));
return TPromise.wrapError(err);
}
});
this._progressService.showWhile(renameOperation, 250);
return renameOperation;
}, err => {
this._renameInputVisible.reset();
this.editor.focus();
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册