diff --git a/src/vte.cc b/src/vte.cc
index 10e08fd..f2e43cf 100644
--- a/src/vte.cc
+++ b/src/vte.cc
@@ -1213,10 +1213,12 @@ vte_terminal_match_contents_refresh(VteTerminal *terminal)
 {
 	GArray *array;
         long start_row, start_col, end_row, end_col;
+        /* Include 3 more lines in both directions. */
+        const int context_lines = 3;
 
-        start_row = _vte_terminal_first_displayed_row (terminal);
+        start_row = _vte_terminal_first_displayed_row (terminal) - context_lines;
         start_col = 0;
-        end_row = _vte_terminal_last_displayed_row (terminal);
+        end_row = _vte_terminal_last_displayed_row (terminal) + context_lines;
         end_col = terminal->pvt->column_count - 1;
 
 	vte_terminal_match_contents_clear(terminal);
