Skip to content

Commit

Permalink
fix hover
Browse files Browse the repository at this point in the history
  • Loading branch information
x17jiri committed Oct 4, 2024
1 parent 2bf6ccd commit e67cb68
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
11 changes: 6 additions & 5 deletions src/vs/editor/browser/controller/mouseTarget.ts
Original file line number Diff line number Diff line change
Expand Up @@ -742,22 +742,23 @@ export class MouseTargetFactory {
// 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 spaceWidth = ctx.spaceWidth;
const lineNumber = ctx.getLineNumberAtVerticalOffset(request.mouseVerticalOffset);
const lineWidth = ctx.visibleRangeForPosition(lineNumber, ctx.viewModel.getLineMaxColumn(lineNumber))?.originalLeft || 0;
const pxBehind = request.mouseContentHorizontalOffset - lineWidth;
const spaceWidth = ctx.spaceWidth;
const colsBehind = Math.floor(pxBehind / spaceWidth);

if (ctx.viewModel.getLineLength(lineNumber) === 0) {
const detail = createEmptyContentDataInLines(pxBehind);
const pos = new Position(lineNumber, 1 + colsBehind);
//return request.fulfillContentText(pos, null, { mightBeForeignElement: false, injectedText: null });
return request.fulfillContentEmpty(pos, createEmptyContentDataInLines(pxBehind));
return request.fulfillContentEmpty(pos, detail);
}

if (request.mouseContentHorizontalOffset >= lineWidth) {
// TODO: This is wrong for RTL
const detail = createEmptyContentDataInLines(pxBehind);
const pos = new Position(lineNumber, ctx.viewModel.getLineMaxColumn(lineNumber) + colsBehind);
//return request.fulfillContentText(pos, null, { mightBeForeignElement: false, injectedText: null });
return request.fulfillContentEmpty(pos, createEmptyContentDataInLines(pxBehind));
return request.fulfillContentEmpty(pos, detail);
}
}

Expand Down
4 changes: 4 additions & 0 deletions src/vs/editor/contrib/hover/browser/getHover.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,10 @@ async function executeProvider(provider: HoverProvider, ordinal: number, model:
}

export function getHoverProviderResultsAsAsyncIterable(registry: LanguageFeatureRegistry<HoverProvider>, model: ITextModel, position: Position, token: CancellationToken, recursive = false): AsyncIterableObject<HoverProviderResult> {
const maxColumn = model.getLineMaxColumn(position.lineNumber);
if (position.column > maxColumn) {
position = new Position(position.lineNumber, maxColumn);
}
const providers = registry.ordered(model, recursive);
const promises = providers.map((provider, index) => executeProvider(provider, index, model, position, token));
return AsyncIterableObject.fromPromises(promises).coalesce();
Expand Down

0 comments on commit e67cb68

Please sign in to comment.