Merge VS Code 1.23.1 (#1520)

This commit is contained in:
Matt Irvine
2018-06-05 11:24:51 -07:00
committed by GitHub
parent e3baf5c443
commit 0c58f09e59
3651 changed files with 74249 additions and 48599 deletions

View File

@@ -16,7 +16,6 @@ import { IWorkspaceContextService } from 'vs/platform/workspace/common/workspace
import { IStorageService } from 'vs/platform/storage/common/storage';
import * as editorCommon from 'vs/editor/common/editorCommon';
import { ICodeEditor } from 'vs/editor/browser/editorBrowser';
import { registerEditorContribution } from 'vs/editor/browser/editorExtensions';
import { ReferencesModel } from './referencesModel';
import { ReferenceWidget, LayoutData } from './referencesWidget';
import { Range } from 'vs/editor/common/core/range';
@@ -34,7 +33,7 @@ export interface RequestOptions {
onGoto?: (reference: Location) => TPromise<any>;
}
export class ReferencesController implements editorCommon.IEditorContribution {
export abstract class ReferencesController implements editorCommon.IEditorContribution {
private static readonly ID = 'editor.contrib.referencesController';
@@ -52,6 +51,7 @@ export class ReferencesController implements editorCommon.IEditorContribution {
}
public constructor(
private _defaultTreeKeyboardSupport: boolean,
editor: ICodeEditor,
@IContextKeyService contextKeyService: IContextKeyService,
@IEditorService private readonly _editorService: IEditorService,
@@ -103,7 +103,7 @@ export class ReferencesController implements editorCommon.IEditorContribution {
}));
const storageKey = 'peekViewLayout';
const data = <LayoutData>JSON.parse(this._storageService.get(storageKey, undefined, '{}'));
this._widget = new ReferenceWidget(this._editor, data, this._textModelResolverService, this._contextService, this._themeService, this._instantiationService, this._environmentService);
this._widget = new ReferenceWidget(this._editor, this._defaultTreeKeyboardSupport, data, this._textModelResolverService, this._contextService, this._themeService, this._instantiationService, this._environmentService);
this._widget.setTitle(nls.localize('labelLoading', "Loading..."));
this._widget.show(range);
this._disposables.push(this._widget.onDidClose(() => {
@@ -155,16 +155,17 @@ export class ReferencesController implements editorCommon.IEditorContribution {
// show widget
return this._widget.setModel(this._model).then(() => {
if (this._widget) { // might have been closed
// set title
this._widget.setMetaTitle(options.getMetaTitle(this._model));
// set title
this._widget.setMetaTitle(options.getMetaTitle(this._model));
// set 'best' selection
let uri = this._editor.getModel().uri;
let pos = new Position(range.startLineNumber, range.startColumn);
let selection = this._model.nearestReference(uri, pos);
if (selection) {
return this._widget.setSelection(selection);
// set 'best' selection
let uri = this._editor.getModel().uri;
let pos = new Position(range.startLineNumber, range.startColumn);
let selection = this._model.nearestReference(uri, pos);
if (selection) {
return this._widget.setSelection(selection);
}
}
return undefined;
});
@@ -174,6 +175,19 @@ export class ReferencesController implements editorCommon.IEditorContribution {
});
}
public async goToNextOrPreviousReference(fwd: boolean) {
if (this._model) { // can be called while still resolving...
let source = this._model.nearestReference(this._editor.getModel().uri, this._widget.position);
let target = this._model.nextOrPreviousReference(source, fwd);
let editorFocus = this._editor.isFocused();
await this._widget.setSelection(target);
await this._gotoReference(target);
if (editorFocus) {
this._editor.focus();
}
}
}
public closeWidget(): void {
if (this._widget) {
this._widget.dispose();
@@ -189,16 +203,16 @@ export class ReferencesController implements editorCommon.IEditorContribution {
this._requestIdPool += 1; // Cancel pending requests
}
private _gotoReference(ref: Location): void {
private _gotoReference(ref: Location): TPromise<any> {
this._widget.hide();
this._ignoreModelChangeEvent = true;
const { uri, range } = ref;
const range = Range.lift(ref.range).collapseToStart();
this._editorService.openEditor({
resource: uri,
return this._editorService.openEditor({
resource: ref.uri,
options: { selection: range }
}).done(openedEditor => {
}).then(openedEditor => {
this._ignoreModelChangeEvent = false;
if (!openedEditor || openedEditor.getControl() !== this._editor) {
@@ -235,5 +249,3 @@ export class ReferencesController implements editorCommon.IEditorContribution {
}
}
}
registerEditorContribution(ReferencesController);