Skip to content

Commit

Permalink
Remove unused code
Browse files Browse the repository at this point in the history
  • Loading branch information
Skalakid committed Oct 10, 2024
1 parent d7edecc commit d85e699
Showing 1 changed file with 6 additions and 10 deletions.
16 changes: 6 additions & 10 deletions src/web/utils/cursorUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,16 +58,12 @@ function scrollIntoView(target: MarkdownTextInputElement, node: TreeNode) {
const currentLine = target.tree.childNodes[orderIndex]?.element;
const scrollTargetElement = currentLine || node.element;

const selection = window.getSelection();
if (selection && selection.rangeCount > 0) {
const caretRect = scrollTargetElement.getBoundingClientRect();
const targetRect = target.getBoundingClientRect();

// In case the caret is below the visible input area, scroll to the end of the node
if (caretRect.top + caretRect.height > targetRect.top + targetRect.height) {
targetElement.scrollTop = caretRect.top - targetRect.top + target.scrollTop - targetRect.height + caretRect.height + 4;
return;
}
const caretRect = scrollTargetElement.getBoundingClientRect();
const targetRect = target.getBoundingClientRect();
// In case the caret is below the visible input area, scroll to the end of the node
if (caretRect.top + caretRect.height > targetRect.top + targetRect.height) {
targetElement.scrollTop = caretRect.top - targetRect.top + target.scrollTop - targetRect.height + caretRect.height + 4;
return;
}

scrollTargetElement.scrollIntoView({
Expand Down

0 comments on commit d85e699

Please sign in to comment.