def run(self, changes=None):
# debug('workspace edit', changes)
if changes:
for uri, file_changes in changes.items():
path = uri_to_filename(uri)
view = self.window.open_file(path)
if view:
if view.is_loading():
# TODO: wait for event instead.
sublime.set_timeout_async(
lambda: view.run_command('lsp_apply_document_edit', {'changes': file_changes}),
500
)
else:
view.run_command('lsp_apply_document_edit',
{'changes': file_changes,
'show_status': False})
else:
debug('view not found to apply', path, file_changes)
message = 'Applied changes to {} documents'.format(len(changes))
self.window.status_message(message)
else:
self.window.status_message('No changes to apply to workspace')
评论列表
文章目录