Trim empty lines at top and bottom of source preview.

This commit is contained in:
Bartosz Taudul 2021-03-27 13:55:22 +01:00
parent a15ba0c7fb
commit 62ac5544b6
No known key found for this signature in database
GPG Key ID: B7FE2008B7575DF3
2 changed files with 20 additions and 2 deletions

View File

@ -2554,15 +2554,24 @@ void SourceView::RenderAsmLine( AsmLine& line, uint32_t ipcnt, uint32_t iptotal,
auto& lines = m_sourceTooltip.get(); auto& lines = m_sourceTooltip.get();
const int start = std::max( 0, (int)srcline - 4 ); const int start = std::max( 0, (int)srcline - 4 );
const int end = std::min<int>( m_sourceTooltip.get().size(), srcline + 3 ); const int end = std::min<int>( m_sourceTooltip.get().size(), srcline + 3 );
bool first = true;
int bottomEmpty = 0;
for( int i=start; i<end; i++ ) for( int i=start; i<end; i++ )
{ {
auto& line = lines[i]; auto& line = lines[i];
if( line.begin == line.end ) if( line.begin == line.end )
{ {
ImGui::TextUnformatted( "" ); if( !first ) bottomEmpty++;
} }
else else
{ {
first = false;
while( bottomEmpty > 0 )
{
ImGui::TextUnformatted( "" );
bottomEmpty--;
}
auto ptr = line.begin; auto ptr = line.begin;
auto it = line.tokens.begin(); auto it = line.tokens.begin();
while( ptr < line.end ) while( ptr < line.end )

View File

@ -17843,15 +17843,24 @@ void View::DrawSourceTooltip( const char* filename, uint32_t srcline, int before
auto& lines = m_srcHintCache.get(); auto& lines = m_srcHintCache.get();
const int start = std::max( 0, (int)srcline - ( before+1 ) ); const int start = std::max( 0, (int)srcline - ( before+1 ) );
const int end = std::min<int>( m_srcHintCache.get().size(), srcline + after ); const int end = std::min<int>( m_srcHintCache.get().size(), srcline + after );
bool first = true;
int bottomEmpty = 0;
for( int i=start; i<end; i++ ) for( int i=start; i<end; i++ )
{ {
auto& line = lines[i]; auto& line = lines[i];
if( line.begin == line.end ) if( line.begin == line.end )
{ {
ImGui::TextUnformatted( "" ); if( !first ) bottomEmpty++;
} }
else else
{ {
first = false;
while( bottomEmpty > 0 )
{
ImGui::TextUnformatted( "" );
bottomEmpty--;
}
auto ptr = line.begin; auto ptr = line.begin;
auto it = line.tokens.begin(); auto it = line.tokens.begin();
while( ptr < line.end ) while( ptr < line.end )