mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-11 10:38:31 -05:00
Merge from vscode c58aaab8a1cc22a7139b761166a0d4f37d41e998 (#7880)
* Merge from vscode c58aaab8a1cc22a7139b761166a0d4f37d41e998 * fix pipelines * fix strict-null-checks * add missing files
This commit is contained in:
@@ -7,7 +7,7 @@ import { CharCode } from 'vs/base/common/charCode';
|
||||
import * as strings from 'vs/base/common/strings';
|
||||
import { WrappingIndent } from 'vs/editor/common/config/editorOptions';
|
||||
import { CharacterClassifier } from 'vs/editor/common/core/characterClassifier';
|
||||
import { toUint32Array } from 'vs/editor/common/core/uint';
|
||||
import { toUint32Array } from 'vs/base/common/uint';
|
||||
import { PrefixSumComputer } from 'vs/editor/common/viewModel/prefixSumComputer';
|
||||
import { ILineMapperFactory, ILineMapping, OutputPosition } from 'vs/editor/common/viewModel/splitLinesCollection';
|
||||
|
||||
|
||||
63
src/vs/editor/common/viewModel/minimapTokensColorTracker.ts
Normal file
63
src/vs/editor/common/viewModel/minimapTokensColorTracker.ts
Normal file
@@ -0,0 +1,63 @@
|
||||
/*---------------------------------------------------------------------------------------------
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import { Emitter, Event } from 'vs/base/common/event';
|
||||
import { RGBA8 } from 'vs/editor/common/core/rgba';
|
||||
import { ColorId, TokenizationRegistry } from 'vs/editor/common/modes';
|
||||
|
||||
export class MinimapTokensColorTracker {
|
||||
private static _INSTANCE: MinimapTokensColorTracker | null = null;
|
||||
public static getInstance(): MinimapTokensColorTracker {
|
||||
if (!this._INSTANCE) {
|
||||
this._INSTANCE = new MinimapTokensColorTracker();
|
||||
}
|
||||
return this._INSTANCE;
|
||||
}
|
||||
|
||||
private _colors!: RGBA8[];
|
||||
private _backgroundIsLight!: boolean;
|
||||
|
||||
private readonly _onDidChange = new Emitter<void>();
|
||||
public readonly onDidChange: Event<void> = this._onDidChange.event;
|
||||
|
||||
private constructor() {
|
||||
this._updateColorMap();
|
||||
TokenizationRegistry.onDidChange(e => {
|
||||
if (e.changedColorMap) {
|
||||
this._updateColorMap();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private _updateColorMap(): void {
|
||||
const colorMap = TokenizationRegistry.getColorMap();
|
||||
if (!colorMap) {
|
||||
this._colors = [RGBA8.Empty];
|
||||
this._backgroundIsLight = true;
|
||||
return;
|
||||
}
|
||||
this._colors = [RGBA8.Empty];
|
||||
for (let colorId = 1; colorId < colorMap.length; colorId++) {
|
||||
const source = colorMap[colorId].rgba;
|
||||
// Use a VM friendly data-type
|
||||
this._colors[colorId] = new RGBA8(source.r, source.g, source.b, Math.round(source.a * 255));
|
||||
}
|
||||
let backgroundLuminosity = colorMap[ColorId.DefaultBackground].getRelativeLuminance();
|
||||
this._backgroundIsLight = backgroundLuminosity >= 0.5;
|
||||
this._onDidChange.fire(undefined);
|
||||
}
|
||||
|
||||
public getColor(colorId: ColorId): RGBA8 {
|
||||
if (colorId < 1 || colorId >= this._colors.length) {
|
||||
// background color (basically invisible)
|
||||
colorId = ColorId.DefaultBackground;
|
||||
}
|
||||
return this._colors[colorId];
|
||||
}
|
||||
|
||||
public backgroundIsLight(): boolean {
|
||||
return this._backgroundIsLight;
|
||||
}
|
||||
}
|
||||
@@ -3,7 +3,7 @@
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import { toUint32 } from 'vs/editor/common/core/uint';
|
||||
import { toUint32 } from 'vs/base/common/uint';
|
||||
|
||||
export class PrefixSumIndexOfResult {
|
||||
_prefixSumIndexOfResultBrand: void;
|
||||
|
||||
@@ -15,7 +15,7 @@ import { ModelDecorationOverviewRulerOptions, ModelDecorationMinimapOptions } fr
|
||||
import * as textModelEvents from 'vs/editor/common/model/textModelEvents';
|
||||
import { ColorId, LanguageId, TokenizationRegistry } from 'vs/editor/common/modes';
|
||||
import { tokenizeLineToHTML } from 'vs/editor/common/modes/textToHtmlTokenizer';
|
||||
import { MinimapTokensColorTracker } from 'vs/editor/common/view/minimapCharRenderer';
|
||||
import { MinimapTokensColorTracker } from 'vs/editor/common/viewModel/minimapTokensColorTracker';
|
||||
import * as viewEvents from 'vs/editor/common/view/viewEvents';
|
||||
import { ViewLayout } from 'vs/editor/common/viewLayout/viewLayout';
|
||||
import { CharacterHardWrappingLineMapperFactory } from 'vs/editor/common/viewModel/characterHardWrappingLineMapper';
|
||||
@@ -24,6 +24,7 @@ import { ICoordinatesConverter, IOverviewRulerDecorations, IViewModel, MinimapLi
|
||||
import { ViewModelDecorations } from 'vs/editor/common/viewModel/viewModelDecorations';
|
||||
import { ITheme } from 'vs/platform/theme/common/themeService';
|
||||
import { RunOnceScheduler } from 'vs/base/common/async';
|
||||
import * as platform from 'vs/base/common/platform';
|
||||
|
||||
const USE_IDENTITY_LINES_COLLECTION = true;
|
||||
|
||||
@@ -128,6 +129,7 @@ export class ViewModel extends viewEvents.ViewEventEmitter implements IViewModel
|
||||
super.dispose();
|
||||
this.decorations.dispose();
|
||||
this.lines.dispose();
|
||||
this.invalidateMinimapColorCache();
|
||||
this.viewportStartLineTrackedRange = this.model._setTrackedRange(this.viewportStartLineTrackedRange, null, TrackedRangeStickiness.NeverGrowsWhenTypingAtEdges);
|
||||
}
|
||||
|
||||
@@ -626,9 +628,19 @@ export class ViewModel extends viewEvents.ViewEventEmitter implements IViewModel
|
||||
|
||||
ranges = ranges.slice(0);
|
||||
ranges.sort(Range.compareRangesUsingStarts);
|
||||
const nonEmptyRanges = ranges.filter((r) => !r.isEmpty());
|
||||
|
||||
if (nonEmptyRanges.length === 0) {
|
||||
let hasEmptyRange = false;
|
||||
let hasNonEmptyRange = false;
|
||||
for (const range of ranges) {
|
||||
if (range.isEmpty()) {
|
||||
hasEmptyRange = true;
|
||||
} else {
|
||||
hasNonEmptyRange = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (!hasNonEmptyRange) {
|
||||
// all ranges are empty
|
||||
if (!emptySelectionClipboard) {
|
||||
return '';
|
||||
}
|
||||
@@ -648,9 +660,29 @@ export class ViewModel extends viewEvents.ViewEventEmitter implements IViewModel
|
||||
return result;
|
||||
}
|
||||
|
||||
if (hasEmptyRange && emptySelectionClipboard) {
|
||||
// mixed empty selections and non-empty selections
|
||||
let result: string[] = [];
|
||||
let prevModelLineNumber = 0;
|
||||
for (const range of ranges) {
|
||||
const modelLineNumber = this.coordinatesConverter.convertViewPositionToModelPosition(new Position(range.startLineNumber, 1)).lineNumber;
|
||||
if (range.isEmpty()) {
|
||||
if (modelLineNumber !== prevModelLineNumber) {
|
||||
result.push(this.model.getLineContent(modelLineNumber));
|
||||
}
|
||||
} else {
|
||||
result.push(this.getValueInRange(range, forceCRLF ? EndOfLinePreference.CRLF : EndOfLinePreference.TextDefined));
|
||||
}
|
||||
prevModelLineNumber = modelLineNumber;
|
||||
}
|
||||
return result.length === 1 ? result[0] : result;
|
||||
}
|
||||
|
||||
let result: string[] = [];
|
||||
for (const nonEmptyRange of nonEmptyRanges) {
|
||||
result.push(this.getValueInRange(nonEmptyRange, forceCRLF ? EndOfLinePreference.CRLF : EndOfLinePreference.TextDefined));
|
||||
for (const range of ranges) {
|
||||
if (!range.isEmpty()) {
|
||||
result.push(this.getValueInRange(range, forceCRLF ? EndOfLinePreference.CRLF : EndOfLinePreference.TextDefined));
|
||||
}
|
||||
}
|
||||
return result.length === 1 ? result[0] : result;
|
||||
}
|
||||
@@ -713,7 +745,7 @@ export class ViewModel extends viewEvents.ViewEventEmitter implements IViewModel
|
||||
if (lineContent === '') {
|
||||
result += '<br>';
|
||||
} else {
|
||||
result += tokenizeLineToHTML(lineContent, lineTokens.inflate(), colorMap, startOffset, endOffset, tabSize);
|
||||
result += tokenizeLineToHTML(lineContent, lineTokens.inflate(), colorMap, startOffset, endOffset, tabSize, platform.isWindows);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user