Skip to content

Commit c0b70dc

Browse files
committed
Always re-render prompt while navigating history
1 parent d2797c2 commit c0b70dc

2 files changed

Lines changed: 10 additions & 4 deletions

File tree

src/replxx_impl.cxx

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -949,14 +949,20 @@ int Replxx::ReplxxImpl::virtual_render( char32_t const* buffer_, int len_, int&
949949
* Refresh the user's input line: the prompt is already onscreen and is not
950950
* redrawn here screen position
951951
*/
952-
void Replxx::ReplxxImpl::refresh_line( HINT_ACTION hintAction_ ) {
952+
void Replxx::ReplxxImpl::refresh_line( HINT_ACTION hintAction_, bool refreshPrompt_ ) {
953953
int long long now( now_us() );
954954
int long long duration( now - _lastRefreshTime );
955955
if ( duration < RAPID_REFRESH_US ) {
956956
_lastRefreshTime = now;
957957
_refreshSkipped = true;
958958
return;
959959
}
960+
if ( refreshPrompt_ )
961+
{
962+
_terminal.jump_cursor( 0, 0 );
963+
_prompt.write();
964+
_prompt._cursorRowOffset = _prompt._extraLines;
965+
}
960966
_refreshSkipped = false;
961967
render( hintAction_ );
962968
handle_hints( hintAction_ );
@@ -1894,7 +1900,7 @@ Replxx::ACTION_RESULT Replxx::ReplxxImpl::history_move( bool previous_ ) {
18941900
}
18951901
_data.assign( _history.current() );
18961902
_pos = _data.length();
1897-
refresh_line();
1903+
refresh_line( HINT_ACTION::REGENERATE, true /* refreshPrompt */ );
18981904
return ( Replxx::ACTION_RESULT::CONTINUE );
18991905
}
19001906

@@ -1941,7 +1947,7 @@ Replxx::ACTION_RESULT Replxx::ReplxxImpl::history_jump( bool back_ ) {
19411947
_history.jump( back_ );
19421948
_data.assign( _history.current() );
19431949
_pos = _data.length();
1944-
refresh_line();
1950+
refresh_line( HINT_ACTION::REGENERATE, true /* refreshPrompt */ );
19451951
}
19461952
return ( Replxx::ACTION_RESULT::CONTINUE );
19471953
}

src/replxx_impl.hxx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -266,7 +266,7 @@ private:
266266
void call_modify_callback( void );
267267
completions_t call_completer( std::string const& input, int& ) const;
268268
hints_t call_hinter( std::string const& input, int&, Replxx::Color& color ) const;
269-
void refresh_line( HINT_ACTION = HINT_ACTION::REGENERATE );
269+
void refresh_line( HINT_ACTION = HINT_ACTION::REGENERATE, bool refreshPrompt_ = false );
270270
void move_cursor( void );
271271
void indent( void );
272272
int virtual_render( char32_t const*, int, int&, int&, Prompt const* = nullptr );

0 commit comments

Comments
 (0)