Don't reload source file, if it's already there.

This commit is contained in:
Bartosz Taudul 2018-08-17 15:24:52 +02:00
parent 5dc3d73ad6
commit d45efbe640

View File

@ -405,6 +405,8 @@ void View::InitTextEditor()
void View::SetTextEditorFile( const char* fileName, int line ) void View::SetTextEditorFile( const char* fileName, int line )
{ {
if( !m_textEditorFile || strcmp( m_textEditorFile, fileName ) != 0 )
{
FILE* f = fopen( fileName, "rb" ); FILE* f = fopen( fileName, "rb" );
fseek( f, 0, SEEK_END ); fseek( f, 0, SEEK_END );
const auto sz = ftell( f ); const auto sz = ftell( f );
@ -413,8 +415,9 @@ void View::SetTextEditorFile( const char* fileName, int line )
data.resize( sz ); data.resize( sz );
fread( data.data(), 1, sz, f ); fread( data.data(), 1, sz, f );
fclose( f ); fclose( f );
m_textEditor->SetText( data ); m_textEditor->SetText( data );
}
m_textEditor->SetCursorPosition( TextEditor::Coordinates( line-1, 0 ) ); m_textEditor->SetCursorPosition( TextEditor::Coordinates( line-1, 0 ) );
m_textEditorFile = fileName; m_textEditorFile = fileName;