Merge from vscode de81ccf04849309f843db21130c806a5783678f7 (#4738)

This commit is contained in:
Anthony Dresser
2019-03-28 13:06:16 -07:00
committed by GitHub
parent cc2951265e
commit e6785ffe95
77 changed files with 562 additions and 835 deletions

View File

@@ -320,8 +320,13 @@ export class Configuration extends CommonEditorConfiguration {
private readonly _elementSizeObserver: ElementSizeObserver;
constructor(options: IEditorOptions, referenceDomElement: HTMLElement | null = null, private readonly accessibilityService: IAccessibilityService) {
super(options);
constructor(
isSimpleWidget: boolean,
options: IEditorOptions,
referenceDomElement: HTMLElement | null = null,
private readonly accessibilityService: IAccessibilityService
) {
super(isSimpleWidget, options);
this._elementSizeObserver = this._register(new ElementSizeObserver(referenceDomElement, () => this._onReferenceDomElementSizeChanged()));

View File

@@ -324,7 +324,7 @@ export class CodeEditorWidget extends Disposable implements editorBrowser.ICodeE
}
protected _createConfiguration(options: editorOptions.IEditorOptions, accessibilityService: IAccessibilityService): editorCommon.IConfiguration {
return new Configuration(options, this._domElement, accessibilityService);
return new Configuration(this.isSimpleWidget, options, this._domElement, accessibilityService);
}
public getId(): string {

View File

@@ -65,6 +65,7 @@ const hasOwnProperty = Object.hasOwnProperty;
export abstract class CommonEditorConfiguration extends Disposable implements editorCommon.IConfiguration {
public readonly isSimpleWidget: boolean;
protected _rawOptions: editorOptions.IEditorOptions;
protected _validatedOptions: editorOptions.IValidatedEditorOptions;
public editor: editorOptions.InternalEditorOptions;
@@ -74,9 +75,11 @@ export abstract class CommonEditorConfiguration extends Disposable implements ed
private _onDidChange = this._register(new Emitter<editorOptions.IConfigurationChangedEvent>());
public readonly onDidChange: Event<editorOptions.IConfigurationChangedEvent> = this._onDidChange.event;
constructor(options: editorOptions.IEditorOptions) {
constructor(isSimpleWidget: boolean, options: editorOptions.IEditorOptions) {
super();
this.isSimpleWidget = isSimpleWidget;
// Do a "deep clone of sorts" on the incoming options
this._rawOptions = objects.mixin({}, options || {});
this._rawOptions.scrollbar = objects.mixin({}, this._rawOptions.scrollbar || {});
@@ -122,7 +125,7 @@ export abstract class CommonEditorConfiguration extends Disposable implements ed
private _computeInternalOptions(): editorOptions.InternalEditorOptions {
const opts = this._validatedOptions;
const partialEnv = this._getEnvConfiguration();
const bareFontInfo = BareFontInfo.createFromRawSettings(this._rawOptions, partialEnv.zoomLevel);
const bareFontInfo = BareFontInfo.createFromRawSettings(this._rawOptions, partialEnv.zoomLevel, this.isSimpleWidget);
const env: editorOptions.IEnvironmentalOptions = {
outerWidth: partialEnv.outerWidth,
outerHeight: partialEnv.outerHeight,
@@ -688,8 +691,8 @@ const editorConfiguration: IConfigurationNode = {
type: 'number',
default: EDITOR_DEFAULTS.contribInfo.suggest.maxVisibleSuggestions,
minimum: 1,
maximum: 12,
description: nls.localize('suggest.maxVisibleSuggestions', "Controls how many suggestions IntelliSense will show before showing a scrollbar.")
maximum: 15,
description: nls.localize('suggest.maxVisibleSuggestions', "Controls how many suggestions IntelliSense will show before showing a scrollbar (maximum 15).")
},
'editor.suggest.filteredTypes': {
type: 'object',
@@ -828,15 +831,15 @@ const editorConfiguration: IConfigurationNode = {
},
}
},
'editor.gotoLocation.many': {
description: nls.localize('editor.gotoLocation.many', "Controls the behaviour of 'go to'-commands, like go to definition, when multiple target locations exist."),
'editor.gotoLocation.multiple': {
description: nls.localize('editor.gotoLocation.multiple', "Controls the behavior of 'Go To' commands, like Go To Definition, when multiple target locations exist."),
type: 'string',
enum: ['peek', 'revealAndPeek', 'reveal'],
default: 'peek',
enum: ['peek', 'gotoAndPeek', 'goto'],
default: EDITOR_DEFAULTS.contribInfo.gotoLocation.multiple,
enumDescriptions: [
nls.localize('editor.gotoLocation.many.peek', 'Show peek view of the results at the request location'),
nls.localize('editor.gotoLocation.many.revealAndPeek', 'Reveal the first result and show peek view at its location'),
nls.localize('editor.gotoLocation.many.reveal', 'Reveal the first result and ignore others')
nls.localize('editor.gotoLocation.multiple.peek', 'Show peek view of the results (default)'),
nls.localize('editor.gotoLocation.multiple.gotoAndPeek', 'Go to the primary result and show a peek view'),
nls.localize('editor.gotoLocation.multiple.goto', 'Go to the primary result and ignore others')
]
},
'editor.selectionHighlight': {

View File

@@ -222,7 +222,7 @@ export interface IGotoLocationOptions {
/**
* Control how goto-command work when having multiple results.
*/
many?: 'peek' | 'revealAndPeek' | 'reveal';
multiple?: 'peek' | 'gotoAndPeek' | 'goto';
}
/**
@@ -270,7 +270,7 @@ export interface IEditorOptions {
lineNumbers?: 'on' | 'off' | 'relative' | 'interval' | ((lineNumber: number) => string);
/**
* Render last line number when the file ends with a newline.
* Defaults to true on Windows/Mac and to false on Linux.
* Defaults to true.
*/
renderFinalNewline?: boolean;
/**
@@ -936,7 +936,7 @@ export interface InternalEditorHoverOptions {
}
export interface InternalGoToLocationOptions {
readonly many: 'peek' | 'revealAndPeek' | 'reveal';
readonly multiple: 'peek' | 'gotoAndPeek' | 'goto';
}
export interface InternalSuggestOptions {
@@ -1401,7 +1401,8 @@ export class InternalEditorOptions {
&& a.localityBonus === b.localityBonus
&& a.shareSuggestSelections === b.shareSuggestSelections
&& a.showIcons === b.showIcons
&& a.maxVisibleSuggestions === b.maxVisibleSuggestions;
&& a.maxVisibleSuggestions === b.maxVisibleSuggestions
&& objects.equals(a.filteredTypes, b.filteredTypes);
}
}
@@ -1411,7 +1412,7 @@ export class InternalEditorOptions {
} else if (!a || !b) {
return false;
} else {
return a.many === b.many;
return a.multiple === b.multiple;
}
}
@@ -1946,7 +1947,7 @@ export class EditorOptionsValidator {
localityBonus: _boolean(suggestOpts.localityBonus, defaults.localityBonus),
shareSuggestSelections: _boolean(suggestOpts.shareSuggestSelections, defaults.shareSuggestSelections),
showIcons: _boolean(suggestOpts.showIcons, defaults.showIcons),
maxVisibleSuggestions: _clampedInt(suggestOpts.maxVisibleSuggestions, defaults.maxVisibleSuggestions, 1, 12),
maxVisibleSuggestions: _clampedInt(suggestOpts.maxVisibleSuggestions, defaults.maxVisibleSuggestions, 1, 15),
filteredTypes: isObject(suggestOpts.filteredTypes) ? suggestOpts.filteredTypes : Object.create(null)
};
}
@@ -1954,7 +1955,7 @@ export class EditorOptionsValidator {
private static _santizeGotoLocationOpts(opts: IEditorOptions, defaults: InternalGoToLocationOptions): InternalGoToLocationOptions {
const gotoOpts = opts.gotoLocation || {};
return {
many: _stringSet<'peek' | 'revealAndPeek' | 'reveal'>(gotoOpts.many, defaults.many, ['peek', 'revealAndPeek', 'reveal'])
multiple: _stringSet<'peek' | 'gotoAndPeek' | 'goto'>(gotoOpts.multiple, defaults.multiple, ['peek', 'gotoAndPeek', 'goto'])
};
}
@@ -2635,7 +2636,7 @@ export const EDITOR_DEFAULTS: IValidatedEditorOptions = {
ariaLabel: nls.localize('editorViewAccessibleLabel', "Editor content"),
renderLineNumbers: RenderLineNumbersType.On,
renderCustomLineNumbers: null,
renderFinalNewline: (platform.isLinux ? false : true),
renderFinalNewline: true,
selectOnLineNumbers: true,
glyphMargin: true,
revealHorizontalRightPadding: 30,
@@ -2720,7 +2721,7 @@ export const EDITOR_DEFAULTS: IValidatedEditorOptions = {
filteredTypes: Object.create(null)
},
gotoLocation: {
many: 'peek'
multiple: 'peek'
},
selectionHighlight: true,
occurrencesHighlight: true,

View File

@@ -80,7 +80,7 @@ export class BareFontInfo {
fontSize?: number | string;
lineHeight?: number | string;
letterSpacing?: number | string;
}, zoomLevel: number): BareFontInfo {
}, zoomLevel: number, ignoreEditorZoom: boolean = false): BareFontInfo {
let fontFamily = _string(opts.fontFamily, EDITOR_FONT_DEFAULTS.fontFamily);
let fontWeight = _string(opts.fontWeight, EDITOR_FONT_DEFAULTS.fontWeight);
@@ -105,7 +105,7 @@ export class BareFontInfo {
let letterSpacing = safeParseFloat(opts.letterSpacing, 0);
letterSpacing = clamp(letterSpacing, MINIMUM_LETTER_SPACING, MAXIMUM_LETTER_SPACING);
let editorZoomLevelMultiplier = 1 + (EditorZoom.getZoomLevel() * 0.1);
let editorZoomLevelMultiplier = 1 + (ignoreEditorZoom ? 0 : EditorZoom.getZoomLevel() * 0.1);
fontSize *= editorZoomLevelMultiplier;
lineHeight *= editorZoomLevelMultiplier;

View File

@@ -14,7 +14,7 @@ export const IModelService = createDecorator<IModelService>('modelService');
export interface IModelService {
_serviceBrand: any;
createModel(value: string | ITextBufferFactory, languageSelection: ILanguageSelection | null, resource: URI | undefined, isForSimpleWidget?: boolean): ITextModel;
createModel(value: string | ITextBufferFactory, languageSelection: ILanguageSelection | null, resource?: URI, isForSimpleWidget?: boolean): ITextModel;
updateModel(model: ITextModel, value: string | ITextBufferFactory): void;

View File

@@ -190,7 +190,7 @@ export class ModelServiceImpl extends Disposable implements IModelService {
};
}
public getCreationOptions(language: string, resource: URI | null | undefined, isForSimpleWidget: boolean): ITextModelCreationOptions {
public getCreationOptions(language: string, resource: URI | undefined, isForSimpleWidget: boolean): ITextModelCreationOptions {
let creationOptions = this._modelCreationOptionsByLanguageAndResource[language + resource];
if (!creationOptions) {
const editor = this._configurationService.getValue<IRawEditorConfig>('editor', { overrideIdentifier: language, resource });
@@ -252,7 +252,7 @@ export class ModelServiceImpl extends Disposable implements IModelService {
// --- begin IModelService
private _createModelData(value: string | ITextBufferFactory, languageIdentifier: LanguageIdentifier, resource: URI | null | undefined, isForSimpleWidget: boolean): ModelData {
private _createModelData(value: string | ITextBufferFactory, languageIdentifier: LanguageIdentifier, resource: URI | undefined, isForSimpleWidget: boolean): ModelData {
// create & save the model
const options = this.getCreationOptions(languageIdentifier.language, resource, isForSimpleWidget);
const model: TextModel = new TextModel(value, options, languageIdentifier, resource);
@@ -343,7 +343,7 @@ export class ModelServiceImpl extends Disposable implements IModelService {
return [EditOperation.replaceMove(oldRange, textBuffer.getValueInRange(newRange, EndOfLinePreference.TextDefined))];
}
public createModel(value: string | ITextBufferFactory, languageSelection: ILanguageSelection | null, resource: URI | null | undefined, isForSimpleWidget: boolean = false): ITextModel {
public createModel(value: string | ITextBufferFactory, languageSelection: ILanguageSelection | null, resource?: URI, isForSimpleWidget: boolean = false): ITextModel {
let modelData: ModelData;
if (languageSelection) {

View File

@@ -131,17 +131,19 @@ export class DefinitionAction extends EditorAction {
alert(msg);
const { gotoLocation } = editor.getConfiguration().contribInfo;
if (this._configuration.openInPeek || (gotoLocation.many === 'peek' && model.references.length > 1)) {
if (this._configuration.openInPeek || (gotoLocation.multiple === 'peek' && model.references.length > 1)) {
this._openInPeek(editorService, editor, model);
} else if (editor.hasModel()) {
const next = model.nearestReference(editor.getModel().uri, editor.getPosition());
if (next) {
const targetEditor = await this._openReference(editor, editorService, next, this._configuration.openToSide);
if (targetEditor && model.references.length > 1 && gotoLocation.many === 'revealAndPeek') {
this._openInPeek(editorService, targetEditor, model);
} else {
model.dispose();
}
const next = model.firstReference();
if (!next) {
return;
}
const targetEditor = await this._openReference(editor, editorService, next, this._configuration.openToSide);
if (targetEditor && model.references.length > 1 && gotoLocation.multiple === 'gotoAndPeek') {
this._openInPeek(editorService, targetEditor, model);
} else {
model.dispose();
}
}
}

View File

@@ -23,7 +23,8 @@ export class OneReference {
constructor(
readonly parent: FileReferences,
private _range: IRange
private _range: IRange,
readonly isProviderFirst: boolean
) {
this.id = defaultGenerator.nextId();
}
@@ -173,6 +174,7 @@ export class ReferencesModel implements IDisposable {
constructor(references: LocationLink[]) {
this._disposables = [];
// grouping and sorting
const [providersFirst] = references;
references.sort(ReferencesModel._compareReferences);
let current: FileReferences | undefined;
@@ -187,7 +189,7 @@ export class ReferencesModel implements IDisposable {
if (current.children.length === 0
|| !Range.equalsRange(ref.range, current.children[current.children.length - 1].range)) {
let oneRef = new OneReference(current, ref.targetSelectionRange || ref.range);
let oneRef = new OneReference(current, ref.targetSelectionRange || ref.range, providersFirst === ref);
this._disposables.push(oneRef.onRefChanged((e) => this._onDidChangeReferenceRange.fire(e)));
this.references.push(oneRef);
current.children.push(oneRef);
@@ -267,6 +269,15 @@ export class ReferencesModel implements IDisposable {
return undefined;
}
firstReference(): OneReference | undefined {
for (const ref of this.references) {
if (ref.isProviderFirst) {
return ref;
}
}
return this.references[0];
}
dispose(): void {
dispose(this.groups);
dispose(this._disposables);

View File

@@ -11,7 +11,7 @@ import { AccessibilitySupport } from 'vs/platform/accessibility/common/accessibi
export class TestConfiguration extends CommonEditorConfiguration {
constructor(opts: IEditorOptions) {
super(opts);
super(false, opts);
this._recomputeOptions();
}

View File

@@ -35,7 +35,7 @@ suite('ModelService', () => {
});
test('EOL setting respected depending on root', () => {
const model1 = modelService.createModel('farboo', null, null);
const model1 = modelService.createModel('farboo', null);
const model2 = modelService.createModel('farboo', null, URI.file(platform.isWindows ? 'c:\\myroot\\myfile.txt' : '/myroot/myfile.txt'));
const model3 = modelService.createModel('farboo', null, URI.file(platform.isWindows ? 'c:\\other\\myfile.txt' : '/other/myfile.txt'));