fix to changes in autocomplete insertion
minor fix
addressed review comments
Merge pull request #3018 from aparajit-pratap/fixAggressiveAutoComplete

Cross-merge from master for PR #3009