Exemple #1
0
	def run(self, edit):
		domain = '%s: GsFmt' % DOMAIN
		vsize = self.view.size()
		src = self.view.substr(sublime.Region(0, vsize))
		if not src.strip():
			return

		src, err = mg9.fmt(self.view.file_name(), src)

		if not err and not src.strip():
			err = "it appears to be empty"

		if err:
			err = "Cannot fmt file. Error: `%s'" % err
			short_err = '%s: %s... error logged to console' % (domain, err[:15])

			def clear_status():
				if self.view.get_status(domain) == short_err:
					self.view.set_status(domain, '')

			gs.println(domain, err)
			self.view.set_status(domain, short_err)
			sublime.set_timeout(clear_status, 10000)

			if 'ipc_timeout' in err:
				self.view.show_popup("%s: <b>%s</b>" % (domain, err))

			return

		_, err = gspatch.merge(self.view, vsize, src, edit)
		if err:
			msg = 'PANIC: Cannot fmt file. Check your source for errors (and maybe undo any changes).'
			sublime.error_message("%s: %s: Merge failure: `%s'" % (domain, msg, err))
Exemple #2
0
	def run(self, edit, pos, content, added_path=''):
		pos = int(pos) # un-f*****g-believable
		view = self.view
		dirty, err = gspatch.merge(view, pos, content, edit)
		if err:
			gs.notice_undo(DOMAIN, err, view, dirty)
		elif dirty:
			k = 'last_import_path.%s' % gs.view_fn(self.view)
			if added_path:
				gs.set_attr(k, added_path)
			else:
				gs.del_attr(k)
Exemple #3
0
	def run(self, edit, pos, content, added_path=''):
		pos = int(pos) # un-f*****g-believable
		view = self.view
		dirty, err = gspatch.merge(view, pos, content, edit)
		if err:
			ui.error(DOMAIN, err)
			if dirty:
				sublime.set_timeout(lambda: view.run_command('undo'), 0)
		elif dirty:
			k = 'last_import_path.%s' % vu.V(view).vfn()
			if added_path:
				gs.set_attr(k, added_path)
			else:
				gs.del_attr(k)
Exemple #4
0
	def run(self, edit):
		vsize = self.view.size()
		src = self.view.substr(sublime.Region(0, vsize))
		if not src.strip():
			return

		src, err = mg9.fmt(self.view.file_name(), src)
		if err:
			gs.println(DOMAIN, "cannot fmt file. error: `%s'" % err)
			return

		if not src.strip():
			return

		_, err = gspatch.merge(self.view, vsize, src, edit)
		if err:
			msg = 'PANIC: Cannot fmt file. Check your source for errors (and maybe undo any changes).'
			sublime.error_message("%s: %s: Merge failure: `%s'" % (DOMAIN, msg, err))
Exemple #5
0
	def run(self, edit):
		vsize = self.view.size()
		src = self.view.substr(sublime.Region(0, vsize))
		if not src.strip():
			return

		src, err = mg9.fmt(self.view.file_name(), src)
		if err:
			gs.println(DOMAIN, "cannot fmt file. error: `%s'" % err)
			return

		if not src.strip():
			gs.println(DOMAIN, "cannot fmt file. it appears to be empty")
			return

		_, err = gspatch.merge(self.view, vsize, src, edit)
		if err:
			msg = 'PANIC: Cannot fmt file. Check your source for errors (and maybe undo any changes).'
			sublime.error_message("%s: %s: Merge failure: `%s'" % (DOMAIN, msg, err))