mirror of
https://github.com/SpartanJ/eepp.git
synced 2026-10-02 11:10:31 +03:00
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:
@@ -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,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>
|
||||||
|
|||||||
@@ -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 ) {
|
||||||
|
|||||||
Reference in New Issue
Block a user