diff --git a/services/web/frontend/js/features/source-editor/extensions/review-tooltip.ts b/services/web/frontend/js/features/source-editor/extensions/review-tooltip.ts index 61d1681ae8..1dca2689c4 100644 --- a/services/web/frontend/js/features/source-editor/extensions/review-tooltip.ts +++ b/services/web/frontend/js/features/source-editor/extensions/review-tooltip.ts @@ -126,9 +126,21 @@ function buildTooltip(state: EditorState): Tooltip | null { return null } + const lineAtFrom = state.doc.lineAt(state.selection.main.from) + const lineAtTo = state.doc.lineAt(state.selection.main.to) + const multiLineSelection = lineAtFrom.number !== lineAtTo.number + const column = state.selection.main.head - lineAtTo.from + + // If the selection is a multi-line selection and the cursor is at the beginning of the next line + // we want to show the tooltip at the end of the previous line + const pos = + multiLineSelection && column === 0 + ? state.selection.main.head - 1 + : state.selection.main.head + return { - pos: state.selection.main.head, - above: true, + pos, + above: state.selection.main.head !== state.selection.main.to, create: createReviewTooltipView, } }