Fix missing lines from highlights on shift-select upwards and then down again
Merge fix for missing highlighted lines. Fix #263. Fix bug 982660.