def send_unsaved_files(payload, sender): files = payload.get('files', []) out = [] for f in files: view = eutils.view_for_file(f) if not view: continue content = eutils.content(view) if view and view.is_dirty(): fname = view.file_name() pristine = None if not fname: # untitled file pristine = '' elif os.path.exists(fname): pristine = read_file(fname) if pristine is not None: out.append({ 'file': f, 'pristine': pristine, 'content': content }) if out: ws.send({ 'action': 'unsavedFiles', 'data': { 'files': out } }, sender) else: logger.info('No unsaved changes')
def send_unsaved_files(payload, sender): files = payload.get('files', []) out = [] for f in files: view = eutils.view_for_file(f) if not view: continue content = eutils.content(view) if view and view.is_dirty(): fname = view.file_name() pristine = None if not fname: # untitled file pristine = '' elif os.path.exists(fname): pristine = read_file(fname) if pristine is not None and pristine != content: out.append({'file': f, 'pristine': pristine, 'content': content}) if out: ws.send({'action': 'unsavedFiles', 'data': {'files': out}}, sender) else: logger.info('No unsaved changes')
def send_unsaved_files(payload, sender): files = payload.get("files", []) out = [] for f in files: view = eutils.view_for_file(f) if not view: continue content = eutils.content(view) if view and view.is_dirty(): fname = view.file_name() pristine = None if not fname: # untitled file pristine = "" elif os.path.exists(fname): pristine = read_file(fname) if pristine is not None: out.append({"file": f, "pristine": pristine, "content": content}) if out: ws.send({"action": "unsavedFiles", "data": {"files": out}}, sender) else: logger.info("No unsaved changes")
def handle_patch_request(payload): logger.debug('Handle CSS patch request') editor_file = payload.get('editorFile') if not editor_file: logger.debug('No editor file in payload, skip patching') return view = eutils.view_for_file(editor_file) if view is None: logger.warn('Unable to find view for %s file' % editor_file) if editor_file[0] == '<': # it's an untitled file, but view doesn't exists return view = sublime.active_window().open_file(editor_file) patch = payload.get('patch') if patch: apply_patch_on_view(view, patch)
def handle_patch_request(payload, sender): logger.debug("Handle CSS patch request") editor_file = payload.get("editorFile") if not editor_file: logger.debug("No editor file in payload, skip patching") return view = eutils.view_for_file(editor_file) if view is None: logger.warn("Unable to find view for %s file" % editor_file) if editor_file[0] == "<": # it's an untitled file, but view doesn't exists return view = sublime.active_window().open_file(editor_file) patch = payload.get("patch") if patch: apply_patch_on_view(view, patch)