Skip to content

Commit d76638e

Browse files
ehussJayflux
authored andcommitted
Fix and enhance next/prev message jumping. (#207)
* Sort build messages by level for next/prev shortcuts. * Add tests for next/prev message order. * Update for rust 1.22. * Next/Prev message support when show_errors_inline is False. Fixes #206. * Add undocumented config variable to disable message sorting. * Support scrolling the build output panel on next/prev message. * Fix on-save checking when show_errors_inline is false. To disable on-save checking, set rust_syntax_checking to false. * Next/Prev message cycles through test errors. * Ensure that all views are closed after running tests. * Fix cyclic import. * Fix test errors that panic outside of the crate. Rust display the source file to the outside crate, which probably isn't available in the current workspace. Next/Prev message was opening a non-existent file. * Fix Next/Prev overriding find-in-files next/prev result. Fixes #209.
1 parent 247ffbe commit d76638e

19 files changed

+609
-5142
lines changed

SyntaxCheckPlugin.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ def run(self):
106106
self.get_rustc_messages()
107107
except rust_proc.ProcessTerminatedError:
108108
return
109-
messages.draw_all_region_highlights(self.window)
109+
messages.messages_finished(self.window)
110110
finally:
111111
self.view.erase_status('rust-check')
112112

@@ -124,7 +124,8 @@ def get_rustc_messages(self):
124124
if method == 'clippy':
125125
# Clippy does not support cargo target filters, must be run for
126126
# all targets.
127-
cmd = settings.get_command(method, command_info, self.cwd)
127+
cmd = settings.get_command(method, command_info, self.cwd,
128+
force_json=True)
128129
p = rust_proc.RustProc()
129130
p.run(self.window, cmd['command'], self.cwd, self, env=cmd['env'])
130131
p.wait()
@@ -135,7 +136,8 @@ def get_rustc_messages(self):
135136
targets = td.determine_targets(self.triggered_file_name)
136137
for (target_src, target_args) in targets:
137138
cmd = settings.get_command(method, command_info, self.cwd,
138-
initial_settings={'target': ' '.join(target_args)})
139+
initial_settings={'target': ' '.join(target_args)},
140+
force_json=True)
139141
if method == 'no-trans':
140142
cmd['command'].extend(['--', '-Zno-trans', '-Zunstable-options'])
141143
if (util.get_setting('rust_syntax_checking_include_tests', True) and

cargo_build.py

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,8 @@ def run(self):
196196
return
197197
messages.clear_messages(self.window)
198198
p = rust_proc.RustProc()
199-
listener = opanel.OutputListener(self.window, self.working_dir)
199+
listener = opanel.OutputListener(self.window, self.working_dir,
200+
self.command_name)
200201
decode_json = util.get_setting('show_errors_inline', True) and \
201202
self.command_info.get('allows_json', False)
202203
try:
@@ -229,16 +230,28 @@ def on_load(self, view):
229230
lambda: messages.show_messages_for_view(view), 1)
230231

231232

232-
class RustNextMessageCommand(sublime_plugin.WindowCommand):
233+
class NextPrevBase(sublime_plugin.WindowCommand):
234+
235+
def _has_inline(self):
236+
return self.window.id() in messages.WINDOW_MESSAGES
237+
238+
239+
class RustNextMessageCommand(NextPrevBase):
233240

234241
def run(self, levels='all'):
235-
messages.show_next_message(self.window, levels)
242+
if self._has_inline():
243+
messages.show_next_message(self.window, levels)
244+
else:
245+
self.window.run_command('next_result')
236246

237247

238-
class RustPrevMessageCommand(sublime_plugin.WindowCommand):
248+
class RustPrevMessageCommand(NextPrevBase):
239249

240250
def run(self, levels='all'):
241-
messages.show_prev_message(self.window, levels)
251+
if self._has_inline():
252+
messages.show_prev_message(self.window, levels)
253+
else:
254+
self.window.run_command('prev_result')
242255

243256

244257
class RustCancelCommand(sublime_plugin.WindowCommand):

rust/cargo_settings.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -350,7 +350,7 @@ def get_merged(self, settings_path, variant, target, key,
350350
return result
351351

352352
def get_command(self, cmd_name, cmd_info,
353-
settings_path, initial_settings={}):
353+
settings_path, initial_settings={}, force_json=False):
354354
"""Generates the command arguments for running Cargo.
355355
356356
:param cmd_name: The name of the command, the key used to select a
@@ -361,6 +361,7 @@ def get_command(self, cmd_name, cmd_info,
361361
directory.
362362
:keyword initial_settings: Initial settings to inject which override
363363
all other settings.
364+
:keyword force_json: If True, will force JSON output.
364365
365366
:Returns: A dictionary with the keys:
366367
- `command`: The command to run as a list of strings.
@@ -400,8 +401,8 @@ def get_computed(key, default=None):
400401
if v:
401402
result.append('--release')
402403

403-
if cmd_info.get('allows_json', False) and \
404-
util.get_setting('show_errors_inline', True):
404+
if force_json or (cmd_info.get('allows_json', False) and
405+
util.get_setting('show_errors_inline', True)):
405406
result.append('--message-format=json')
406407

407408
# features

0 commit comments

Comments
 (0)