diff --git a/src/vte.cc b/src/vte.cc
index 8d9136f..292725c 100644
--- a/src/vte.cc
+++ b/src/vte.cc
@@ -1118,12 +1118,21 @@ static void
 vte_terminal_match_contents_refresh(VteTerminal *terminal)
 {
 	GArray *array;
+        long start_row, start_col, end_row, end_col;
+        int context_lines = 3;
+        /* Include 3 more lines in both directions. */
+        start_row = terminal->pvt->screen->scroll_delta - context_lines;
+        start_col = 0;
+        end_row = terminal->pvt->screen->scroll_delta + terminal->pvt->row_count - 1 + context_lines;
+        end_col = terminal->pvt->column_count - 1;
 	vte_terminal_match_contents_clear(terminal);
 	array = g_array_new(FALSE, TRUE, sizeof(struct _VteCharAttributes));
-	terminal->pvt->match_contents = vte_terminal_get_text(terminal,
-							      always_selected,
-							      NULL,
-							      array);
+	terminal->pvt->match_contents = vte_terminal_get_text_range(terminal,
+                                                                    start_row, start_col,
+                                                                    end_row, end_col,
+                                                                    always_selected,
+                                                                    NULL,
+                                                                    array);
 	terminal->pvt->match_attributes = array;
 }
 
