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

@@ -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;