mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-01-22 01:25:38 -05:00
Merge VS Code 1.23.1 (#1520)
This commit is contained in:
@@ -16,6 +16,7 @@ import { PartFingerprint, PartFingerprints } from 'vs/editor/browser/view/viewPa
|
||||
import { IViewModel } from 'vs/editor/common/viewModel/viewModel';
|
||||
import { EditorLayoutInfo } from 'vs/editor/common/config/editorOptions';
|
||||
import { ViewLine } from 'vs/editor/browser/viewParts/lines/viewLine';
|
||||
import { HorizontalRange } from 'vs/editor/common/view/renderingContext';
|
||||
|
||||
export interface IViewZoneData {
|
||||
viewZoneId: number;
|
||||
@@ -34,6 +35,7 @@ export interface IMarginData {
|
||||
|
||||
export interface IEmptyContentData {
|
||||
isAfterLines: boolean;
|
||||
horizontalDistanceToText?: number;
|
||||
}
|
||||
|
||||
interface IETextRange {
|
||||
@@ -174,6 +176,14 @@ class ElementPath {
|
||||
);
|
||||
}
|
||||
|
||||
public static isStrictChildOfViewLines(path: Uint8Array): boolean {
|
||||
return (
|
||||
path.length > 4
|
||||
&& path[0] === PartFingerprint.OverflowGuard
|
||||
&& path[3] === PartFingerprint.ViewLines
|
||||
);
|
||||
}
|
||||
|
||||
public static isChildOfScrollableElement(path: Uint8Array): boolean {
|
||||
return (
|
||||
path.length >= 2
|
||||
@@ -214,7 +224,7 @@ class ElementPath {
|
||||
}
|
||||
}
|
||||
|
||||
class HitTestContext {
|
||||
export class HitTestContext {
|
||||
|
||||
public readonly model: IViewModel;
|
||||
public readonly layoutInfo: EditorLayoutInfo;
|
||||
@@ -238,12 +248,16 @@ class HitTestContext {
|
||||
}
|
||||
|
||||
public getZoneAtCoord(mouseVerticalOffset: number): IViewZoneData {
|
||||
return HitTestContext.getZoneAtCoord(this._context, mouseVerticalOffset);
|
||||
}
|
||||
|
||||
public static getZoneAtCoord(context: ViewContext, mouseVerticalOffset: number): IViewZoneData {
|
||||
// The target is either a view zone or the empty space after the last view-line
|
||||
let viewZoneWhitespace = this._context.viewLayout.getWhitespaceAtVerticalOffset(mouseVerticalOffset);
|
||||
let viewZoneWhitespace = context.viewLayout.getWhitespaceAtVerticalOffset(mouseVerticalOffset);
|
||||
|
||||
if (viewZoneWhitespace) {
|
||||
let viewZoneMiddle = viewZoneWhitespace.verticalOffset + viewZoneWhitespace.height / 2,
|
||||
lineCount = this._context.model.getLineCount(),
|
||||
lineCount = context.model.getLineCount(),
|
||||
positionBefore: Position = null,
|
||||
position: Position,
|
||||
positionAfter: Position = null;
|
||||
@@ -254,7 +268,7 @@ class HitTestContext {
|
||||
}
|
||||
if (viewZoneWhitespace.afterLineNumber > 0) {
|
||||
// There are more lines above this view zone
|
||||
positionBefore = new Position(viewZoneWhitespace.afterLineNumber, this._context.model.getLineMaxColumn(viewZoneWhitespace.afterLineNumber));
|
||||
positionBefore = new Position(viewZoneWhitespace.afterLineNumber, context.model.getLineMaxColumn(viewZoneWhitespace.afterLineNumber));
|
||||
}
|
||||
|
||||
if (positionAfter === null) {
|
||||
@@ -330,7 +344,7 @@ class HitTestContext {
|
||||
return this._viewHelper.getLineWidth(lineNumber);
|
||||
}
|
||||
|
||||
public visibleRangeForPosition2(lineNumber: number, column: number) {
|
||||
public visibleRangeForPosition2(lineNumber: number, column: number): HorizontalRange {
|
||||
return this._viewHelper.visibleRangeForPosition2(lineNumber, column);
|
||||
}
|
||||
|
||||
@@ -402,7 +416,13 @@ class HitTestRequest extends BareHitTestRequest {
|
||||
}
|
||||
|
||||
const EMPTY_CONTENT_AFTER_LINES: IEmptyContentData = { isAfterLines: true };
|
||||
const EMPTY_CONTENT_IN_LINES: IEmptyContentData = { isAfterLines: false };
|
||||
|
||||
function createEmptyContentDataInLines(horizontalDistanceToText: number): IEmptyContentData {
|
||||
return {
|
||||
isAfterLines: false,
|
||||
horizontalDistanceToText: horizontalDistanceToText
|
||||
};
|
||||
}
|
||||
|
||||
export class MouseTargetFactory {
|
||||
|
||||
@@ -621,6 +641,17 @@ export class MouseTargetFactory {
|
||||
}
|
||||
|
||||
if (domHitTestExecuted) {
|
||||
// Check if we are hitting a view-line (can happen in the case of inline decorations on empty lines)
|
||||
// See https://github.com/Microsoft/vscode/issues/46942
|
||||
if (ElementPath.isStrictChildOfViewLines(request.targetPath)) {
|
||||
const lineNumber = ctx.getLineNumberAtVerticalOffset(request.mouseVerticalOffset);
|
||||
if (ctx.model.getLineLength(lineNumber) === 0) {
|
||||
const lineWidth = ctx.getLineWidth(lineNumber);
|
||||
const detail = createEmptyContentDataInLines(request.mouseContentHorizontalOffset - lineWidth);
|
||||
return request.fulfill(MouseTargetType.CONTENT_EMPTY, new Position(lineNumber, 1), void 0, detail);
|
||||
}
|
||||
}
|
||||
|
||||
// We have already executed hit test...
|
||||
return request.fulfill(MouseTargetType.UNKNOWN);
|
||||
}
|
||||
@@ -691,9 +722,11 @@ export class MouseTargetFactory {
|
||||
if (request.mouseContentHorizontalOffset > lineWidth) {
|
||||
if (browser.isEdge && pos.column === 1) {
|
||||
// See https://github.com/Microsoft/vscode/issues/10875
|
||||
return request.fulfill(MouseTargetType.CONTENT_EMPTY, new Position(lineNumber, ctx.model.getLineMaxColumn(lineNumber)), void 0, EMPTY_CONTENT_IN_LINES);
|
||||
const detail = createEmptyContentDataInLines(request.mouseContentHorizontalOffset - lineWidth);
|
||||
return request.fulfill(MouseTargetType.CONTENT_EMPTY, new Position(lineNumber, ctx.model.getLineMaxColumn(lineNumber)), void 0, detail);
|
||||
}
|
||||
return request.fulfill(MouseTargetType.CONTENT_EMPTY, pos, void 0, EMPTY_CONTENT_IN_LINES);
|
||||
const detail = createEmptyContentDataInLines(request.mouseContentHorizontalOffset - lineWidth);
|
||||
return request.fulfill(MouseTargetType.CONTENT_EMPTY, pos, void 0, detail);
|
||||
}
|
||||
|
||||
const visibleRange = ctx.visibleRangeForPosition2(lineNumber, column);
|
||||
|
||||
Reference in New Issue
Block a user