@@ -106,6 +106,19 @@ def _test_message_order(self, view, messages, inline, command):
106
106
107
107
to_close = []
108
108
109
+ # Helper to check when the view is updated to the correct location.
110
+ def check_view_has_updated (window , expected_filename , expected_row_col ):
111
+ view = window .active_view ()
112
+ view_filename = os .path .normpath (view .file_name ())
113
+ if view_filename != expected_filename :
114
+ return False
115
+ region = view .sel ()[0 ]
116
+ rowcol = view .rowcol (region .begin ())
117
+ if expected_row_col [1 ] is None :
118
+ return rowcol [0 ] == expected_row_col [0 ]
119
+ else :
120
+ return rowcol == expected_row_col
121
+
109
122
def check_sequence (direction ):
110
123
omsgs = messages if direction == 'next' else reversed (messages )
111
124
levels = ('all' , 'error' , 'warning' ) if inline else ('all' ,)
@@ -124,22 +137,27 @@ def check_sequence(direction):
124
137
window .run_command ('rust_' + direction + '_message' ,
125
138
{'levels' : level })
126
139
# Sublime doesn't always immediately move the active
127
- # view when 'next_result' is called, so give it a
128
- # moment to update.
129
- time .sleep (0.1 )
130
- next_view = window .active_view ()
131
- to_close .append (next_view )
132
- self .assertEqual (os .path .normpath (next_view .file_name ()),
133
- os .path .normpath (next_filename ))
134
- region = next_view .sel ()[0 ]
135
- rowcol = next_view .rowcol (region .begin ())
140
+ # view when 'next_result' is called, so loop until
141
+ # it looks like it has updated to the correct location.
142
+ expected_filename = os .path .normpath (next_filename )
136
143
if inline :
137
- self . assertEqual ( rowcol , next_row_col )
144
+ expected_row_col = next_row_col
138
145
else :
139
146
# When inline is disabled, we use Sublime's
140
147
# built-in next/prev, which goes to the beginning.
141
148
# Just validate the row is correct.
142
- self .assertEqual (rowcol [0 ], next_row_col [0 ])
149
+ expected_row_col = (next_row_col [0 ], None )
150
+ for _ in range (30 ):
151
+ if check_view_has_updated (window , expected_filename , expected_row_col ):
152
+ break
153
+ time .sleep (0.1 )
154
+ else :
155
+ view = window .active_view ()
156
+ raise AssertionError ('view did not update to %r at %r as expected\n current view is %r at %r' % (
157
+ expected_filename , expected_row_col ,
158
+ view .file_name (), view .rowcol (view .sel ()[0 ].begin ()))
159
+ )
160
+ to_close .append (window .active_view ())
143
161
# Verify the output panel is highlighting the correct
144
162
# thing.
145
163
build_panel = window .find_output_panel (
0 commit comments