提交 46543615 编写于 作者: J Joao Moreno

Merge remote-tracking branch 'origin/master' into scm-api

......@@ -30,6 +30,7 @@ export class ViewCursor {
private _cursorStyle: TextEditorCursorStyle;
private _lastRenderedContent: string;
private _lineHeight: number;
private _characterWidth: number;
constructor(context: ViewContext, isSecondary: boolean) {
this._context = context;
......@@ -128,6 +129,19 @@ export class ViewCursor {
this._positionTop = visibleRange.top;
this._positionLeft = visibleRange.left;
this._isInViewport = true;
if (this._cursorStyle !== TextEditorCursorStyle.Line) {
let visibleRangeForCharacter = ctx.linesVisibleRangesForRange({
startLineNumber: this._position.lineNumber,
startColumn: this._position.column,
endLineNumber: this._position.lineNumber,
endColumn: this._position.column + 1
}, false);
if (visibleRangeForCharacter.length > 0 && visibleRangeForCharacter[0].ranges.length > 0) {
this._characterWidth = visibleRangeForCharacter[0].ranges[0].width;
}
}
} else {
this._isInViewport = false;
}
......@@ -156,6 +170,18 @@ export class ViewCursor {
this._domNode.setLineHeight(this._lineHeight);
this._domNode.setHeight(this._lineHeight);
if (this._cursorStyle !== TextEditorCursorStyle.Line) {
let desiredWidth = '1ch';
if (this._characterWidth > 0) {
desiredWidth = `${this._characterWidth}px`;
}
if (this._domNode.domNode.style.width !== desiredWidth) {
this._domNode.domNode.style.width = desiredWidth;
}
}
return {
position: this._position,
contentTop: top,
......
......@@ -30,55 +30,68 @@ export class BackupRestorer implements IWorkbenchContribution {
@ITextModelResolverService private textModelResolverService: ITextModelResolverService,
@IEditorGroupService private groupService: IEditorGroupService
) {
this.restoreBackups();
}
private restoreBackups(): void {
if (!this.environmentService.isExtensionDevelopment) {
this.restoreBackups();
this.partService.joinCreation().then(() => {
this.doRestoreBackups().done(null, errors.onUnexpectedError);
});
}
}
private restoreBackups(): void {
private doRestoreBackups(): TPromise<any> {
// Find all files and untitled with backups
return this.backupFileService.getWorkspaceFileBackups().then(backups => {
// Wait for all editors being restored before restoring backups
this.partService.joinCreation().then(() => {
const stacks = this.groupService.getStacksModel();
const hasOpenedEditors = stacks.groups.length > 0;
// Find all files and untitled with backups
this.backupFileService.getWorkspaceFileBackups().then(backups => {
const restorePromises: TPromise<any>[] = [];
const editorsToOpen: URI[] = [];
// Restore any backup that is opened and remember those that are not yet
backups.forEach(backup => {
if (stacks.isOpen(backup)) {
if (backup.scheme === 'file') {
restorePromises.push(this.textModelResolverService.createModelReference(backup));
} else if (backup.scheme === 'untitled') {
restorePromises.push(this.untitledEditorService.get(backup).resolve());
}
} else {
editorsToOpen.push(backup);
}
});
// Restore all backups that are opened as editors
return TPromise.join(restorePromises).then(() => {
if (editorsToOpen.length > 0) {
const resourceToInputs = TPromise.join(editorsToOpen.map(resource => this.editorService.createInput({ resource })));
return resourceToInputs.then(inputs => {
const openEditorsArgs = inputs.map((input, index) => {
return { input, options: { pinned: true, preserveFocus: true, inactive: index > 0 || hasOpenedEditors }, position: Position.ONE };
});
// Open all remaining backups as editors and resolve them to load their backups
return this.editorService.openEditors(openEditorsArgs).then(() => TPromise.join(inputs.map(input => input.resolve())));
});
}
});
}).done(null, errors.onUnexpectedError);
// Resolve backups that are opened in stacks model
return this.doResolveOpenedBackups(backups).then(unresolved => {
// Some failed to restore or were not opened at all so we open and resolve them manually
if (unresolved.length > 0) {
return this.doOpenEditors(unresolved).then(() => this.doResolveOpenedBackups(unresolved));
}
});
});
}
private doOpenEditors(inputs: URI[]): TPromise<void> {
const stacks = this.groupService.getStacksModel();
const hasOpenedEditors = stacks.groups.length > 0;
return TPromise.join(inputs.map(resource => this.editorService.createInput({ resource }))).then(inputs => {
const openEditorsArgs = inputs.map((input, index) => {
return { input, options: { pinned: true, preserveFocus: true, inactive: index > 0 || hasOpenedEditors }, position: Position.ONE };
});
// Open all remaining backups as editors and resolve them to load their backups
return this.editorService.openEditors(openEditorsArgs).then(() => void 0);
});
}
private doResolveOpenedBackups(backups: URI[]): TPromise<URI[]> {
const stacks = this.groupService.getStacksModel();
const restorePromises: TPromise<any>[] = [];
const unresolved: URI[] = [];
backups.forEach(backup => {
if (stacks.isOpen(backup)) {
if (backup.scheme === 'file') {
restorePromises.push(this.textModelResolverService.createModelReference(backup).then(null, () => unresolved.push(backup)));
} else if (backup.scheme === 'untitled') {
restorePromises.push(this.untitledEditorService.get(backup).resolve().then(null, () => unresolved.push(backup)));
}
} else {
unresolved.push(backup);
}
});
return TPromise.join(restorePromises).then(() => unresolved, () => unresolved);
}
public getId(): string {
return 'vs.backup.backupRestorer';
}
......
......@@ -10,6 +10,7 @@ import { KeyCode, KeyMod } from 'vs/base/common/keyCodes';
import * as paths from 'vs/base/common/paths';
import * as errors from 'vs/base/common/errors';
import { equalsIgnoreCase } from 'vs/base/common/strings';
import { IKeyboardEvent } from 'vs/base/browser/keyboardEvent';
import { isMacintosh } from 'vs/base/common/platform';
import * as dom from 'vs/base/browser/dom';
import { IMouseEvent, DragMouseEvent } from 'vs/base/browser/mouseEvent';
......@@ -20,16 +21,16 @@ import { ITree, IAccessibilityProvider, ContextMenuEvent, IDataSource, IRenderer
import { InputBox, IInputValidationOptions } from 'vs/base/browser/ui/inputbox/inputBox';
import { DefaultController, DefaultDragAndDrop } from 'vs/base/parts/tree/browser/treeDefaults';
import { IActionProvider } from 'vs/base/parts/tree/browser/actionsRenderer';
import { IContextViewService, IContextMenuService } from 'vs/platform/contextview/browser/contextView';
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
import { IWorkspaceContextService } from 'vs/platform/workspace/common/workspace';
import { IContextKeyService } from 'vs/platform/contextkey/common/contextkey';
import * as debug from 'vs/workbench/parts/debug/common/debug';
import { Expression, Variable, FunctionBreakpoint, StackFrame, Thread, Process, Breakpoint, ExceptionBreakpoint, Model, Scope } from 'vs/workbench/parts/debug/common/debugModel';
import { ViewModel } from 'vs/workbench/parts/debug/common/debugViewModel';
import { ContinueAction, StepOverAction, PauseAction, AddFunctionBreakpointAction, ReapplyBreakpointsAction, DisableAllBreakpointsAction, RemoveBreakpointAction, ToggleEnablementAction, RenameFunctionBreakpointAction, RemoveWatchExpressionAction, AddWatchExpressionAction, EditWatchExpressionAction, RemoveAllBreakpointsAction, EnableAllBreakpointsAction, StepOutAction, StepIntoAction, SetValueAction, RemoveAllWatchExpressionsAction, ToggleBreakpointsActivatedAction, RestartFrameAction, AddToWatchExpressionsAction } from 'vs/workbench/parts/debug/browser/debugActions';
import { CopyValueAction } from 'vs/workbench/parts/debug/electron-browser/electronDebugActions';
import { IContextViewService, IContextMenuService } from 'vs/platform/contextview/browser/contextView';
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
import { IWorkspaceContextService } from 'vs/platform/workspace/common/workspace';
import { Source } from 'vs/workbench/parts/debug/common/debugSource';
import { IKeyboardEvent } from 'vs/base/browser/keyboardEvent';
import { once } from 'vs/base/common/functional';
const $ = dom.$;
......@@ -130,8 +131,8 @@ function renderRenameBox(debugService: debug.IDebugService, contextViewService:
debugService.renameWatchExpression(element.getId(), inputBox.value).done(null, errors.onUnexpectedError);
} else if (element instanceof Expression && !element.name) {
debugService.removeWatchExpressions(element.getId());
} else if (element instanceof FunctionBreakpoint && renamed && inputBox.value) {
debugService.renameFunctionBreakpoint(element.getId(), inputBox.value).done(null, errors.onUnexpectedError);
} else if (element instanceof FunctionBreakpoint && inputBox.value) {
debugService.renameFunctionBreakpoint(element.getId(), renamed ? inputBox.value : element.name).done(null, errors.onUnexpectedError);
} else if (element instanceof FunctionBreakpoint && !element.name) {
debugService.removeFunctionBreakpoints(element.getId()).done(null, errors.onUnexpectedError);
} else if (element instanceof Variable) {
......@@ -176,10 +177,10 @@ function getSourceName(source: Source, contextService: IWorkspaceContextService)
export class BaseDebugController extends DefaultController {
constructor(
protected debugService: debug.IDebugService,
private contextMenuService: IContextMenuService,
private actionProvider: IActionProvider,
private focusOnContextMenu = true
@debug.IDebugService protected debugService: debug.IDebugService,
@IContextMenuService private contextMenuService: IContextMenuService,
@IContextKeyService contextKeyService: IContextKeyService
) {
super();
......@@ -189,6 +190,11 @@ export class BaseDebugController extends DefaultController {
this.downKeyBindingDispatcher.set(KeyCode.Delete, this.onDelete.bind(this));
this.downKeyBindingDispatcher.set(KeyMod.Shift | KeyCode.Delete, this.onDelete.bind(this));
}
if (isMacintosh) {
this.downKeyBindingDispatcher.set(KeyCode.Enter, this.onRename.bind(this));
} else {
this.downKeyBindingDispatcher.set(KeyCode.F2, this.onRename.bind(this));
}
}
public onContextMenu(tree: ITree, element: debug.IEnablement, event: ContextMenuEvent): boolean {
......@@ -199,9 +205,7 @@ export class BaseDebugController extends DefaultController {
event.preventDefault();
event.stopPropagation();
if (this.focusOnContextMenu) {
tree.setFocus(element);
}
tree.setFocus(element);
if (this.actionProvider.hasSecondaryActions(tree, element)) {
const anchor = { x: event.posx + 1, y: event.posy };
......@@ -225,6 +229,10 @@ export class BaseDebugController extends DefaultController {
protected onDelete(tree: ITree, event: IKeyboardEvent): boolean {
return false;
}
protected onRename(tree: ITree, event: IKeyboardEvent): boolean {
return false;
}
}
// call stack
......@@ -759,11 +767,6 @@ export class VariablesAccessibilityProvider implements IAccessibilityProvider {
export class VariablesController extends BaseDebugController {
constructor(debugService: debug.IDebugService, contextMenuService: IContextMenuService, actionProvider: IActionProvider) {
super(debugService, contextMenuService, actionProvider);
this.downKeyBindingDispatcher.set(KeyCode.Enter, this.setSelectedExpression.bind(this));
}
protected onLeftClick(tree: ITree, element: any, event: IMouseEvent): boolean {
// double click on primitive value: open input box to be able to set the value
if (element instanceof Variable && event.detail === 2) {
......@@ -777,7 +780,7 @@ export class VariablesController extends BaseDebugController {
return super.onLeftClick(tree, element, event);
}
protected setSelectedExpression(tree: ITree, event: KeyboardEvent): boolean {
protected onEnter(tree: ITree, event: IKeyboardEvent): boolean {
const element = tree.getFocus();
if (element instanceof Variable && !element.hasChildren) {
this.debugService.getViewModel().setSelectedExpression(element);
......@@ -995,16 +998,6 @@ export class WatchExpressionsAccessibilityProvider implements IAccessibilityProv
export class WatchExpressionsController extends BaseDebugController {
constructor(debugService: debug.IDebugService, contextMenuService: IContextMenuService, actionProvider: IActionProvider) {
super(debugService, contextMenuService, actionProvider);
if (isMacintosh) {
this.downKeyBindingDispatcher.set(KeyCode.Enter, this.onRename.bind(this));
} else {
this.downKeyBindingDispatcher.set(KeyCode.F2, this.onRename.bind(this));
}
}
protected onLeftClick(tree: ITree, element: any, event: IMouseEvent): boolean {
// double click on primitive value: open input box to be able to select and copy value.
if (element instanceof Expression && event.detail === 2) {
......@@ -1018,7 +1011,7 @@ export class WatchExpressionsController extends BaseDebugController {
return super.onLeftClick(tree, element, event);
}
protected onRename(tree: ITree, event: KeyboardEvent): boolean {
protected onRename(tree: ITree, event: IKeyboardEvent): boolean {
const element = tree.getFocus();
if (element instanceof Expression) {
const watchExpression = <Expression>element;
......@@ -1258,6 +1251,7 @@ export class BreakpointsRenderer implements IRenderer {
private renderFunctionBreakpoint(tree: ITree, functionBreakpoint: debug.IFunctionBreakpoint, data: IBaseBreakpointTemplateData): void {
const selected = this.debugService.getViewModel().getSelectedFunctionBreakpoint();
if (!functionBreakpoint.name || (selected && selected.getId() === functionBreakpoint.getId())) {
data.name.textContent = '';
renderRenameBox(this.debugService, this.contextViewService, tree, functionBreakpoint, data.breakpoint, {
initialValue: functionBreakpoint.name,
placeholder: nls.localize('functionBreakpointPlaceholder', "Function to break on"),
......@@ -1328,15 +1322,6 @@ export class BreakpointsAccessibilityProvider implements IAccessibilityProvider
export class BreakpointsController extends BaseDebugController {
constructor(debugService: debug.IDebugService, contextMenuService: IContextMenuService, actionProvider: IActionProvider) {
super(debugService, contextMenuService, actionProvider);
if (isMacintosh) {
this.downKeyBindingDispatcher.set(KeyCode.Enter, this.onRename.bind(this));
} else {
this.downKeyBindingDispatcher.set(KeyCode.F2, this.onRename.bind(this));
}
}
protected onLeftClick(tree: ITree, element: any, event: IMouseEvent): boolean {
if (element instanceof FunctionBreakpoint && event.detail === 2) {
this.debugService.getViewModel().setSelectedFunctionBreakpoint(element);
......
......@@ -86,7 +86,7 @@ export class VariablesView extends CollapsibleViewletView {
dataSource: new viewer.VariablesDataSource(),
renderer: this.instantiationService.createInstance(viewer.VariablesRenderer),
accessibilityProvider: new viewer.VariablesAccessibilityProvider(),
controller: new viewer.VariablesController(this.debugService, this.contextMenuService, new viewer.VariablesActionProvider(this.instantiationService))
controller: this.instantiationService.createInstance(viewer.VariablesController, new viewer.VariablesActionProvider(this.instantiationService))
}, {
ariaLabel: nls.localize('variablesAriaTreeLabel', "Debug Variables"),
twistiePixels
......@@ -182,7 +182,7 @@ export class WatchExpressionsView extends CollapsibleViewletView {
dataSource: new viewer.WatchExpressionsDataSource(),
renderer: this.instantiationService.createInstance(viewer.WatchExpressionsRenderer, actionProvider, this.actionRunner),
accessibilityProvider: new viewer.WatchExpressionsAccessibilityProvider(),
controller: new viewer.WatchExpressionsController(this.debugService, this.contextMenuService, actionProvider),
controller: this.instantiationService.createInstance(viewer.WatchExpressionsController, actionProvider),
dnd: this.instantiationService.createInstance(viewer.WatchExpressionsDragAndDrop)
}, {
ariaLabel: nls.localize({ comment: ['Debug is a noun in this context, not a verb.'], key: 'watchAriaTreeLabel' }, "Debug Watch Expressions"),
......@@ -301,7 +301,7 @@ export class CallStackView extends CollapsibleViewletView {
dataSource: this.instantiationService.createInstance(viewer.CallStackDataSource),
renderer: this.instantiationService.createInstance(viewer.CallStackRenderer),
accessibilityProvider: this.instantiationService.createInstance(viewer.CallstackAccessibilityProvider),
controller: new viewer.CallStackController(this.debugService, this.contextMenuService, actionProvider)
controller: this.instantiationService.createInstance(viewer.CallStackController, actionProvider)
}, {
ariaLabel: nls.localize({ comment: ['Debug is a noun in this context, not a verb.'], key: 'callStackAriaLabel' }, "Debug Call Stack"),
twistiePixels
......@@ -361,7 +361,7 @@ export class BreakpointsView extends AdaptiveCollapsibleViewletView {
dataSource: new viewer.BreakpointsDataSource(),
renderer: this.instantiationService.createInstance(viewer.BreakpointsRenderer, actionProvider, this.actionRunner),
accessibilityProvider: this.instantiationService.createInstance(viewer.BreakpointsAccessibilityProvider),
controller: new viewer.BreakpointsController(this.debugService, this.contextMenuService, actionProvider),
controller: this.instantiationService.createInstance(viewer.BreakpointsController, actionProvider),
sorter: {
compare(tree: ITree, element: any, otherElement: any): number {
const first = <IBreakpoint>element;
......
......@@ -143,7 +143,7 @@ export class Repl extends Panel implements IPrivateReplService {
dataSource: new ReplExpressionsDataSource(),
renderer: this.renderer,
accessibilityProvider: new ReplExpressionsAccessibilityProvider(),
controller: new ReplExpressionsController(this.debugService, this.contextMenuService, new ReplExpressionsActionProvider(this.instantiationService), this.replInput, false)
controller: this.instantiationService.createInstance(ReplExpressionsController, this.replInput, new ReplExpressionsActionProvider(this.instantiationService))
}, replTreeOptions);
if (!Repl.HISTORY) {
......
......@@ -26,6 +26,7 @@ import { AddToWatchExpressionsAction, ClearReplAction } from 'vs/workbench/parts
import { CopyAction } from 'vs/workbench/parts/debug/electron-browser/electronDebugActions';
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
import { IContextMenuService } from 'vs/platform/contextview/browser/contextView';
import { IContextKeyService } from 'vs/platform/contextkey/common/contextkey';
import { IWorkbenchEditorService } from 'vs/workbench/services/editor/common/editorService';
import { IWorkspaceContextService } from 'vs/platform/workspace/common/workspace';
......@@ -496,13 +497,13 @@ export class ReplExpressionsController extends BaseDebugController {
private lastSelectedString: string = null;
constructor(
debugService: IDebugService,
contextMenuService: IContextMenuService,
actionProvider: IActionProvider,
private replInput: ICodeEditor,
focusOnContextMenu = true
actionProvider: IActionProvider,
@IDebugService debugService: IDebugService,
@IContextMenuService contextMenuService: IContextMenuService,
@IContextKeyService contextKeyService: IContextKeyService
) {
super(debugService, contextMenuService, actionProvider, focusOnContextMenu);
super(actionProvider, debugService, contextMenuService, contextKeyService);
}
protected onLeftClick(tree: ITree, element: any, eventish: ICancelableEvent, origin: string = 'mouse'): boolean {
......
......@@ -152,16 +152,6 @@ export class Adapter {
description: nls.localize('internalConsoleOptions', "Controls behavior of the internal debug console.")
};
const warnRelativePaths = (attribute: IJSONSchema) => {
if (attribute) {
attribute.pattern = '^\\${.*}.*|' + paths.isAbsoluteRegex.source;
attribute.errorMessage = nls.localize('relativePathsNotConverted', "Relative paths will no longer be automatically converted to absolute ones. Consider using ${workspaceRoot} as a prefix.");
}
};
warnRelativePaths(properties['outDir']);
warnRelativePaths(properties['program']);
warnRelativePaths(properties['cwd']);
const osProperties = objects.deepClone(properties);
properties['windows'] = {
type: 'object',
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册