提交 3f81b43a 编写于 作者: A Alex Dima

Fixes #38591

上级 4bb888d7
......@@ -78,6 +78,7 @@ export class SelectionsOverlay extends DynamicViewOverlay {
private _context: ViewContext;
private _lineHeight: number;
private _roundedSelection: boolean;
private _typicalHalfwidthCharacterWidth: number;
private _selections: Range[];
private _renderResult: string[];
......@@ -86,6 +87,7 @@ export class SelectionsOverlay extends DynamicViewOverlay {
this._context = context;
this._lineHeight = this._context.configuration.editor.lineHeight;
this._roundedSelection = this._context.configuration.editor.viewInfo.roundedSelection;
this._typicalHalfwidthCharacterWidth = this._context.configuration.editor.fontInfo.typicalHalfwidthCharacterWidth;
this._selections = [];
this._renderResult = null;
this._context.addEventHandler(this);
......@@ -108,6 +110,9 @@ export class SelectionsOverlay extends DynamicViewOverlay {
if (e.viewInfo) {
this._roundedSelection = this._context.configuration.editor.viewInfo.roundedSelection;
}
if (e.fontInfo) {
this._typicalHalfwidthCharacterWidth = this._context.configuration.editor.fontInfo.typicalHalfwidthCharacterWidth;
}
return true;
}
public onCursorStateChanged(e: viewEvents.ViewCursorStateChangedEvent): boolean {
......@@ -154,6 +159,7 @@ export class SelectionsOverlay extends DynamicViewOverlay {
}
private _enrichVisibleRangesWithStyle(linesVisibleRanges: LineVisibleRangesWithStyle[], previousFrame: LineVisibleRangesWithStyle[]): void {
const epsilon = this._typicalHalfwidthCharacterWidth / 4;
let previousFrameTop: HorizontalRangeWithStyle = null;
let previousFrameBottom: HorizontalRangeWithStyle = null;
......@@ -202,13 +208,13 @@ export class SelectionsOverlay extends DynamicViewOverlay {
let prevLeft = linesVisibleRanges[i - 1].ranges[0].left;
let prevRight = linesVisibleRanges[i - 1].ranges[0].left + linesVisibleRanges[i - 1].ranges[0].width;
if (curLeft === prevLeft) {
if (abs(curLeft - prevLeft) < epsilon) {
startStyle.top = CornerStyle.FLAT;
} else if (curLeft > prevLeft) {
startStyle.top = CornerStyle.INTERN;
}
if (curRight === prevRight) {
if (abs(curRight - prevRight) < epsilon) {
endStyle.top = CornerStyle.FLAT;
} else if (prevLeft < curRight && curRight < prevRight) {
endStyle.top = CornerStyle.INTERN;
......@@ -224,13 +230,13 @@ export class SelectionsOverlay extends DynamicViewOverlay {
let nextLeft = linesVisibleRanges[i + 1].ranges[0].left;
let nextRight = linesVisibleRanges[i + 1].ranges[0].left + linesVisibleRanges[i + 1].ranges[0].width;
if (curLeft === nextLeft) {
if (abs(curLeft - nextLeft) < epsilon) {
startStyle.bottom = CornerStyle.FLAT;
} else if (nextLeft < curLeft && curLeft < nextRight) {
startStyle.bottom = CornerStyle.INTERN;
}
if (curRight === nextRight) {
if (abs(curRight - nextRight) < epsilon) {
endStyle.bottom = CornerStyle.FLAT;
} else if (curRight < nextRight) {
endStyle.bottom = CornerStyle.INTERN;
......@@ -407,3 +413,7 @@ registerThemingParticipant((theme, collector) => {
collector.addRule(`.monaco-editor .view-line span.inline-selected-text { color: ${editorSelectionForegroundColor}; }`);
}
});
function abs(n: number): number {
return n < 0 ? -n : n;
}
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册