Skip to content

Commit

Permalink
macOS build fixes.
Browse files Browse the repository at this point in the history
UICodeEditor fix incorrect horizontal scroll when document is changed and fix incorrect horizontal scroll on document open.
  • Loading branch information
SpartanJ committed Jan 17, 2024
1 parent aaa7046 commit c877501
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 1 deletion.
3 changes: 3 additions & 0 deletions include/eepp/core/string.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -343,6 +343,8 @@ class EE_API String {

template <typename... Args>
static std::string format( std::string_view format, Args&&... args ) {
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wformat-security"
int size =
std::snprintf( nullptr, 0, format.data(),
FormatArg<std::decay_t<Args>>::get( std::forward<Args>( args ) )... ) +
Expand All @@ -353,6 +355,7 @@ class EE_API String {
FormatArg<std::decay_t<Args>>::get( std::forward<Args>( args ) )... );
result.resize( size - 1 );
}
#pragma clang diagnostic pop
return result;
}

Expand Down
1 change: 1 addition & 0 deletions src/eepp/core/debug.cpp
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#include <cassert>
#include <cstdarg>
#include <eepp/core/debug.hpp>
#include <eepp/system/log.hpp>
Expand Down
5 changes: 4 additions & 1 deletion src/eepp/ui/uicodeeditor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -856,6 +856,7 @@ void UICodeEditor::setDocument( std::shared_ptr<TextDocument> doc ) {
mDoc = doc;
mDoc->registerClient( this );
invalidateEditor();
invalidateLongestLineWidth();
invalidateDraw();
onDocumentChanged();
}
Expand Down Expand Up @@ -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 ) {
Expand Down

0 comments on commit c877501

Please sign in to comment.