Skip to content

Commit c4aa04c

Browse files
committed
Always re-render prompt while navigating history
1 parent f1bf1a5 commit c4aa04c

2 files changed

Lines changed: 20 additions & 8 deletions

File tree

src/replxx_impl.cxx

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -966,7 +966,7 @@ int Replxx::ReplxxImpl::virtual_render( char32_t const* buffer_, int len_, int&
966966
* Refresh the user's input line: the prompt is already onscreen and is not
967967
* redrawn here screen position
968968
*/
969-
void Replxx::ReplxxImpl::refresh_line( HINT_ACTION hintAction_ ) {
969+
void Replxx::ReplxxImpl::refresh_line( HINT_ACTION hintAction_, bool refreshPrompt_ ) {
970970
int long long now( now_us() );
971971
int long long duration( now - _lastRefreshTime );
972972
if ( duration < RAPID_REFRESH_US ) {
@@ -993,10 +993,22 @@ void Replxx::ReplxxImpl::refresh_line( HINT_ACTION hintAction_ ) {
993993

994994
// position at the end of the prompt, clear to end of previous input
995995
_terminal.set_cursor_visible( false );
996-
_terminal.jump_cursor(
997-
_prompt.indentation(), // 0-based on Win32
998-
-( _prompt._cursorRowOffset - _prompt._extraLines )
999-
);
996+
if ( refreshPrompt_ )
997+
{
998+
_terminal.jump_cursor(
999+
0,
1000+
-_prompt._cursorRowOffset
1001+
);
1002+
_prompt.write();
1003+
_prompt._cursorRowOffset = _prompt._extraLines;
1004+
}
1005+
else
1006+
{
1007+
_terminal.jump_cursor(
1008+
_prompt.indentation(), // 0-based on Win32
1009+
-( _prompt._cursorRowOffset - _prompt._extraLines )
1010+
);
1011+
}
10001012
// display the input line
10011013
if ( _hasNewlines ) {
10021014
_terminal.clear_screen( Terminal::CLEAR_SCREEN::TO_END );
@@ -1934,7 +1946,7 @@ Replxx::ACTION_RESULT Replxx::ReplxxImpl::history_move( bool previous_ ) {
19341946
}
19351947
_data.assign( _history.current() );
19361948
_pos = _data.length();
1937-
refresh_line();
1949+
refresh_line( HINT_ACTION::REGENERATE, true /* refreshPrompt */ );
19381950
return ( Replxx::ACTION_RESULT::CONTINUE );
19391951
}
19401952

@@ -2006,7 +2018,7 @@ Replxx::ACTION_RESULT Replxx::ReplxxImpl::history_jump( bool back_ ) {
20062018
_history.jump( back_ );
20072019
_data.assign( _history.current() );
20082020
_pos = _data.length();
2009-
refresh_line();
2021+
refresh_line( HINT_ACTION::REGENERATE, true /* refreshPrompt */ );
20102022
}
20112023
return ( Replxx::ACTION_RESULT::CONTINUE );
20122024
}

src/replxx_impl.hxx

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

0 commit comments

Comments
 (0)