mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-16 10:58:30 -05:00
Refresh master with initial release/0.24 snapshot (#332)
* Initial port of release/0.24 source code * Fix additional headers * Fix a typo in launch.json
This commit is contained in:
@@ -6,6 +6,7 @@
|
||||
|
||||
import { InlineDecoration } from 'vs/editor/common/viewModel/viewModel';
|
||||
import { Constants } from 'vs/editor/common/core/uint';
|
||||
import * as strings from 'vs/base/common/strings';
|
||||
|
||||
export class LineDecoration {
|
||||
_lineDecorationBrand: void;
|
||||
@@ -172,7 +173,7 @@ export class LineDecorationsNormalizer {
|
||||
/**
|
||||
* Normalize line decorations. Overlapping decorations will generate multiple segments
|
||||
*/
|
||||
public static normalize(lineDecorations: LineDecoration[]): DecorationSegment[] {
|
||||
public static normalize(lineContent: string, lineDecorations: LineDecoration[]): DecorationSegment[] {
|
||||
if (lineDecorations.length === 0) {
|
||||
return [];
|
||||
}
|
||||
@@ -184,16 +185,34 @@ export class LineDecorationsNormalizer {
|
||||
|
||||
for (let i = 0, len = lineDecorations.length; i < len; i++) {
|
||||
let d = lineDecorations[i];
|
||||
let startColumn = d.startColumn;
|
||||
let endColumn = d.endColumn;
|
||||
let className = d.className;
|
||||
|
||||
let currentStartOffset = d.startColumn - 1;
|
||||
let currentEndOffset = d.endColumn - 2;
|
||||
// If the position would end up in the middle of a high-low surrogate pair, we move it to before the pair
|
||||
if (startColumn > 1) {
|
||||
const charCodeBefore = lineContent.charCodeAt(startColumn - 2);
|
||||
if (strings.isHighSurrogate(charCodeBefore)) {
|
||||
startColumn--;
|
||||
}
|
||||
}
|
||||
|
||||
if (endColumn > 1) {
|
||||
const charCodeBefore = lineContent.charCodeAt(endColumn - 2);
|
||||
if (strings.isHighSurrogate(charCodeBefore)) {
|
||||
endColumn--;
|
||||
}
|
||||
}
|
||||
|
||||
let currentStartOffset = startColumn - 1;
|
||||
let currentEndOffset = endColumn - 2;
|
||||
|
||||
nextStartOffset = stack.consumeLowerThan(currentStartOffset, nextStartOffset, result);
|
||||
|
||||
if (stack.count === 0) {
|
||||
nextStartOffset = currentStartOffset;
|
||||
}
|
||||
stack.insert(currentEndOffset, d.className);
|
||||
stack.insert(currentEndOffset, className);
|
||||
}
|
||||
|
||||
stack.consumeLowerThan(Constants.MAX_SAFE_SMALL_INTEGER, nextStartOffset, result);
|
||||
|
||||
@@ -531,7 +531,7 @@ function _applyRenderWhitespace(lineContent: string, len: number, tokens: LinePa
|
||||
*/
|
||||
function _applyInlineDecorations(lineContent: string, len: number, tokens: LinePart[], _lineDecorations: LineDecoration[]): LinePart[] {
|
||||
_lineDecorations.sort(LineDecoration.compare);
|
||||
const lineDecorations = LineDecorationsNormalizer.normalize(_lineDecorations);
|
||||
const lineDecorations = LineDecorationsNormalizer.normalize(lineContent, _lineDecorations);
|
||||
const lineDecorationsLen = lineDecorations.length;
|
||||
|
||||
let lineDecorationIndex = 0;
|
||||
@@ -636,10 +636,13 @@ function _renderLine(input: ResolvedRenderLineInput, sb: IStringBuilder): Render
|
||||
}
|
||||
}
|
||||
|
||||
if (!fontIsMonospace && !containsForeignElements) {
|
||||
sb.appendASCIIString(' style="width:');
|
||||
sb.appendASCIIString(String(spaceWidth * partContentCnt));
|
||||
sb.appendASCIIString('px"');
|
||||
if (!fontIsMonospace) {
|
||||
const partIsOnlyWhitespace = (partType === 'vs-whitespace');
|
||||
if (partIsOnlyWhitespace || !containsForeignElements) {
|
||||
sb.appendASCIIString(' style="width:');
|
||||
sb.appendASCIIString(String(spaceWidth * partContentCnt));
|
||||
sb.appendASCIIString('px"');
|
||||
}
|
||||
}
|
||||
sb.appendASCII(CharCode.GreaterThan);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user