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
+3
View File
@@ -343,6 +343,8 @@ class EE_API String {
template <typename... Args> template <typename... Args>
static std::string format( std::string_view format, Args&&... args ) { static std::string format( std::string_view format, Args&&... args ) {
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wformat-security"
int size = int size =
std::snprintf( nullptr, 0, format.data(), std::snprintf( nullptr, 0, format.data(),
FormatArg<std::decay_t<Args>>::get( std::forward<Args>( args ) )... ) + FormatArg<std::decay_t<Args>>::get( std::forward<Args>( args ) )... ) +
@@ -353,6 +355,7 @@ class EE_API String {
FormatArg<std::decay_t<Args>>::get( std::forward<Args>( args ) )... ); FormatArg<std::decay_t<Args>>::get( std::forward<Args>( args ) )... );
result.resize( size - 1 ); result.resize( size - 1 );
} }
#pragma clang diagnostic pop
return result; return result;
} }
+1
View File
@@ -1,3 +1,4 @@
#include <cassert>
#include <cstdarg> #include <cstdarg>
#include <eepp/core/debug.hpp> #include <eepp/core/debug.hpp>
#include <eepp/system/log.hpp> #include <eepp/system/log.hpp>
+4 -1
View File
@@ -622,7 +622,7 @@ Float UICodeEditor::getViewportWidth( const bool& forceVScroll ) const {
vScrollWidth += getMinimapWidth(); vScrollWidth += getMinimapWidth();
Float viewWidth = eefloor( mSize.getWidth() - mPaddingPx.Left - mPaddingPx.Right - Float viewWidth = eefloor( mSize.getWidth() - mPaddingPx.Left - mPaddingPx.Right -
getGutterWidth() - vScrollWidth ); getGutterWidth() - vScrollWidth );
return viewWidth; return eemax( 0.f, viewWidth );
} }
bool UICodeEditor::getShowIndentationGuides() const { bool UICodeEditor::getShowIndentationGuides() const {
@@ -856,6 +856,7 @@ void UICodeEditor::setDocument( std::shared_ptr<TextDocument> doc ) {
mDoc = doc; mDoc = doc;
mDoc->registerClient( this ); mDoc->registerClient( this );
invalidateEditor(); invalidateEditor();
invalidateLongestLineWidth();
invalidateDraw(); invalidateDraw();
onDocumentChanged(); onDocumentChanged();
} }
@@ -1832,6 +1833,8 @@ void UICodeEditor::scrollTo( TextRange position, bool centered, bool forceExactP
Float offsetXEnd = getXOffsetCol( position.end() ); Float offsetXEnd = getXOffsetCol( position.end() );
Float minVisibility = getGlyphWidth(); Float minVisibility = getGlyphWidth();
Float viewPortWidth = getViewportWidth(); Float viewPortWidth = getViewportWidth();
if ( viewPortWidth == 0 )
return;
if ( offsetXEnd + minVisibility > mScroll.x + viewPortWidth ) { if ( offsetXEnd + minVisibility > mScroll.x + viewPortWidth ) {
setScrollX( eefloor( eemax( 0.f, offsetXEnd + minVisibility - viewPortWidth ) ) ); setScrollX( eefloor( eemax( 0.f, offsetXEnd + minVisibility - viewPortWidth ) ) );
} else if ( offsetXEnd < mScroll.x ) { } else if ( offsetXEnd < mScroll.x ) {