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:
Karl Burtram
2018-04-04 15:27:51 -07:00
committed by GitHub
parent 5fba3e31b4
commit dafb780987
9412 changed files with 141255 additions and 98813 deletions

View File

@@ -228,6 +228,9 @@ export class CommonFindController extends Disposable implements editorCommon.IEd
}
public setSearchString(searchString: string): void {
if (this._state.isRegex) {
searchString = strings.escapeRegExpCharacters(searchString);
}
this._state.change({ searchString: searchString }, false);
}
@@ -362,10 +365,10 @@ export class FindController extends CommonFindController implements IFindControl
constructor(
editor: ICodeEditor,
@IContextViewService private _contextViewService: IContextViewService,
@IContextKeyService private _contextKeyService: IContextKeyService,
@IKeybindingService private _keybindingService: IKeybindingService,
@IThemeService private _themeService: IThemeService,
@IContextViewService private readonly _contextViewService: IContextViewService,
@IContextKeyService private readonly _contextKeyService: IContextKeyService,
@IKeybindingService private readonly _keybindingService: IKeybindingService,
@IThemeService private readonly _themeService: IThemeService,
@IStorageService storageService: IStorageService,
@optional(IClipboardService) clipboardService: IClipboardService
) {
@@ -538,7 +541,7 @@ export abstract class SelectionMatchFindAction extends EditorAction {
if (!this._run(controller)) {
controller.start({
forceRevealReplace: false,
seedSearchStringFromSelection: false,
seedSearchStringFromSelection: editor.getConfiguration().contribInfo.find.seedSearchStringFromSelection,
seedSearchStringFromGlobalClipboard: false,
shouldFocus: FindStartFocusAction.NoFocusChange,
shouldAnimate: true

View File

@@ -5,13 +5,13 @@
'use strict';
import { IDisposable } from 'vs/base/common/lifecycle';
import * as editorCommon from 'vs/editor/common/editorCommon';
import { Position } from 'vs/editor/common/core/position';
import { Range } from 'vs/editor/common/core/range';
import { ModelDecorationOptions } from 'vs/editor/common/model/textModelWithDecorations';
import { editorFindMatchHighlight, editorFindMatch } from 'vs/platform/theme/common/colorRegistry';
import { ModelDecorationOptions } from 'vs/editor/common/model/textModel';
import { overviewRulerFindMatchForeground } from 'vs/platform/theme/common/colorRegistry';
import { themeColorFromId } from 'vs/platform/theme/common/themeService';
import { ICodeEditor } from 'vs/editor/browser/editorBrowser';
import { IModelDecorationsChangeAccessor, FindMatch, IModelDeltaDecoration, TrackedRangeStickiness, OverviewRulerLane } from 'vs/editor/common/model';
export class FindDecorations implements IDisposable {
@@ -108,7 +108,7 @@ export class FindDecorations implements IDisposable {
}
if (this._highlightedDecorationId !== null || newCurrentDecorationId !== null) {
this._editor.changeDecorations((changeAccessor: editorCommon.IModelDecorationsChangeAccessor) => {
this._editor.changeDecorations((changeAccessor: IModelDecorationsChangeAccessor) => {
if (this._highlightedDecorationId !== null) {
changeAccessor.changeDecorationOptions(this._highlightedDecorationId, FindDecorations._FIND_MATCH_DECORATION);
this._highlightedDecorationId = null;
@@ -136,11 +136,11 @@ export class FindDecorations implements IDisposable {
return matchPosition;
}
public set(findMatches: editorCommon.FindMatch[], findScope: Range): void {
public set(findMatches: FindMatch[], findScope: Range): void {
this._editor.changeDecorations((accessor) => {
let findMatchesOptions: ModelDecorationOptions = FindDecorations._FIND_MATCH_DECORATION;
let newOverviewRulerApproximateDecorations: editorCommon.IModelDeltaDecoration[] = [];
let newOverviewRulerApproximateDecorations: IModelDeltaDecoration[] = [];
if (findMatches.length > 1000) {
// we go into a mode where the overview ruler gets "approximate" decorations
@@ -179,7 +179,7 @@ export class FindDecorations implements IDisposable {
}
// Find matches
let newFindMatchesDecorations: editorCommon.IModelDeltaDecoration[] = new Array<editorCommon.IModelDeltaDecoration>(findMatches.length);
let newFindMatchesDecorations: IModelDeltaDecoration[] = new Array<IModelDeltaDecoration>(findMatches.length);
for (let i = 0, len = findMatches.length; i < len; i++) {
newFindMatchesDecorations[i] = {
range: findMatches[i].range,
@@ -222,44 +222,44 @@ export class FindDecorations implements IDisposable {
}
private static readonly _CURRENT_FIND_MATCH_DECORATION = ModelDecorationOptions.register({
stickiness: editorCommon.TrackedRangeStickiness.NeverGrowsWhenTypingAtEdges,
stickiness: TrackedRangeStickiness.NeverGrowsWhenTypingAtEdges,
className: 'currentFindMatch',
showIfCollapsed: true,
overviewRuler: {
color: themeColorFromId(editorFindMatch),
darkColor: themeColorFromId(editorFindMatch),
position: editorCommon.OverviewRulerLane.Center
color: themeColorFromId(overviewRulerFindMatchForeground),
darkColor: themeColorFromId(overviewRulerFindMatchForeground),
position: OverviewRulerLane.Center
}
});
private static readonly _FIND_MATCH_DECORATION = ModelDecorationOptions.register({
stickiness: editorCommon.TrackedRangeStickiness.NeverGrowsWhenTypingAtEdges,
stickiness: TrackedRangeStickiness.NeverGrowsWhenTypingAtEdges,
className: 'findMatch',
showIfCollapsed: true,
overviewRuler: {
color: themeColorFromId(editorFindMatchHighlight),
darkColor: themeColorFromId(editorFindMatchHighlight),
position: editorCommon.OverviewRulerLane.Center
color: themeColorFromId(overviewRulerFindMatchForeground),
darkColor: themeColorFromId(overviewRulerFindMatchForeground),
position: OverviewRulerLane.Center
}
});
private static readonly _FIND_MATCH_NO_OVERVIEW_DECORATION = ModelDecorationOptions.register({
stickiness: editorCommon.TrackedRangeStickiness.NeverGrowsWhenTypingAtEdges,
stickiness: TrackedRangeStickiness.NeverGrowsWhenTypingAtEdges,
className: 'findMatch',
showIfCollapsed: true
});
private static readonly _FIND_MATCH_ONLY_OVERVIEW_DECORATION = ModelDecorationOptions.register({
stickiness: editorCommon.TrackedRangeStickiness.NeverGrowsWhenTypingAtEdges,
stickiness: TrackedRangeStickiness.NeverGrowsWhenTypingAtEdges,
overviewRuler: {
color: themeColorFromId(editorFindMatchHighlight),
darkColor: themeColorFromId(editorFindMatchHighlight),
position: editorCommon.OverviewRulerLane.Center
color: themeColorFromId(overviewRulerFindMatchForeground),
darkColor: themeColorFromId(overviewRulerFindMatchForeground),
position: OverviewRulerLane.Center
}
});
private static readonly _RANGE_HIGHLIGHT_DECORATION = ModelDecorationOptions.register({
stickiness: editorCommon.TrackedRangeStickiness.NeverGrowsWhenTypingAtEdges,
stickiness: TrackedRangeStickiness.NeverGrowsWhenTypingAtEdges,
className: 'rangeHighlight',
isWholeLine: true
});

View File

@@ -22,6 +22,7 @@ import { IKeybindings } from 'vs/platform/keybinding/common/keybindingsRegistry'
import { CursorChangeReason, ICursorPositionChangedEvent } from 'vs/editor/common/controller/cursorEvents';
import { RawContextKey, ContextKeyExpr } from 'vs/platform/contextkey/common/contextkey';
import { ICodeEditor } from 'vs/editor/browser/editorBrowser';
import { ITextModel, FindMatch, EndOfLinePreference } from 'vs/editor/common/model';
export const CONTEXT_FIND_WIDGET_VISIBLE = new RawContextKey<boolean>('findWidgetVisible', false);
export const CONTEXT_FIND_WIDGET_NOT_VISIBLE: ContextKeyExpr = CONTEXT_FIND_WIDGET_VISIBLE.toNegated();
@@ -147,14 +148,8 @@ export class FindModelBoundToEditorModel {
}
}
private static _getSearchRange(model: editorCommon.IModel, searchOnlyEditableRange: boolean, findScope: Range): Range {
let searchRange: Range;
if (searchOnlyEditableRange) {
searchRange = model.getEditableRange();
} else {
searchRange = model.getFullModelRange();
}
private static _getSearchRange(model: ITextModel, findScope: Range): Range {
let searchRange = model.getFullModelRange();
// If we have set now or before a find scope, use it for computing the search range
if (findScope) {
@@ -226,7 +221,7 @@ export class FindModelBoundToEditorModel {
}
let findScope = this._decorations.getFindScope();
let searchRange = FindModelBoundToEditorModel._getSearchRange(this._editor.getModel(), this._state.isReplaceRevealed, findScope);
let searchRange = FindModelBoundToEditorModel._getSearchRange(this._editor.getModel(), findScope);
// ...(----)...|...
if (searchRange.getEndPosition().isBefore(before)) {
@@ -291,13 +286,13 @@ export class FindModelBoundToEditorModel {
}
}
private _getNextMatch(after: Position, captureMatches: boolean, forceMove: boolean, isRecursed: boolean = false): editorCommon.FindMatch {
private _getNextMatch(after: Position, captureMatches: boolean, forceMove: boolean, isRecursed: boolean = false): FindMatch {
if (this._cannotFind()) {
return null;
}
let findScope = this._decorations.getFindScope();
let searchRange = FindModelBoundToEditorModel._getSearchRange(this._editor.getModel(), this._state.isReplaceRevealed, findScope);
let searchRange = FindModelBoundToEditorModel._getSearchRange(this._editor.getModel(), findScope);
// ...(----)...|...
if (searchRange.getEndPosition().isBefore(after)) {
@@ -388,8 +383,8 @@ export class FindModelBoundToEditorModel {
}
}
private _findMatches(findScope: Range, captureMatches: boolean, limitResultCount: number): editorCommon.FindMatch[] {
let searchRange = FindModelBoundToEditorModel._getSearchRange(this._editor.getModel(), this._state.isReplaceRevealed, findScope);
private _findMatches(findScope: Range, captureMatches: boolean, limitResultCount: number): FindMatch[] {
let searchRange = FindModelBoundToEditorModel._getSearchRange(this._editor.getModel(), findScope);
return this._editor.getModel().findMatches(this._state.searchString, searchRange, this._state.isRegex, this._state.matchCase, this._state.wholeWord ? this._editor.getConfiguration().wordSeparators : null, captureMatches, limitResultCount);
}
@@ -401,7 +396,7 @@ export class FindModelBoundToEditorModel {
const findScope = this._decorations.getFindScope();
if (findScope === null && this._state.matchesCount >= MATCHES_LIMIT) {
// Doing a replace on the entire file that is over 1k matches
// Doing a replace on the entire file that is over ${MATCHES_LIMIT} matches
this._largeReplaceAll();
} else {
this._regularReplaceAll(findScope);
@@ -430,7 +425,7 @@ export class FindModelBoundToEditorModel {
}
const model = this._editor.getModel();
const modelText = model.getValue(editorCommon.EndOfLinePreference.LF);
const modelText = model.getValue(EndOfLinePreference.LF);
const fullModelRange = model.getFullModelRange();
const replacePattern = this._getReplacePattern();

View File

@@ -28,7 +28,7 @@ import { IContextKeyService, IContextKey } from 'vs/platform/contextkey/common/c
import { ITheme, registerThemingParticipant, IThemeService } from 'vs/platform/theme/common/themeService';
import { Color } from 'vs/base/common/color';
import { IConfigurationChangedEvent } from 'vs/editor/common/config/editorOptions';
import { editorFindRangeHighlight, editorFindMatch, editorFindMatchHighlight, activeContrastBorder, contrastBorder, inputBackground, editorWidgetBackground, inputActiveOptionBorder, widgetShadow, inputForeground, inputBorder, inputValidationInfoBackground, inputValidationInfoBorder, inputValidationWarningBackground, inputValidationWarningBorder, inputValidationErrorBackground, inputValidationErrorBorder, errorForeground, editorWidgetBorder } from 'vs/platform/theme/common/colorRegistry';
import { editorFindRangeHighlight, editorFindMatch, editorFindMatchHighlight, contrastBorder, inputBackground, editorWidgetBackground, inputActiveOptionBorder, widgetShadow, inputForeground, inputBorder, inputValidationInfoBackground, inputValidationInfoBorder, inputValidationWarningBackground, inputValidationWarningBorder, inputValidationErrorBackground, inputValidationErrorBorder, errorForeground, editorWidgetBorder, editorFindMatchBorder, editorFindMatchHighlightBorder, editorFindRangeHighlightBorder } from 'vs/platform/theme/common/colorRegistry';
export interface IFindController {
@@ -1076,12 +1076,19 @@ registerThemingParticipant((theme, collector) => {
collector.addRule(`.monaco-editor .find-widget { box-shadow: 0 2px 8px ${widgetShadowColor}; }`);
}
let hcOutline = theme.getColor(activeContrastBorder);
if (hcOutline) {
collector.addRule(`.monaco-editor .findScope { border: 1px dashed ${hcOutline.transparent(0.4)}; }`);
collector.addRule(`.monaco-editor .currentFindMatch { border: 2px solid ${hcOutline}; padding: 1px; -moz-box-sizing: border-box; box-sizing: border-box; }`);
collector.addRule(`.monaco-editor .findMatch { border: 1px dotted ${hcOutline}; -moz-box-sizing: border-box; box-sizing: border-box; }`);
let findMatchHighlightBorder = theme.getColor(editorFindMatchHighlightBorder);
if (findMatchHighlightBorder) {
collector.addRule(`.monaco-editor .findMatch { border: 1px dotted ${findMatchHighlightBorder}; -moz-box-sizing: border-box; box-sizing: border-box; }`);
}
let findMatchBorder = theme.getColor(editorFindMatchBorder);
if (findMatchBorder) {
collector.addRule(`.monaco-editor .currentFindMatch { border: 2px solid ${findMatchBorder}; padding: 1px; -moz-box-sizing: border-box; box-sizing: border-box; }`);
}
let findRangeHighlightBorder = theme.getColor(editorFindRangeHighlightBorder);
if (findRangeHighlightBorder) {
collector.addRule(`.monaco-editor .findScope { border: 1px dashed ${findRangeHighlightBorder}; }`);
}
let hcBorder = theme.getColor(contrastBorder);
if (hcBorder) {
collector.addRule(`.monaco-editor .find-widget { border: 2px solid ${hcBorder}; }`);

View File

@@ -7,6 +7,7 @@
import { Range } from 'vs/editor/common/core/range';
import { Selection } from 'vs/editor/common/core/selection';
import * as editorCommon from 'vs/editor/common/editorCommon';
import { ITextModel } from 'vs/editor/common/model';
interface IEditOperation {
range: Range;
@@ -26,7 +27,7 @@ export class ReplaceAllCommand implements editorCommon.ICommand {
this._replaceStrings = replaceStrings;
}
public getEditOperations(model: editorCommon.ITokenizedModel, builder: editorCommon.IEditOperationBuilder): void {
public getEditOperations(model: ITextModel, builder: editorCommon.IEditOperationBuilder): void {
if (this._ranges.length > 0) {
// Collect all edit operations
var ops: IEditOperation[] = [];
@@ -65,7 +66,7 @@ export class ReplaceAllCommand implements editorCommon.ICommand {
this._trackedEditorSelectionId = builder.trackSelection(this._editorSelection);
}
public computeCursorState(model: editorCommon.ITokenizedModel, helper: editorCommon.ICursorStateComputerData): Selection {
public computeCursorState(model: ITextModel, helper: editorCommon.ICursorStateComputerData): Selection {
return helper.getTrackedSelection(this._trackedEditorSelectionId);
}
}

View File

@@ -33,7 +33,7 @@ export abstract class SimpleFindWidget extends Widget {
protected _updateHistoryDelayer: Delayer<void>;
constructor(
@IContextViewService private _contextViewService: IContextViewService,
@IContextViewService private readonly _contextViewService: IContextViewService,
private animate: boolean = true
) {
super();

View File

@@ -12,7 +12,7 @@ import { Position } from 'vs/editor/common/core/position';
import { Selection } from 'vs/editor/common/core/selection';
import { Range } from 'vs/editor/common/core/range';
import * as platform from 'vs/base/common/platform';
import { CommonFindController, FindStartFocusAction, IFindStartOptions, NextMatchFindAction, StartFindAction } from 'vs/editor/contrib/find/findController';
import { CommonFindController, FindStartFocusAction, IFindStartOptions, NextMatchFindAction, StartFindAction, NextSelectionMatchFindAction } from 'vs/editor/contrib/find/findController';
import { withTestCodeEditor } from 'vs/editor/test/browser/testCodeEditor';
import { HistoryNavigator } from 'vs/base/common/history';
import { IContextKeyService } from 'vs/platform/contextkey/common/contextkey';
@@ -92,7 +92,7 @@ suite('FindController', () => {
});
}
test('stores to the global clipboard buffer on start find action', () => {
/* test('stores to the global clipboard buffer on start find action', () => {
withTestCodeEditor([
'ABC',
'ABC',
@@ -165,7 +165,7 @@ suite('FindController', () => {
findController.dispose();
});
});
}); */
test('issue #1857: F3, Find Next, acts like "Find Under Cursor"', () => {
withTestCodeEditor([
@@ -475,6 +475,64 @@ suite('FindController', () => {
}
return result;
}
test('issue #38232: Find Next Selection, regex enabled', () => {
withTestCodeEditor([
'([funny]',
'',
'([funny]'
], { serviceCollection: serviceCollection }, (editor, cursor) => {
clipboardState = '';
let findController = editor.registerAndInstantiateContribution<TestFindController>(TestFindController);
let nextSelectionMatchFindAction = new NextSelectionMatchFindAction();
// toggle regex
findController.getState().change({ isRegex: true }, false);
// change selection
editor.setSelection(new Selection(1, 1, 1, 9));
// cmd+f3
nextSelectionMatchFindAction.run(null, editor);
assert.deepEqual(editor.getSelections().map(fromRange), [
[3, 1, 3, 9]
]);
findController.dispose();
});
});
test('issue #38232: Find Next Selection, regex enabled, find widget open', () => {
withTestCodeEditor([
'([funny]',
'',
'([funny]'
], { serviceCollection: serviceCollection }, (editor, cursor) => {
clipboardState = '';
let findController = editor.registerAndInstantiateContribution<TestFindController>(TestFindController);
let startFindAction = new StartFindAction();
let nextSelectionMatchFindAction = new NextSelectionMatchFindAction();
// cmd+f - open find widget
startFindAction.run(null, editor);
// toggle regex
findController.getState().change({ isRegex: true }, false);
// change selection
editor.setSelection(new Selection(1, 1, 1, 9));
// cmd+f3
nextSelectionMatchFindAction.run(null, editor);
assert.deepEqual(editor.getSelections().map(fromRange), [
[3, 1, 3, 9]
]);
findController.dispose();
});
});
});
suite('FindController query options persistence', () => {

View File

@@ -1475,46 +1475,6 @@ suite('FindModel', () => {
findState.dispose();
});
findTest('finds only in editable range if replace is shown', (editor, cursor) => {
editor.getModel().setEditableRange({
startLineNumber: 6,
startColumn: 1,
endLineNumber: 8,
endColumn: 1
});
let findState = new FindReplaceState();
findState.change({ searchString: 'hello', replaceString: 'hi', wholeWord: true }, false);
let findModel = new FindModelBoundToEditorModel(editor, findState);
assertFindState(
editor,
[1, 1, 1, 1],
null,
[
[6, 14, 6, 19],
[6, 27, 6, 32],
[7, 14, 7, 19],
[8, 14, 8, 19]
]
);
findState.change({ isReplaceRevealed: true }, false);
assertFindState(
editor,
[1, 1, 1, 1],
null,
[
[6, 14, 6, 19],
[6, 27, 6, 32],
[7, 14, 7, 19]
]
);
findModel.dispose();
findState.dispose();
});
findTest('listens to model content changes', (editor, cursor) => {
let findState = new FindReplaceState();
findState.change({ searchString: 'hello', replaceString: 'hi', wholeWord: true }, false);