IME fixes that should fix SpartanJ/ecode#355.

Fix a crash when loading empty file from disk.
This commit is contained in:
Martín Lucas Golini
2024-11-15 00:07:40 -03:00
parent 8242274059
commit 889ba51a2e
3 changed files with 10 additions and 4 deletions
+2
View File
@@ -230,6 +230,8 @@ void EventDispatcher::sendTextInput( const Uint32& textChar, const Uint32& times
void EventDispatcher::sendTextEditing( const String& text, const Int32& start,
const Int32& length ) {
mWindow->getIME().onTextEditing( text, start, length );
if ( !mWindow->getIME().isEditing() && length <= 0 )
return;
TextEditingEvent textEditingEvent =
TextEditingEvent( mFocusNode, Event::TextInput, text, start, length );
Node* node = mFocusNode;
+4 -3
View File
@@ -1170,7 +1170,7 @@ Sizef UICodeEditor::getViewportDimensions() const {
Rectf UICodeEditor::getScreenPosition( const TextPosition& position ) const {
Float lineHeight = getLineHeight();
Vector2f screenStart( getScreenStart() );
Vector2f start( screenStart.x + getGutterWidth(), screenStart.y );
Vector2f start( screenStart.x + getGutterWidth(), screenStart.y + getPluginsTopSpace() );
Vector2f startScroll( start - mScroll );
auto offset = getTextPositionOffsetSanitized( position, lineHeight );
return { { static_cast<Float>( startScroll.x + offset.x ),
@@ -4332,9 +4332,10 @@ Float UICodeEditor::getMinimapWidth() const {
if ( !mMinimapEnabled )
return 0.f;
Float w = PixelDensity::dpToPx( mMinimapConfig.width );
Float pw = getPixelsSize().getWidth();
// Max [mMinimapConfig.maxPercentWidth]% of the editor view width
if ( w / getPixelsSize().getWidth() > mMinimapConfig.maxPercentWidth )
w = getPixelsSize().getWidth() * mMinimapConfig.maxPercentWidth;
if ( pw != 0 && w / pw > mMinimapConfig.maxPercentWidth )
w = pw * mMinimapConfig.maxPercentWidth;
return w;
}
+4 -1
View File
@@ -755,7 +755,10 @@ void AppConfig::loadProject( std::string projectFolder, UICodeEditorSplitter* ed
editorSplitter->loadAsyncFileFromPathInNewTab(
snapshotFile.cachePath,
[snapshotFile]( UICodeEditor* editor, const std::string& ) {
[snapshotFile, editorSplitter]( UICodeEditor* editor, const std::string& ) {
// Editor could have been closed right after load
if ( !editorSplitter->editorExists( editor ) )
return;
TextDocument& doc = editor->getDocument();
auto selection = TextRange::fromString( snapshotFile.selection );
doc.setDefaultFileName( snapshotFile.name );