提交 88d91e54 编写于 作者: B Benjamin Pasero

Merge branch 'master' into ben/fuzzy-quickopen

Conflicts:
	src/vs/workbench/electron-browser/main.contribution.ts
......@@ -21,8 +21,8 @@ class SyncedBuffer {
private diagnosticRequestor: IDiagnosticRequestor;
private client: ITypescriptServiceClient;
constructor(model: TextDocument, filepath: string, diagnosticRequestor: IDiagnosticRequestor, client: ITypescriptServiceClient) {
this.document = model;
constructor(document: TextDocument, filepath: string, diagnosticRequestor: IDiagnosticRequestor, client: ITypescriptServiceClient) {
this.document = document;
this.filepath = filepath;
this.diagnosticRequestor = diagnosticRequestor;
this.client = client;
......@@ -30,26 +30,10 @@ class SyncedBuffer {
public open(): void {
let args: Proto.OpenRequestArgs = {
file: this.filepath
file: this.filepath,
fileContent: this.document.getText()
};
this.client.execute('open', args, false);
// The last line never has a new line character at the end. So we use range.
// Sending a replace doesn't work if the buffer is newer then on disk and
// if changes are on the last line. In this case the tsserver has less characters
// which makes the tsserver bail since the range is invalid
/*
let lastLineRange = this.document.lineAt(this.document.lineCount - 1).range;
let text = this.document.getText();
let changeArgs: Proto.ChangeRequestArgs = {
file: this.filepath,
line: 1,
offset: 1,
endLine: lastLineRange.end.line + 1,
endOffset: lastLineRange.end.character + 1,
insertString: text
}
this.client.execute('change', changeArgs, false);
*/
}
public close(): void {
......
......@@ -40,7 +40,7 @@ interface RequestItem {
export default class TypeScriptServiceClient implements ITypescriptServiceClient {
public static Trace: boolean = false;
public static Trace: boolean = process.env.TSS_TRACE || false;
private host: ITypescriptServiceClientHost;
private pathSeparator: string;
......
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
'use strict';
import {IDisposable} from 'vs/base/common/lifecycle';
import Event, {Emitter} from 'vs/base/common/event';
export class ApiCommands {
static Instance = new ApiCommands();
private _commands: { [id: string]: [(...args: any[]) => any, any] } = Object.create(null);
private _onDidAddCommand = new Emitter<{ id: string; handler: (...args: any[]) => any; thisArg?: any }>();
add(id: string, handler: (...args: any[]) => any, thisArg?: any) {
if (this._commands[id]) {
throw new Error();
}
this._commands[id] = [handler, thisArg];
this._onDidAddCommand.fire({ id, handler, thisArg });
}
track(callback: (event: { id: string; handler: (...args: any[]) => any; thisArg?: any }) => any): IDisposable {
for (let id in this._commands) {
let [handler, thisArg] = this._commands[id];
callback({ id, handler, thisArg });
}
return this._onDidAddCommand.event(callback);
}
}
export function addApiCommand(id: string, handler: (...args: any[]) => any, thisArg?: any) {
ApiCommands.Instance.add(id, handler, thisArg);
}
\ No newline at end of file
......@@ -8,6 +8,7 @@ import {Registry} from 'vs/platform/platform';
import {ICommandHandler, ICommandsMap, IKeybindingItem, IKeybindings, IKeybindingContextRule} from 'vs/platform/keybinding/common/keybindingService';
import {KeybindingsUtils} from 'vs/platform/keybinding/common/keybindingsUtils';
import {KeyMod, KeyCode, BinaryKeybindings} from 'vs/base/common/keyCodes';
import {ApiCommands} from 'vs/platform/keybinding/common/commands';
import Platform = require('vs/base/common/platform');
export interface ICommandRule extends IKeybindings {
......@@ -67,6 +68,17 @@ class KeybindingsRegistryImpl implements IKeybindingsRegistry {
constructor() {
this._keybindings = [];
this._commands = Object.create(null);
ApiCommands.Instance.track(event => {
this.registerCommandDesc({
id: event.id,
handler: function(accessor, args) {
event.handler.apply(event.thisArg, args);
},
weight: this.WEIGHT.externalExtension(0),
context: undefined,
primary: undefined
});
});
}
public registerCommandRule(rule:ICommandRule): void {
......
......@@ -35,6 +35,7 @@ import {NavigateTypesSupportRegistry, INavigateTypesSupport, ITypeBearing} from
import {RenameRegistry} from 'vs/editor/contrib/rename/common/rename';
import {FormatRegistry, FormatOnTypeRegistry} from 'vs/editor/contrib/format/common/format';
import {ICodeLensData} from 'vs/editor/contrib/codelens/common/codelens';
import {addApiCommand} from 'vs/platform/keybinding/common/commands';
export class ExtHostLanguageFeatureCommands {
......@@ -44,28 +45,30 @@ export class ExtHostLanguageFeatureCommands {
constructor(commands: PluginHostCommands) {
this._commands = commands;
this._register('vscode.executeWorkspaceSymbolProvider', this._executeWorkspaceSymbolProvider);
this._register('vscode.executeDefinitionProvider', this._executeDefinitionProvider);
this._register('vscode.executeHoverProvider', this._executeHoverProvider);
this._register('vscode.executeDocumentHighlights', this._executeDocumentHighlights);
this._register('vscode.executeReferenceProvider', this._executeReferenceProvider);
this._register('vscode.executeDocumentRenameProvider', this._executeDocumentRenameProvider);
this._register('vscode.executeSignatureHelpProvider', this._executeSignatureHelpProvider);
this._register('vscode.executeDocumentSymbolProvider', this._executeDocumentSymbolProvider);
this._register('vscode.executeCompletionItemProvider', this._executeCompletionItemProvider);
this._register('vscode.executeCodeActionProvider', this._executeCodeActionProvider);
this._register('vscode.executeCodeLensProvider', this._executeCodeLensProvider);
this._register('vscode.executeFormatDocumentProvider', this._executeFormatDocumentProvider);
this._register('vscode.executeFormatRangeProvider', this._executeFormatRangeProvider);
this._register('vscode.executeFormatOnTypeProvider', this._executeFormatOnTypeProvider);
}
private _register(id: string, callback: (...args: any[]) => any): void {
this._disposables.push(this._commands.registerCommand(id, callback, this));
addApiCommand('vscode.executeWorkspaceSymbolProvider', this._executeWorkspaceSymbolProvider, this);
addApiCommand('vscode.executeDefinitionProvider', this._executeDefinitionProvider, this);
addApiCommand('vscode.executeHoverProvider', this._executeHoverProvider, this);
addApiCommand('vscode.executeDocumentHighlights', this._executeDocumentHighlights, this);
addApiCommand('vscode.executeReferenceProvider', this._executeReferenceProvider, this);
addApiCommand('vscode.executeDocumentRenameProvider', this._executeDocumentRenameProvider, this);
addApiCommand('vscode.executeSignatureHelpProvider', this._executeSignatureHelpProvider, this);
addApiCommand('vscode.executeDocumentSymbolProvider', this._executeDocumentSymbolProvider, this);
addApiCommand('vscode.executeCompletionItemProvider', this._executeCompletionItemProvider, this);
addApiCommand('vscode.executeCodeActionProvider', this._executeCodeActionProvider, this);
addApiCommand('vscode.executeCodeLensProvider', this._executeCodeLensProvider, this);
addApiCommand('vscode.executeFormatDocumentProvider', this._executeFormatDocumentProvider, this);
addApiCommand('vscode.executeFormatRangeProvider', this._executeFormatRangeProvider, this);
addApiCommand('vscode.executeFormatOnTypeProvider', this._executeFormatOnTypeProvider, this);
}
// --- command impl
/**
* Execute workspace symbol provider.
*
* @param query Search string to match query symbol names
* @return A promise that resolves to an array of symbol information.
*/
private _executeWorkspaceSymbolProvider(query: string): Thenable<types.SymbolInformation[]> {
return this._commands.executeCommand<ITypeBearing[]>('_executeWorkspaceSymbolProvider', { query }).then(value => {
if (Array.isArray(value)) {
......
......@@ -15,6 +15,7 @@ import {PluginHostEditors} from 'vs/workbench/api/common/pluginHostEditors';
import {IMessageService, Severity} from 'vs/platform/message/common/message';
import {canSerialize} from 'vs/base/common/marshalling';
import {toErrorMessage} from 'vs/base/common/errors';
import {ApiCommands} from 'vs/platform/keybinding/common/commands';
import * as vscode from 'vscode';
@Remotable.PluginHostContext('PluginHostCommands')
......@@ -27,6 +28,11 @@ export class PluginHostCommands {
constructor(@IThreadService threadService: IThreadService) {
this._pluginHostEditors = threadService.getRemotable(PluginHostEditors);
this._proxy = threadService.getRemotable(MainThreadCommands);
ApiCommands.Instance.track(event => {
let {id, handler, thisArg} = event;
this.registerCommand(id, handler, thisArg);
});
}
registerCommand(id: string, command: <T>(...args: any[]) => T | Thenable<T>, thisArgs?: any): vscode.Disposable {
......
......@@ -16,12 +16,13 @@ import {CloseEditorAction, ReloadWindowAction, ShowStartupPerformance, ZoomReset
// Contribute Global Actions
const viewCategory = nls.localize('view', "View");
const developerCategory = nls.localize('developerCat', "Developer");
const developerCategory = nls.localize('developer', "Developer");
const fileCategory = nls.localize('file', "File");
const workbenchActionsRegistry = <IWorkbenchActionRegistry>Registry.as(Extensions.WorkbenchActions);
workbenchActionsRegistry.registerWorkbenchAction(new SyncActionDescriptor(NewWindowAction, NewWindowAction.ID, NewWindowAction.LABEL, { primary: KeyMod.CtrlCmd | KeyMod.Shift | KeyCode.KEY_N }));
workbenchActionsRegistry.registerWorkbenchAction(new SyncActionDescriptor(CloseWindowAction, CloseWindowAction.ID, CloseWindowAction.LABEL, { primary: KeyMod.CtrlCmd | KeyMod.Shift | KeyCode.KEY_W }));
workbenchActionsRegistry.registerWorkbenchAction(new SyncActionDescriptor(CloseFolderAction, CloseFolderAction.ID, CloseFolderAction.LABEL, { primary: KeyMod.chord(KeyMod.CtrlCmd | KeyCode.KEY_K, KeyCode.KEY_F) }), nls.localize('file', "File"));
workbenchActionsRegistry.registerWorkbenchAction(new SyncActionDescriptor(OpenRecentAction, OpenRecentAction.ID, OpenRecentAction.LABEL), nls.localize('file', "File"));
workbenchActionsRegistry.registerWorkbenchAction(new SyncActionDescriptor(CloseFolderAction, CloseFolderAction.ID, CloseFolderAction.LABEL, { primary: KeyMod.chord(KeyMod.CtrlCmd | KeyCode.KEY_K, KeyCode.KEY_F) }), fileCategory);
workbenchActionsRegistry.registerWorkbenchAction(new SyncActionDescriptor(OpenRecentAction, OpenRecentAction.ID, OpenRecentAction.LABEL), fileCategory);
workbenchActionsRegistry.registerWorkbenchAction(new SyncActionDescriptor(ToggleDevToolsAction, ToggleDevToolsAction.ID, ToggleDevToolsAction.LABEL), developerCategory);
workbenchActionsRegistry.registerWorkbenchAction(new SyncActionDescriptor(ZoomInAction, ZoomInAction.ID, ZoomInAction.LABEL, { primary: KeyMod.CtrlCmd | KeyCode.US_EQUAL }), viewCategory);
workbenchActionsRegistry.registerWorkbenchAction(new SyncActionDescriptor(ZoomOutAction, ZoomOutAction.ID, ZoomOutAction.LABEL, { primary: KeyMod.CtrlCmd | KeyCode.US_MINUS }), viewCategory);
......@@ -29,18 +30,11 @@ workbenchActionsRegistry.registerWorkbenchAction(new SyncActionDescriptor(ZoomRe
workbenchActionsRegistry.registerWorkbenchAction(new SyncActionDescriptor(ShowStartupPerformance, ShowStartupPerformance.ID, ShowStartupPerformance.LABEL), developerCategory);
workbenchActionsRegistry.registerWorkbenchAction(new SyncActionDescriptor(ReloadWindowAction, ReloadWindowAction.ID, ReloadWindowAction.LABEL));
workbenchActionsRegistry.registerWorkbenchAction(new SyncActionDescriptor(CloseMessagesAction, CloseMessagesAction.ID, CloseMessagesAction.LABEL, { primary: KeyCode.Escape }, [{ key: WorkbenchMessageService.GLOBAL_MESSAGES_SHOWING_CONTEXT }]));
workbenchActionsRegistry.registerWorkbenchAction(new SyncActionDescriptor(CloseEditorAction, CloseEditorAction.ID, CloseEditorAction.LABEL, {
primary: KeyMod.CtrlCmd | KeyCode.KEY_W,
win: { primary: KeyMod.CtrlCmd | KeyCode.F4, secondary: [KeyMod.CtrlCmd | KeyCode.KEY_W] }
}), viewCategory);
workbenchActionsRegistry.registerWorkbenchAction(new SyncActionDescriptor(ToggleFullScreenAction, ToggleFullScreenAction.ID, ToggleFullScreenAction.LABEL, {
primary: KeyCode.F11,
mac: { primary: KeyMod.CtrlCmd | KeyMod.WinCtrl | KeyCode.KEY_F }
}), viewCategory);
workbenchActionsRegistry.registerWorkbenchAction(new SyncActionDescriptor(CloseEditorAction, CloseEditorAction.ID, CloseEditorAction.LABEL, { primary: KeyMod.CtrlCmd | KeyCode.KEY_W, win: { primary: KeyMod.CtrlCmd | KeyCode.F4, secondary: [KeyMod.CtrlCmd | KeyCode.KEY_W] } }), viewCategory);
workbenchActionsRegistry.registerWorkbenchAction(new SyncActionDescriptor(ToggleFullScreenAction, ToggleFullScreenAction.ID, ToggleFullScreenAction.LABEL, { primary: KeyCode.F11, mac: { primary: KeyMod.CtrlCmd | KeyMod.WinCtrl | KeyCode.KEY_F } }), viewCategory);
// Configuration: Window
const configurationRegistry = <IConfigurationRegistry>Registry.as(ConfigurationExtensions.Configuration);
// Window Configuration
configurationRegistry.registerConfiguration({
'id': 'window',
'order': 6,
......@@ -66,7 +60,7 @@ configurationRegistry.registerConfiguration({
}
});
// Update Configuration
// Configuration: Update
configurationRegistry.registerConfiguration({
'id': 'update',
'order': 10,
......@@ -77,7 +71,7 @@ configurationRegistry.registerConfiguration({
'type': 'string',
'default': 'stable',
'description': nls.localize('updateChannel', "Configure the update channel to receive updates from. Requires a restart after change.")
},
}
}
});
......
......@@ -15,8 +15,19 @@
height: calc(100% - 24px);
}
.monaco-workbench .repl .surveyor {
font-family: Monaco, Menlo, Consolas, "Droid Sans Mono", "Inconsolata", "Courier New", monospace, "Droid Sans Fallback";
position: absolute;
display: inline-block;
width : auto;
top: 0;
left: 0;
visibility: hidden;
}
.monaco-workbench .repl .repl-tree .monaco-tree .monaco-tree-row > .content {
line-height: 24px;
word-wrap: break-word;
-webkit-user-select: initial;
}
......
......@@ -48,6 +48,8 @@ export class Repl extends baseeditor.BaseEditor {
private toDispose: lifecycle.IDisposable[];
private tree: tree.ITree;
private renderer: viewer.ReplExpressionsRenderer;
private characterWidthSurveyor: HTMLElement;
private treeContainer: HTMLElement;
private replInput: HTMLInputElement;
private refreshTimeoutHandle: number;
......@@ -121,9 +123,17 @@ export class Repl extends baseeditor.BaseEditor {
}
});
this.characterWidthSurveyor = dom.append(container, $('.surveyor'));
this.characterWidthSurveyor.textContent = 'a';
for (let i = 0; i < 10; i++) {
this.characterWidthSurveyor.textContent += this.characterWidthSurveyor.textContent;
}
this.characterWidthSurveyor.style.fontSize = platform.isMacintosh ? '12px' : '14px';
this.renderer = this.instantiationService.createInstance(viewer.ReplExpressionsRenderer);
this.tree = new treeimpl.Tree(this.treeContainer, {
dataSource: new viewer.ReplExpressionsDataSource(this.debugService),
renderer: this.instantiationService.createInstance(viewer.ReplExpressionsRenderer),
renderer: this.renderer,
controller: new viewer.ReplExpressionsController(this.debugService, this.contextMenuService, new viewer.ReplExpressionsActionProvider(this.instantiationService), this.replInput, false)
}, replTreeOptions);
......@@ -146,7 +156,9 @@ export class Repl extends baseeditor.BaseEditor {
public layout(dimension: builder.Dimension): void {
if (this.tree) {
this.renderer.setWidth(dimension.width - 20, this.characterWidthSurveyor.clientWidth / this.characterWidthSurveyor.textContent.length);
this.tree.layout(this.treeContainer.clientHeight);
this.tree.refresh().done(null, errors.onUnexpectedError);
}
}
......
......@@ -107,6 +107,9 @@ export class ReplExpressionsRenderer implements tree.IRenderer {
/((\/|[a-zA-Z]:\\)[^\(\)<>\'\"\[\]]+):(\d+):(\d+)/
]
private width: number;
private characterWidth: number;
constructor(
@debug.IDebugService private debugService: debug.IDebugService,
@IWorkbenchEditorService private editorService: IWorkbenchEditorService,
......@@ -116,7 +119,20 @@ export class ReplExpressionsRenderer implements tree.IRenderer {
}
public getHeight(tree:tree.ITree, element:any): number {
return element instanceof model.Expression ? 48 : 24;
return this.getHeightForString(element.value) + (element instanceof model.Expression ? this.getHeightForString(element.name) : 0);
}
private getHeightForString(s: string): number {
if (!s || !s.length || this.width <= 0 || this.characterWidth <= 0) {
return 24;
}
return 24 * Math.ceil(s.length * this.characterWidth / this.width);
}
public setWidth(fullWidth: number, characterWidth: number): void {
this.width = fullWidth;
this.characterWidth = characterWidth;
}
public getTemplateId(tree: tree.ITree, element: any): string {
......
......@@ -257,7 +257,7 @@ export class WatchingProblemCollector extends AbstractProblemCollector implement
private markers: IStringDictionary<IMarkerData[]>;
// Cleaning state
private ignoreOpenByOwner: IStringDictionary<boolean>;
private ignoreOpenResourcesByOwner: IStringDictionary<boolean>;
private resourcesToClean: IStringDictionary<IStringDictionary<URI>>;
constructor(problemMatchers: ProblemMatcher[], markerService: IMarkerService, modelService: IModelService) {
......@@ -266,7 +266,7 @@ export class WatchingProblemCollector extends AbstractProblemCollector implement
this.markerService = markerService;
this.resetCurrentResource();
this.resourcesToClean = Object.create(null);
this.ignoreOpenByOwner = Object.create(null);
this.ignoreOpenResourcesByOwner = Object.create(null);
this.watchingBeginsPatterns = [];
this.watchingEndsPatterns = [];
this.problemMatchers.forEach(matcher => {
......@@ -283,13 +283,13 @@ export class WatchingProblemCollector extends AbstractProblemCollector implement
this.emit(ProblemCollectorEvents.WatchingBeginDetected, {});
this.recordResourcesToClean(matcher.owner);
}
let value: boolean = this.ignoreOpenByOwner[matcher.owner];
let value: boolean = this.ignoreOpenResourcesByOwner[matcher.owner];
if (!value) {
this.ignoreOpenByOwner[matcher.owner] = (matcher.applyTo === ApplyToKind.closedDocuments);
this.ignoreOpenResourcesByOwner[matcher.owner] = (matcher.applyTo === ApplyToKind.closedDocuments);
} else {
let newValue = value && (matcher.applyTo === ApplyToKind.closedDocuments);
if (newValue != value) {
this.ignoreOpenByOwner[matcher.owner] = newValue;
this.ignoreOpenResourcesByOwner[matcher.owner] = newValue;
}
}
})
......@@ -395,7 +395,8 @@ export class WatchingProblemCollector extends AbstractProblemCollector implement
let resourceSet = this.resourcesToClean[owner];
if (resourceSet) {
let toClean = Object.keys(resourceSet).map(key => resourceSet[key]).filter(resource => {
return this.ignoreOpenByOwner[owner] && !this.isOpen(resource);
// Check whether we need to ignore open documents for this owner.
return this.ignoreOpenResourcesByOwner[owner] ? !this.isOpen(resource) : true;
});
this.markerService.remove(owner, toClean);
if (remove) {
......
......@@ -30,6 +30,7 @@ define([
'vs/workbench/browser/actions/triggerEditorActions',
'vs/workbench/browser/actions/triggerNavigation',
'vs/workbench/browser/actions/showPerformanceBox',
'vs/workbench/browser/actions/openSettings',
'vs/workbench/parts/quickopen/browser/quickopen.contribution',
......@@ -56,7 +57,6 @@ define([
'vs/workbench/parts/markdown/browser/markdownActions.contribution',
'vs/workbench/browser/workbench',
'vs/workbench/browser/actions/openSettings',
'vs/workbench/parts/tasks/electron-browser/task.contribution',
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册