mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-03-26 23:00:29 -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:
@@ -10,8 +10,8 @@ import { TimeoutTimer } from 'vs/base/common/async';
|
||||
import Event, { Emitter } from 'vs/base/common/event';
|
||||
import { IDisposable, dispose } from 'vs/base/common/lifecycle';
|
||||
import { TPromise } from 'vs/base/common/winjs.base';
|
||||
import { IModel, IWordAtPosition } from 'vs/editor/common/editorCommon';
|
||||
import { ISuggestSupport, SuggestRegistry, StandardTokenType, SuggestTriggerKind } from 'vs/editor/common/modes';
|
||||
import { ITextModel, IWordAtPosition } from 'vs/editor/common/model';
|
||||
import { ISuggestSupport, SuggestRegistry, StandardTokenType, SuggestTriggerKind, SuggestContext } from 'vs/editor/common/modes';
|
||||
import { Position } from 'vs/editor/common/core/position';
|
||||
import { provideSuggestionItems, getSuggestionComparator, ISuggestionItem } from './suggest';
|
||||
import { CompletionModel } from './completionModel';
|
||||
@@ -19,22 +19,22 @@ import { CursorChangeReason, ICursorSelectionChangedEvent } from 'vs/editor/comm
|
||||
import { ICodeEditor } from 'vs/editor/browser/editorBrowser';
|
||||
|
||||
export interface ICancelEvent {
|
||||
retrigger: boolean;
|
||||
readonly retrigger: boolean;
|
||||
}
|
||||
|
||||
export interface ITriggerEvent {
|
||||
auto: boolean;
|
||||
readonly auto: boolean;
|
||||
}
|
||||
|
||||
export interface ISuggestEvent {
|
||||
completionModel: CompletionModel;
|
||||
isFrozen: boolean;
|
||||
auto: boolean;
|
||||
readonly completionModel: CompletionModel;
|
||||
readonly isFrozen: boolean;
|
||||
readonly auto: boolean;
|
||||
}
|
||||
|
||||
export interface SuggestTriggerContext {
|
||||
auto: boolean;
|
||||
triggerCharacter?: string;
|
||||
readonly auto: boolean;
|
||||
readonly triggerCharacter?: string;
|
||||
}
|
||||
|
||||
export class LineContext {
|
||||
@@ -59,25 +59,13 @@ export class LineContext {
|
||||
return true;
|
||||
}
|
||||
|
||||
static isInEditableRange(editor: ICodeEditor): boolean {
|
||||
const model = editor.getModel();
|
||||
const position = editor.getPosition();
|
||||
if (model.hasEditableRange()) {
|
||||
const editableRange = model.getEditableRange();
|
||||
if (!editableRange.containsPosition(position)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
readonly lineNumber: number;
|
||||
readonly column: number;
|
||||
readonly leadingLineContent: string;
|
||||
readonly leadingWord: IWordAtPosition;
|
||||
readonly auto: boolean;
|
||||
|
||||
constructor(model: IModel, position: Position, auto: boolean) {
|
||||
constructor(model: ITextModel, position: Position, auto: boolean) {
|
||||
this.leadingLineContent = model.getLineContent(position.lineNumber).substr(0, position.column - 1);
|
||||
this.leadingWord = model.getWordUntilPosition(position);
|
||||
this.lineNumber = position.lineNumber;
|
||||
@@ -289,9 +277,9 @@ export class SuggestModel implements IDisposable {
|
||||
|
||||
this.cancel();
|
||||
|
||||
if (LineContext.shouldAutoTrigger(this._editor)) {
|
||||
this._triggerAutoSuggestPromise = TPromise.timeout(this._quickSuggestDelay);
|
||||
this._triggerAutoSuggestPromise.then(() => {
|
||||
this._triggerAutoSuggestPromise = TPromise.timeout(this._quickSuggestDelay);
|
||||
this._triggerAutoSuggestPromise.then(() => {
|
||||
if (LineContext.shouldAutoTrigger(this._editor)) {
|
||||
const model = this._editor.getModel();
|
||||
const pos = this._editor.getPosition();
|
||||
|
||||
@@ -307,9 +295,8 @@ export class SuggestModel implements IDisposable {
|
||||
} else {
|
||||
// Check the type of the token that triggered this
|
||||
model.tokenizeIfCheap(pos.lineNumber);
|
||||
const { tokenType } = model
|
||||
.getLineTokens(pos.lineNumber)
|
||||
.findTokenAtOffset(Math.max(pos.column - 1 - 1, 0));
|
||||
const lineTokens = model.getLineTokens(pos.lineNumber);
|
||||
const tokenType = lineTokens.getStandardTokenType(lineTokens.findTokenIndexAtOffset(Math.max(pos.column - 1 - 1, 0)));
|
||||
const inValidScope = quickSuggestions.other && tokenType === StandardTokenType.Other
|
||||
|| quickSuggestions.comments && tokenType === StandardTokenType.Comment
|
||||
|| quickSuggestions.strings && tokenType === StandardTokenType.String;
|
||||
@@ -319,10 +306,10 @@ export class SuggestModel implements IDisposable {
|
||||
}
|
||||
}
|
||||
|
||||
this._triggerAutoSuggestPromise = null;
|
||||
this.trigger({ auto: true });
|
||||
});
|
||||
}
|
||||
}
|
||||
this._triggerAutoSuggestPromise = null;
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -352,10 +339,6 @@ export class SuggestModel implements IDisposable {
|
||||
const auto = context.auto;
|
||||
const ctx = new LineContext(model, this._editor.getPosition(), auto);
|
||||
|
||||
if (!LineContext.isInEditableRange(this._editor)) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Cancel previous requests, change state & update UI
|
||||
this.cancel(retrigger);
|
||||
this._state = auto ? State.Auto : State.Manual;
|
||||
@@ -364,13 +347,23 @@ export class SuggestModel implements IDisposable {
|
||||
// Capture context when request was sent
|
||||
this._context = ctx;
|
||||
|
||||
// Build context for request
|
||||
let suggestCtx: SuggestContext;
|
||||
if (context.triggerCharacter) {
|
||||
suggestCtx = {
|
||||
triggerKind: SuggestTriggerKind.TriggerCharacter,
|
||||
triggerCharacter: context.triggerCharacter
|
||||
};
|
||||
} else if (onlyFrom && onlyFrom.length) {
|
||||
suggestCtx = { triggerKind: SuggestTriggerKind.TriggerForIncompleteCompletions };
|
||||
} else {
|
||||
suggestCtx = { triggerKind: SuggestTriggerKind.Invoke };
|
||||
}
|
||||
|
||||
this._requestPromise = provideSuggestionItems(model, this._editor.getPosition(),
|
||||
this._editor.getConfiguration().contribInfo.snippetSuggestions,
|
||||
onlyFrom,
|
||||
{
|
||||
triggerCharacter: context.triggerCharacter,
|
||||
triggerKind: context.triggerCharacter ? SuggestTriggerKind.TriggerCharacter : SuggestTriggerKind.Invoke
|
||||
}
|
||||
suggestCtx
|
||||
).then(items => {
|
||||
|
||||
this._requestPromise = null;
|
||||
|
||||
Reference in New Issue
Block a user