def run(self, edit, payload=None, **kwargs): if not payload: return suppress_update(self.view) s = self.view.sel()[0] sels = [[s.a, s.a]] try: payload = eutils.parse_json(payload) except: payload = {'content': payload, 'selection': None} # if sublime_ver < 3: # payload['content'] = payload.get('content', u'').decode('utf-8') self.view.replace(edit, sublime.Region(0, self.view.size()), payload.get('content', '')) if payload.get('selection'): sels = [payload.get('selection')] self.view.sel().clear() for s in sels: self.view.sel().add(sublime.Region(s[0], s[1])) self.view.show(self.view.sel())
def send_patches(buf_id=None, p=None): if not buf_id or not p: return p = eutils.parse_json(p) view = eutils.view_for_buffer_id(buf_id) if p and view is not None: ws.send({"action": "update", "data": {"editorFile": eutils.file_name(view), "patch": p}})
def send_patches(buf_id=None, p=None): if not buf_id or not p: return p = eutils.parse_json(p) view = eutils.view_for_buffer_id(buf_id) if p and view is not None: ws.send({ 'action': 'update', 'data': { 'editorFile': eutils.file_name(view), 'patch': p } })
def patch(buf_id, patches): """ Performs patching of given source in separate thread """ logger.debug('Request patching') if buf_id not in _patch_state: _patch_state[buf_id] = { 'running': False, 'patches': [], 'start_time': 0 } state = _patch_state[buf_id] patches = eutils.parse_json(patches) or [] if is_locked(state): logger.debug('Batch patches') state['patches'] += patches elif patches: logger.debug('Start patching') _start_patch(buf_id, patches)