macOS build fixes.

UICodeEditor fix incorrect horizontal scroll when document is changed and fix incorrect horizontal scroll on document open.
This commit is contained in:
Martín Lucas Golini
2024-01-17 00:26:32 -03:00
parent aaa70460d8
commit c87750102f
3 changed files with 8 additions and 1 deletions
+1
View File
@@ -1,3 +1,4 @@
#include <cassert>
#include <cstdarg>
#include <eepp/core/debug.hpp>
#include <eepp/system/log.hpp>
+4 -1
View File
@@ -622,7 +622,7 @@ Float UICodeEditor::getViewportWidth( const bool& forceVScroll ) const {
vScrollWidth += getMinimapWidth();
Float viewWidth = eefloor( mSize.getWidth() - mPaddingPx.Left - mPaddingPx.Right -
getGutterWidth() - vScrollWidth );
return viewWidth;
return eemax( 0.f, viewWidth );
}
bool UICodeEditor::getShowIndentationGuides() const {
@@ -856,6 +856,7 @@ void UICodeEditor::setDocument( std::shared_ptr<TextDocument> doc ) {
mDoc = doc;
mDoc->registerClient( this );
invalidateEditor();
invalidateLongestLineWidth();
invalidateDraw();
onDocumentChanged();
}
@@ -1832,6 +1833,8 @@ void UICodeEditor::scrollTo( TextRange position, bool centered, bool forceExactP
Float offsetXEnd = getXOffsetCol( position.end() );
Float minVisibility = getGlyphWidth();
Float viewPortWidth = getViewportWidth();
if ( viewPortWidth == 0 )
return;
if ( offsetXEnd + minVisibility > mScroll.x + viewPortWidth ) {
setScrollX( eefloor( eemax( 0.f, offsetXEnd + minVisibility - viewPortWidth ) ) );
} else if ( offsetXEnd < mScroll.x ) {