mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-03-21 20:30: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:
@@ -14,14 +14,18 @@ import { Position } from 'vs/editor/common/core/position';
|
||||
import { Selection } from 'vs/editor/common/core/selection';
|
||||
import { RunOnceScheduler } from 'vs/base/common/async';
|
||||
import * as editorCommon from 'vs/editor/common/editorCommon';
|
||||
import { registerEditorAction, registerEditorContribution, ServicesAccessor, EditorAction } from 'vs/editor/browser/editorExtensions';
|
||||
import { EditorAction, registerEditorAction, registerEditorContribution, ServicesAccessor } from 'vs/editor/browser/editorExtensions';
|
||||
import { EditorContextKeys } from 'vs/editor/common/editorContextKeys';
|
||||
import { registerThemingParticipant } from 'vs/platform/theme/common/themeService';
|
||||
import { registerThemingParticipant, themeColorFromId } from 'vs/platform/theme/common/themeService';
|
||||
import { editorBracketMatchBackground, editorBracketMatchBorder } from 'vs/editor/common/view/editorColorRegistry';
|
||||
import { ModelDecorationOptions } from 'vs/editor/common/model/textModelWithDecorations';
|
||||
import { ModelDecorationOptions } from 'vs/editor/common/model/textModel';
|
||||
import { ICodeEditor } from 'vs/editor/browser/editorBrowser';
|
||||
import { registerColor } from 'vs/platform/theme/common/colorRegistry';
|
||||
import { TrackedRangeStickiness, IModelDeltaDecoration, OverviewRulerLane } from 'vs/editor/common/model';
|
||||
|
||||
class SelectBracketAction extends EditorAction {
|
||||
const overviewRulerBracketMatchForeground = registerColor('editorOverviewRuler.bracketMatchForeground', { dark: '#A0A0A0', light: '#A0A0A0', hc: '#A0A0A0' }, nls.localize('overviewRulerBracketMatchForeground', 'Overview ruler marker color for matching brackets.'));
|
||||
|
||||
class JumpToBracketAction extends EditorAction {
|
||||
constructor() {
|
||||
super({
|
||||
id: 'editor.action.jumpToBracket',
|
||||
@@ -44,6 +48,25 @@ class SelectBracketAction extends EditorAction {
|
||||
}
|
||||
}
|
||||
|
||||
class SelectToBracketAction extends EditorAction {
|
||||
constructor() {
|
||||
super({
|
||||
id: 'editor.action.selectToBracket',
|
||||
label: nls.localize('smartSelect.selectToBracket', "Select to Bracket"),
|
||||
alias: 'Select to Bracket',
|
||||
precondition: null
|
||||
});
|
||||
}
|
||||
|
||||
public run(accessor: ServicesAccessor, editor: ICodeEditor): void {
|
||||
let controller = BracketMatchingController.get(editor);
|
||||
if (!controller) {
|
||||
return;
|
||||
}
|
||||
controller.selectToBracket();
|
||||
}
|
||||
}
|
||||
|
||||
type Brackets = [Range, Range];
|
||||
|
||||
class BracketsData {
|
||||
@@ -148,9 +171,58 @@ export class BracketMatchingController extends Disposable implements editorCommo
|
||||
this._editor.revealRange(newSelections[0]);
|
||||
}
|
||||
|
||||
public selectToBracket(): void {
|
||||
const model = this._editor.getModel();
|
||||
if (!model) {
|
||||
return;
|
||||
}
|
||||
const selection = this._editor.getSelection();
|
||||
if (!selection.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
const position = selection.getStartPosition();
|
||||
|
||||
let brackets = model.matchBracket(position);
|
||||
|
||||
let openBracket: Position = null;
|
||||
let closeBracket: Position = null;
|
||||
|
||||
if (!brackets) {
|
||||
const nextBracket = model.findNextBracket(position);
|
||||
if (nextBracket && nextBracket.range) {
|
||||
brackets = model.matchBracket(nextBracket.range.getStartPosition());
|
||||
}
|
||||
}
|
||||
|
||||
if (brackets) {
|
||||
if (brackets[0].startLineNumber === brackets[1].startLineNumber) {
|
||||
openBracket = brackets[1].startColumn < brackets[0].startColumn ?
|
||||
brackets[1].getStartPosition() : brackets[0].getStartPosition();
|
||||
closeBracket = brackets[1].startColumn < brackets[0].startColumn ?
|
||||
brackets[0].getEndPosition() : brackets[1].getEndPosition();
|
||||
} else {
|
||||
openBracket = brackets[1].startLineNumber < brackets[0].startLineNumber ?
|
||||
brackets[1].getStartPosition() : brackets[0].getStartPosition();
|
||||
closeBracket = brackets[1].startLineNumber < brackets[0].startLineNumber ?
|
||||
brackets[0].getEndPosition() : brackets[1].getEndPosition();
|
||||
}
|
||||
}
|
||||
|
||||
if (openBracket && closeBracket) {
|
||||
this._editor.setSelection(new Range(openBracket.lineNumber, openBracket.column, closeBracket.lineNumber, closeBracket.column));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private static readonly _DECORATION_OPTIONS = ModelDecorationOptions.register({
|
||||
stickiness: editorCommon.TrackedRangeStickiness.NeverGrowsWhenTypingAtEdges,
|
||||
className: 'bracket-match'
|
||||
stickiness: TrackedRangeStickiness.NeverGrowsWhenTypingAtEdges,
|
||||
className: 'bracket-match',
|
||||
overviewRuler: {
|
||||
color: themeColorFromId(overviewRulerBracketMatchForeground),
|
||||
darkColor: themeColorFromId(overviewRulerBracketMatchForeground),
|
||||
position: OverviewRulerLane.Center
|
||||
}
|
||||
});
|
||||
|
||||
private _updateBrackets(): void {
|
||||
@@ -159,7 +231,7 @@ export class BracketMatchingController extends Disposable implements editorCommo
|
||||
}
|
||||
this._recomputeBrackets();
|
||||
|
||||
let newDecorations: editorCommon.IModelDeltaDecoration[] = [], newDecorationsLen = 0;
|
||||
let newDecorations: IModelDeltaDecoration[] = [], newDecorationsLen = 0;
|
||||
for (let i = 0, len = this._lastBracketsData.length; i < len; i++) {
|
||||
let brackets = this._lastBracketsData[i].brackets;
|
||||
if (brackets) {
|
||||
@@ -227,7 +299,8 @@ export class BracketMatchingController extends Disposable implements editorCommo
|
||||
}
|
||||
|
||||
registerEditorContribution(BracketMatchingController);
|
||||
registerEditorAction(SelectBracketAction);
|
||||
registerEditorAction(SelectToBracketAction);
|
||||
registerEditorAction(JumpToBracketAction);
|
||||
registerThemingParticipant((theme, collector) => {
|
||||
let bracketMatchBackground = theme.getColor(editorBracketMatchBackground);
|
||||
if (bracketMatchBackground) {
|
||||
|
||||
Reference in New Issue
Block a user