Skip to content

Commit

Permalink
Code Editor scrolling fix (#7949)
Browse files Browse the repository at this point in the history
  • Loading branch information
blancoberg authored Jan 6, 2025
1 parent 7730b78 commit e96a977
Showing 1 changed file with 20 additions and 4 deletions.
24 changes: 20 additions & 4 deletions src/surge-xt/gui/overlays/LuaEditors.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1118,16 +1118,32 @@ void SurgeCodeEditorComponent::mouseWheelMove(const juce::MouseEvent &e,
juce::MouseWheelDetails w(wheel);
w.deltaY *= 4;

enum
{
verticalScrollbar,
horizontalScrollbar
};

// makes it possible to mouse wheel scroll and select text at the same time
if (e.mods.isShiftDown())
{
auto scrollbar = dynamic_cast<juce::ScrollBar *>(getChildren()[1]);
auto pos = scrollbar->getCurrentRange().getStart();
scrollToColumn(pos - w.deltaY * 10);
auto scrollbar = dynamic_cast<juce::ScrollBar *>(getChildren()[horizontalScrollbar]);

if (scrollbar != nullptr)
{
auto pos = scrollbar->getCurrentRange().getStart();
auto width = scrollbar->getCurrentRangeSize();
auto maxScroll = std::max((double)0, scrollbar->getMaximumRangeLimit() - width);

scrollToColumn(std::min((double)maxScroll, pos - w.deltaY * 10));
}
}
else
{
scrollBy(-w.deltaY * 10);
auto maxScroll = std::max(0, getDocument().getNumLines() - getNumLinesOnScreen());
auto scrollPos = getFirstLineOnScreen();

scrollToLine(std::min((double)maxScroll, (double)scrollPos - w.deltaY * 10));
}
}

Expand Down

0 comments on commit e96a977

Please sign in to comment.