Ejemplo n.º 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))
Ejemplo n.º 2
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))
Ejemplo n.º 3
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))