Skip to content

Commit

Permalink
Ignore underlong completions.
Browse files Browse the repository at this point in the history
  • Loading branch information
AmokHuginnsson committed Jun 6, 2020
1 parent 737c8e8 commit ffd76db
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
10 changes: 7 additions & 3 deletions src/replxx_impl.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -349,8 +349,12 @@ Replxx::ReplxxImpl::completions_t Replxx::ReplxxImpl::call_completer( std::strin
);
completions_t completions;
completions.reserve( completionsIntermediary.size() );
for ( Replxx::Completion const& c : completionsIntermediary ) {
completions.emplace_back( c );
for ( Replxx::Completion const& external : completionsIntermediary ) {
Completion internal( external );
if ( internal.text().length() < contextLen_ ) {
continue;
}
completions.emplace_back( internal );
}
return ( completions );
}
Expand Down Expand Up @@ -1948,7 +1952,7 @@ Replxx::ACTION_RESULT Replxx::ReplxxImpl::bracketed_paste( char32_t ) {
if ( c == KEY::PASTE_FINISH ) {
break;
}
if ( c == '\r' ) {
if ( ( c == '\r' ) || ( c == KEY::control( 'M' ) ) ) {
c = '\n';
}
buf.push_back( c );
Expand Down
4 changes: 2 additions & 2 deletions tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -579,8 +579,8 @@ def test_tab_completion( self_ ):
def test_completion_shorter_result( self_ ):
self_.check_scenario(
"<up><tab><cr><c-d>",
"<c9>\\pi<rst><ceos><c12><c9>π<rst><ceos><c10><c9>π<rst><ceos><c10>\r\n"
"π\r\n",
"<c9>\\pi<rst><ceos><c12><bell><c9>\\pi<rst><ceos><c12>\r\n"
"\\pi\r\n",
"\\pi\n"
)
def test_completion_pager( self_ ):
Expand Down

0 comments on commit ffd76db

Please sign in to comment.