Merge from vscode 5d18ad4c5902e3bddbc9f78da82dfc2ac349e908 (#9683)

This commit is contained in:
Anthony Dresser
2020-03-20 01:17:27 -07:00
committed by GitHub
parent 1520441b84
commit dd8fb9433b
89 changed files with 3095 additions and 445 deletions

View File

@@ -747,13 +747,13 @@ export class DiffReview extends Disposable {
let ariaLabel: string = '';
switch (type) {
case DiffEntryType.Equal:
ariaLabel = nls.localize('equalLine', "original {0}, modified {1}: {2}", originalLine, modifiedLine, lineContent);
ariaLabel = nls.localize('equalLine', "{0} original line {1} modified line {2}", lineContent, originalLine, modifiedLine);
break;
case DiffEntryType.Insert:
ariaLabel = nls.localize('insertLine', "+ modified {0}: {1}", modifiedLine, lineContent);
ariaLabel = nls.localize('insertLine', "+ {0} modified line {1}", lineContent, modifiedLine);
break;
case DiffEntryType.Delete:
ariaLabel = nls.localize('deleteLine', "- original {0}: {1}", originalLine, lineContent);
ariaLabel = nls.localize('deleteLine', "- {0} original line {1}", lineContent, originalLine);
break;
}
row.setAttribute('aria-label', ariaLabel);
@@ -869,9 +869,14 @@ class DiffReviewPrev extends EditorAction {
function findFocusedDiffEditor(accessor: ServicesAccessor): DiffEditorWidget | null {
const codeEditorService = accessor.get(ICodeEditorService);
const diffEditors = codeEditorService.listDiffEditors();
const activeCodeEditor = codeEditorService.getActiveCodeEditor();
if (!activeCodeEditor) {
return null;
}
for (let i = 0, len = diffEditors.length; i < len; i++) {
const diffEditor = <DiffEditorWidget>diffEditors[i];
if (diffEditor.hasWidgetFocus()) {
if (diffEditor.getModifiedEditor().getId() === activeCodeEditor.getId() || diffEditor.getOriginalEditor().getId() === activeCodeEditor.getId()) {
return diffEditor;
}
}

View File

@@ -2841,6 +2841,14 @@ export interface ISuggestOptions {
* Show typeParameter-suggestions.
*/
showTypeParameters?: boolean;
/**
* Show issue-suggestions.
*/
showIssues?: boolean;
/**
* Show user-suggestions.
*/
showUsers?: boolean;
/**
* Show snippet-suggestions.
*/
@@ -2895,6 +2903,8 @@ class EditorSuggest extends BaseEditorOption<EditorOption.suggest, InternalSugge
showFolders: true,
showTypeParameters: true,
showSnippets: true,
showUsers: true,
showIssues: true,
statusBar: {
visible: false
}
@@ -3083,6 +3093,16 @@ class EditorSuggest extends BaseEditorOption<EditorOption.suggest, InternalSugge
default: true,
markdownDescription: nls.localize('editor.suggest.showSnippets', "When enabled IntelliSense shows `snippet`-suggestions.")
},
'editor.suggest.showUsers': {
type: 'boolean',
default: true,
markdownDescription: nls.localize('editor.suggest.showUsers', "When enabled IntelliSense shows `user`-suggestions.")
},
'editor.suggest.showIssues': {
type: 'boolean',
default: true,
markdownDescription: nls.localize('editor.suggest.showIssues', "When enabled IntelliSense shows `issues`-suggestions.")
},
'editor.suggest.statusBar.visible': {
type: 'boolean',
default: false,
@@ -3131,6 +3151,8 @@ class EditorSuggest extends BaseEditorOption<EditorOption.suggest, InternalSugge
showFolders: EditorBooleanOption.boolean(input.showFolders, this.defaultValue.showFolders),
showTypeParameters: EditorBooleanOption.boolean(input.showTypeParameters, this.defaultValue.showTypeParameters),
showSnippets: EditorBooleanOption.boolean(input.showSnippets, this.defaultValue.showSnippets),
showUsers: EditorBooleanOption.boolean(input.showUsers, this.defaultValue.showUsers),
showIssues: EditorBooleanOption.boolean(input.showIssues, this.defaultValue.showIssues),
statusBar: {
visible: EditorBooleanOption.boolean(input.statusBar?.visible, !!this.defaultValue.statusBar.visible)
}

View File

@@ -319,6 +319,8 @@ export const enum CompletionItemKind {
Customcolor,
Folder,
TypeParameter,
User,
Issue,
Snippet, // <- highest value (used for compare!)
}
@@ -327,32 +329,34 @@ export const enum CompletionItemKind {
*/
export const completionKindToCssClass = (function () {
let data = Object.create(null);
data[CompletionItemKind.Method] = 'method';
data[CompletionItemKind.Function] = 'function';
data[CompletionItemKind.Constructor] = 'constructor';
data[CompletionItemKind.Field] = 'field';
data[CompletionItemKind.Variable] = 'variable';
data[CompletionItemKind.Class] = 'class';
data[CompletionItemKind.Struct] = 'struct';
data[CompletionItemKind.Interface] = 'interface';
data[CompletionItemKind.Module] = 'module';
data[CompletionItemKind.Property] = 'property';
data[CompletionItemKind.Event] = 'event';
data[CompletionItemKind.Operator] = 'operator';
data[CompletionItemKind.Unit] = 'unit';
data[CompletionItemKind.Value] = 'value';
data[CompletionItemKind.Constant] = 'constant';
data[CompletionItemKind.Enum] = 'enum';
data[CompletionItemKind.EnumMember] = 'enum-member';
data[CompletionItemKind.Keyword] = 'keyword';
data[CompletionItemKind.Snippet] = 'snippet';
data[CompletionItemKind.Text] = 'text';
data[CompletionItemKind.Color] = 'color';
data[CompletionItemKind.File] = 'file';
data[CompletionItemKind.Reference] = 'reference';
data[CompletionItemKind.Customcolor] = 'customcolor';
data[CompletionItemKind.Folder] = 'folder';
data[CompletionItemKind.TypeParameter] = 'type-parameter';
data[CompletionItemKind.Method] = 'symbol-method';
data[CompletionItemKind.Function] = 'symbol-function';
data[CompletionItemKind.Constructor] = 'symbol-constructor';
data[CompletionItemKind.Field] = 'symbol-field';
data[CompletionItemKind.Variable] = 'symbol-variable';
data[CompletionItemKind.Class] = 'symbol-class';
data[CompletionItemKind.Struct] = 'symbol-struct';
data[CompletionItemKind.Interface] = 'symbol-interface';
data[CompletionItemKind.Module] = 'symbol-module';
data[CompletionItemKind.Property] = 'symbol-property';
data[CompletionItemKind.Event] = 'symbol-event';
data[CompletionItemKind.Operator] = 'symbol-operator';
data[CompletionItemKind.Unit] = 'symbol-unit';
data[CompletionItemKind.Value] = 'symbol-value';
data[CompletionItemKind.Constant] = 'symbol-constant';
data[CompletionItemKind.Enum] = 'symbol-enum';
data[CompletionItemKind.EnumMember] = 'symbol-enum-member';
data[CompletionItemKind.Keyword] = 'symbol-keyword';
data[CompletionItemKind.Snippet] = 'symbol-snippet';
data[CompletionItemKind.Text] = 'symbol-text';
data[CompletionItemKind.Color] = 'symbol-color';
data[CompletionItemKind.File] = 'symbol-file';
data[CompletionItemKind.Reference] = 'symbol-reference';
data[CompletionItemKind.Customcolor] = 'symbol-customcolor';
data[CompletionItemKind.Folder] = 'symbol-folder';
data[CompletionItemKind.TypeParameter] = 'symbol-type-parameter';
data[CompletionItemKind.User] = 'account';
data[CompletionItemKind.Issue] = 'issues';
return function (kind: CompletionItemKind) {
return data[kind] || 'property';
@@ -395,7 +399,8 @@ export let completionKindFromString: {
data['folder'] = CompletionItemKind.Folder;
data['type-parameter'] = CompletionItemKind.TypeParameter;
data['typeParameter'] = CompletionItemKind.TypeParameter;
data['account'] = CompletionItemKind.User;
data['issue'] = CompletionItemKind.Issue;
return function (value: string, strict?: true) {
let res = data[value];
if (typeof res === 'undefined' && !strict) {

View File

@@ -53,7 +53,9 @@ export enum CompletionItemKind {
Customcolor = 22,
Folder = 23,
TypeParameter = 24,
Snippet = 25
User = 25,
Issue = 26,
Snippet = 27
}
export enum CompletionItemTag {

View File

@@ -13,7 +13,7 @@ import { IQuickPick, IQuickPickItem, IKeyMods } from 'vs/platform/quickinput/com
import { CancellationToken } from 'vs/base/common/cancellation';
import { IDisposable, DisposableStore, toDisposable } from 'vs/base/common/lifecycle';
import { Event } from 'vs/base/common/event';
import { isDiffEditor } from 'vs/editor/browser/editorBrowser';
import { isDiffEditor, getCodeEditor } from 'vs/editor/browser/editorBrowser';
import { withNullAsUndefined } from 'vs/base/common/types';
import { once } from 'vs/base/common/functional';
@@ -59,12 +59,24 @@ export abstract class AbstractEditorNavigationQuickAccessProvider implements IQu
// Restore any view state if this picker was closed
// without actually going to a line
const lastKnownEditorViewState = withNullAsUndefined(editor.saveViewState());
once(token.onCancellationRequested)(() => {
if (lastKnownEditorViewState) {
editor.restoreViewState(lastKnownEditorViewState);
}
});
const codeEditor = getCodeEditor(editor);
if (codeEditor) {
// Remember view state and update it when the cursor position
// changes even later because it could be that the user has
// configured quick open to remain open when focus is lost and
// we always want to restore the current location.
let lastKnownEditorViewState = withNullAsUndefined(editor.saveViewState());
disposables.add(codeEditor.onDidChangeCursorPosition(() => {
lastKnownEditorViewState = withNullAsUndefined(editor.saveViewState());
}));
once(token.onCancellationRequested)(() => {
if (lastKnownEditorViewState) {
editor.restoreViewState(lastKnownEditorViewState);
}
});
}
// Clean up decorations on dispose
disposables.add(toDisposable(() => this.clearDecorations(editor)));
@@ -98,9 +110,9 @@ export abstract class AbstractEditorNavigationQuickAccessProvider implements IQu
*/
protected abstract provideWithoutTextEditor(picker: IQuickPick<IQuickPickItem>, token: CancellationToken): IDisposable;
protected gotoLocation(editor: IEditor, range: IRange, keyMods: IKeyMods, forceSideBySide?: boolean): void {
editor.setSelection(range);
editor.revealRangeInCenter(range, ScrollType.Smooth);
protected gotoLocation(editor: IEditor, options: { range: IRange, keyMods: IKeyMods, forceSideBySide?: boolean }): void {
editor.setSelection(options.range);
editor.revealRangeInCenter(options.range, ScrollType.Smooth);
editor.focus();
}

View File

@@ -38,7 +38,7 @@ export abstract class AbstractGotoLineQuickAccessProvider extends AbstractEditor
return;
}
this.gotoLocation(editor, this.toRange(item.lineNumber, item.column), picker.keyMods);
this.gotoLocation(editor, { range: this.toRange(item.lineNumber, item.column), keyMods: picker.keyMods });
picker.hide();
}

View File

@@ -95,7 +95,7 @@ export abstract class AbstractGotoSymbolQuickAccessProvider extends AbstractEdit
disposables.add(picker.onDidAccept(() => {
const [item] = picker.selectedItems;
if (item && item.range) {
this.gotoLocation(editor, item.range.selection, picker.keyMods);
this.gotoLocation(editor, { range: item.range.selection, keyMods: picker.keyMods });
picker.hide();
}
@@ -104,7 +104,7 @@ export abstract class AbstractGotoSymbolQuickAccessProvider extends AbstractEdit
// Goto symbol side by side if enabled
disposables.add(picker.onDidTriggerItemButton(({ item }) => {
if (item && item.range) {
this.gotoLocation(editor, item.range.selection, picker.keyMods, true);
this.gotoLocation(editor, { range: item.range.selection, keyMods: picker.keyMods, forceSideBySide: true });
picker.hide();
}

View File

@@ -195,7 +195,6 @@ class ItemRenderer implements IListRenderer<CompletionItem, ISuggestionTemplateD
const textLabel = typeof suggestion.label === 'string' ? suggestion.label : suggestion.label.name;
data.root.id = getAriaId(index);
data.icon.className = 'icon ' + completionKindToCssClass(suggestion.kind);
data.colorspan.style.backgroundColor = '';
const labelOptions: IIconLabelValueOptions = {
@@ -230,7 +229,7 @@ class ItemRenderer implements IListRenderer<CompletionItem, ISuggestionTemplateD
// normal icon
data.icon.className = 'icon hide';
data.iconContainer.className = '';
addClasses(data.iconContainer, `suggest-icon codicon codicon-symbol-${completionKindToCssClass(suggestion.kind)}`);
addClasses(data.iconContainer, `suggest-icon codicon codicon-${completionKindToCssClass(suggestion.kind)}`);
}
if (suggestion.tags && suggestion.tags.indexOf(CompletionItemTag.Deprecated) >= 0) {

View File

@@ -360,10 +360,8 @@ export abstract class ZoneWidget implements IHorizontalSashLayoutProvider {
const lineHeight = this.editor.getOption(EditorOption.lineHeight);
// adjust heightInLines to viewport
const maxHeightInLines = (this.editor.getLayoutInfo().height / lineHeight) * 0.8;
if (heightInLines >= maxHeightInLines) {
heightInLines = maxHeightInLines;
}
const maxHeightInLines = Math.max(12, (this.editor.getLayoutInfo().height / lineHeight) * 0.8);
heightInLines = Math.min(heightInLines, maxHeightInLines);
let arrowHeight = 0;
let frameThickness = 0;