mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-03-20 12:00:24 -04:00
Merge VS Code 1.21 source code (#1067)
* Initial VS Code 1.21 file copy with patches * A few more merges * Post npm install * Fix batch of build breaks * Fix more build breaks * Fix more build errors * Fix more build breaks * Runtime fixes 1 * Get connection dialog working with some todos * Fix a few packaging issues * Copy several node_modules to package build to fix loader issues * Fix breaks from master * A few more fixes * Make tests pass * First pass of license header updates * Second pass of license header updates * Fix restore dialog issues * Remove add additional themes menu items * fix select box issues where the list doesn't show up * formatting * Fix editor dispose issue * Copy over node modules to correct location on all platforms
This commit is contained in:
@@ -25,7 +25,7 @@ import { SnippetController2 } from 'vs/editor/contrib/snippet/snippetController2
|
||||
import { Context as SuggestContext } from './suggest';
|
||||
import { SuggestModel, State } from './suggestModel';
|
||||
import { ICompletionItem } from './completionModel';
|
||||
import { SuggestWidget } from './suggestWidget';
|
||||
import { SuggestWidget, ISelectedSuggestion } from './suggestWidget';
|
||||
import { KeybindingsRegistry } from 'vs/platform/keybinding/common/keybindingsRegistry';
|
||||
import { SuggestMemories } from 'vs/editor/contrib/suggest/suggestMemory';
|
||||
|
||||
@@ -34,9 +34,9 @@ class AcceptOnCharacterOracle {
|
||||
private _disposables: IDisposable[] = [];
|
||||
|
||||
private _activeAcceptCharacters = new Set<string>();
|
||||
private _activeItem: ICompletionItem;
|
||||
private _activeItem: ISelectedSuggestion;
|
||||
|
||||
constructor(editor: ICodeEditor, widget: SuggestWidget, accept: (item: ICompletionItem) => any) {
|
||||
constructor(editor: ICodeEditor, widget: SuggestWidget, accept: (selected: ISelectedSuggestion) => any) {
|
||||
|
||||
this._disposables.push(widget.onDidShow(() => this._onItem(widget.getFocusedItem())));
|
||||
this._disposables.push(widget.onDidFocus(this._onItem, this));
|
||||
@@ -52,14 +52,14 @@ class AcceptOnCharacterOracle {
|
||||
}));
|
||||
}
|
||||
|
||||
private _onItem(item: ICompletionItem): void {
|
||||
if (!item || isFalsyOrEmpty(item.suggestion.commitCharacters)) {
|
||||
private _onItem(selected: ISelectedSuggestion): void {
|
||||
if (!selected || isFalsyOrEmpty(selected.item.suggestion.commitCharacters)) {
|
||||
this.reset();
|
||||
return;
|
||||
}
|
||||
this._activeItem = item;
|
||||
this._activeItem = selected;
|
||||
this._activeAcceptCharacters.clear();
|
||||
for (const ch of item.suggestion.commitCharacters) {
|
||||
for (const ch of selected.item.suggestion.commitCharacters) {
|
||||
if (ch.length > 0) {
|
||||
this._activeAcceptCharacters.add(ch[0]);
|
||||
}
|
||||
@@ -77,7 +77,7 @@ class AcceptOnCharacterOracle {
|
||||
|
||||
export class SuggestController implements IEditorContribution {
|
||||
|
||||
private static ID: string = 'editor.contrib.suggestController';
|
||||
private static readonly ID: string = 'editor.contrib.suggestController';
|
||||
|
||||
public static get(editor: ICodeEditor): SuggestController {
|
||||
return editor.getContribution<SuggestController>(SuggestController.ID);
|
||||
@@ -90,12 +90,12 @@ export class SuggestController implements IEditorContribution {
|
||||
|
||||
constructor(
|
||||
private _editor: ICodeEditor,
|
||||
@ICommandService private _commandService: ICommandService,
|
||||
@IContextKeyService private _contextKeyService: IContextKeyService,
|
||||
@IInstantiationService private _instantiationService: IInstantiationService,
|
||||
@ICommandService private readonly _commandService: ICommandService,
|
||||
@IContextKeyService private readonly _contextKeyService: IContextKeyService,
|
||||
@IInstantiationService private readonly _instantiationService: IInstantiationService,
|
||||
) {
|
||||
this._model = new SuggestModel(this._editor);
|
||||
this._memory = _instantiationService.createInstance(SuggestMemories);
|
||||
this._memory = _instantiationService.createInstance(SuggestMemories, this._editor.getConfiguration().contribInfo.suggestSelection);
|
||||
|
||||
this._toDispose.push(this._model.onDidTrigger(e => {
|
||||
if (!this._widget) {
|
||||
@@ -103,29 +103,22 @@ export class SuggestController implements IEditorContribution {
|
||||
}
|
||||
this._widget.showTriggered(e.auto);
|
||||
}));
|
||||
let lastSelectedItem: ICompletionItem;
|
||||
this._toDispose.push(this._model.onDidSuggest(e => {
|
||||
let index = this._memory.select(this._editor.getModel().getLanguageIdentifier(), e.completionModel.items, lastSelectedItem);
|
||||
if (index >= 0) {
|
||||
lastSelectedItem = e.completionModel.items[index];
|
||||
} else {
|
||||
index = 0;
|
||||
lastSelectedItem = undefined;
|
||||
}
|
||||
let index = this._memory.select(this._editor.getModel(), this._editor.getPosition(), e.completionModel.items);
|
||||
this._widget.showSuggestions(e.completionModel, index, e.isFrozen, e.auto);
|
||||
}));
|
||||
this._toDispose.push(this._model.onDidCancel(e => {
|
||||
if (this._widget && !e.retrigger) {
|
||||
this._widget.hideWidget();
|
||||
lastSelectedItem = undefined;
|
||||
}
|
||||
}));
|
||||
|
||||
// Manage the acceptSuggestionsOnEnter context key
|
||||
let acceptSuggestionsOnEnter = SuggestContext.AcceptSuggestionsOnEnter.bindTo(_contextKeyService);
|
||||
let updateFromConfig = () => {
|
||||
const { acceptSuggestionOnEnter } = this._editor.getConfiguration().contribInfo;
|
||||
const { acceptSuggestionOnEnter, suggestSelection } = this._editor.getConfiguration().contribInfo;
|
||||
acceptSuggestionsOnEnter.set(acceptSuggestionOnEnter === 'on' || acceptSuggestionOnEnter === 'smart');
|
||||
this._memory.setMode(suggestSelection);
|
||||
};
|
||||
this._toDispose.push(this._editor.onDidChangeConfiguration((e) => updateFromConfig()));
|
||||
updateFromConfig();
|
||||
@@ -148,7 +141,7 @@ export class SuggestController implements IEditorContribution {
|
||||
);
|
||||
|
||||
let makesTextEdit = SuggestContext.MakesTextEdit.bindTo(this._contextKeyService);
|
||||
this._toDispose.push(this._widget.onDidFocus(item => {
|
||||
this._toDispose.push(this._widget.onDidFocus(({ item }) => {
|
||||
|
||||
const position = this._editor.getPosition();
|
||||
const startColumn = item.position.column - item.suggestion.overwriteBefore;
|
||||
@@ -193,13 +186,13 @@ export class SuggestController implements IEditorContribution {
|
||||
}
|
||||
}
|
||||
|
||||
private _onDidSelectItem(item: ICompletionItem): void {
|
||||
if (!item) {
|
||||
protected _onDidSelectItem(event: ISelectedSuggestion): void {
|
||||
if (!event || !event.item) {
|
||||
this._model.cancel();
|
||||
return;
|
||||
}
|
||||
|
||||
const { suggestion, position } = item;
|
||||
const { suggestion, position } = event.item;
|
||||
const editorColumn = this._editor.getPosition().column;
|
||||
const columnDelta = editorColumn - position.column;
|
||||
|
||||
@@ -209,8 +202,8 @@ export class SuggestController implements IEditorContribution {
|
||||
this._editor.pushUndoStop();
|
||||
}
|
||||
|
||||
// remember this word for future invocations
|
||||
this._memory.remember(this._editor.getModel().getLanguageIdentifier(), item);
|
||||
// keep item in memory
|
||||
this._memory.memorize(this._editor.getModel(), this._editor.getPosition(), event.item);
|
||||
|
||||
let { insertText } = suggestion;
|
||||
if (suggestion.snippetType !== 'textmate') {
|
||||
@@ -237,7 +230,7 @@ export class SuggestController implements IEditorContribution {
|
||||
this._model.cancel();
|
||||
}
|
||||
|
||||
this._alertCompletionItem(item);
|
||||
this._alertCompletionItem(event.item);
|
||||
}
|
||||
|
||||
private _alertCompletionItem({ suggestion }: ICompletionItem): void {
|
||||
|
||||
Reference in New Issue
Block a user