Esempio n. 1
0
	def test_toggle_folding_open_multiple_all_closed(self):
		vim.feedkeys("zM")
		vim.current.window.cursor = (2, 0)
		self.assertEqual(foldclosed(2), 2)
		self.assertNotEqual(self.showhide.toggle_folding(), None)
		self.assertEqual(vim.CMDHISTORY[-1], u_encode(u'normal! 1zo'))
		self.assertEqual(vim.current.window.cursor, [2, 0])
Esempio n. 2
0
	def test_toggle_folding_open_one(self):
		vim.current.window.cursor = (10, 0)
		vim.feedkeys("zM")
		# self.assertEqual(foldclosed(10), 10)
		self.assertNotEqual(self.showhide.toggle_folding(), None)
		self.assertEqual(vim.CMDHISTORY[-1], u_encode(u'normal! 1zo'))
		self.assertEqual(vim.current.window.cursor, [10, 0])
Esempio n. 3
0
	def test_toggle_folding_open_multiple_all_closed_reverse(self):
		vim.current.window.cursor = (2, 0)
		vim.feedkeys('zM')
		self.assertEqual(foldclosed(2), 2)
		self.assertNotEqual(self.showhide.toggle_folding(reverse=True), None)
		self.assertEqual(vim.CMDHISTORY[-1], u_encode(u'2,16foldopen!'))
		self.assertEqual(vim.current.window.cursor, [2, 0])
Esempio n. 4
0
	def test_toggle_folding_close_one(self):
		vim.current.window.cursor = (13, 0)
		vim.feedkeys("zO")
		self.assertEqual(foldclosed(13), -1)
		self.assertNotEqual(self.showhide.toggle_folding(), None)
		self.assertEqual(vim.CMDHISTORY[-2], u_encode(u'13,15foldclose!'))
		self.assertEqual(vim.CMDHISTORY[-1], u_encode(u'normal! 2zo'))
		self.assertEqual(vim.current.window.cursor, [13, 0])
Esempio n. 5
0
	def test_indent_heading(self):
		line = 2
		vim.current.window.cursor = (line, 0)
		self.assertEqual(foldlevel(line), 1)
		vim.feedkeys(">>")
		self.assertEqual(foldlevel(line), 2)
		vim.feedkeys("<<")
		self.assertEqual(foldlevel(line), 1)
Esempio n. 6
0
	def test_toggle_folding_open_multiple_second_level_half_open_reverse(self):
		vim.current.window.cursor = (2, 0)
		vim.feedkeys('zR')
		self.assertEqual(foldclosed(2), -1)
		self.assertEqual(foldclosed(6), -1)
		self.assertEqual(foldclosed(10), 10)
		self.assertEqual(foldclosed(13), 13)
		self.assertEqual(foldclosed(16), 16)
		self.assertNotEqual(self.showhide.toggle_folding(reverse=True), None)
		self.assertEqual(vim.CMDHISTORY[-1], u_encode(u'normal! 6ggzc'))
		self.assertEqual(vim.current.window.cursor, [2, 0])
Esempio n. 7
0
	def test_toggle_folding_close_multiple_all_open(self):
		vim.feedkeys("zR")
		vim.current.window.cursor = (2, 0)
		self.assertEqual(foldclosed(2), -1)
		self.assertEqual(foldclosed(6), -1)
		self.assertEqual(foldclosed(10), -1)
		self.assertEqual(foldclosed(13), -1)
		self.assertEqual(foldclosed(16), -1)
		self.assertNotEqual(self.showhide.toggle_folding(), None)
		self.assertEqual(vim.CMDHISTORY[-1], u_encode(u'2,16foldclose!'))
		self.assertEqual(vim.current.window.cursor, [2, 0])
Esempio n. 8
0
	def test_toggle_folding_open_multiple_first_level_open(self):
		vim.current.window.cursor = (2, 0)
		vim.feedkeys("zM")
		vim.feedkeys("zr")
		self.assertEqual(foldclosed(2), -1)
		self.assertEqual(foldclosed(6), 6)
		self.assertEqual(foldclosed(10), 10)
		self.assertEqual(foldclosed(13), 13)
		self.assertEqual(foldclosed(16), 16)
		self.assertNotEqual(self.showhide.toggle_folding(), None)
		self.assertEqual(vim.CMDHISTORY[-2], u_encode(u'normal! 6gg1zo'))
		self.assertEqual(vim.CMDHISTORY[-1], u_encode(u'normal! 10gg1zo'))
		self.assertEqual(vim.current.window.cursor, [2, 0])
Esempio n. 9
0
	def test_toggle_folding_first_heading_with_no_children_reverse(self):
		vim.current.buffer[:] = [ u_encode(i) for i in u"""
* Überschrift 1
Text 1

Bla bla
* Überschrift 2
* Überschrift 3
  asdf sdf
""".split(u'\n') ]
		vim.current.window.cursor = (2, 0)
		vim.command("set ft=org")
		vim.feedkeys("zR")
		vim.command("2,5foldclose!")
		self.assertEqual(foldclosed(2), 2)
		self.assertEqual(foldclosed(6), -1)
		self.assertEqual(foldclosed(7), -1)

		self.assertNotEqual(self.showhide.toggle_folding(reverse=True), None)
		self.assertEqual(vim.CMDHISTORY[-1], u_encode(u'2,5foldopen!'))
		self.assertEqual(vim.current.window.cursor, [2, 0])
Esempio n. 10
0
	def setUp(self):
		global counter
		counter += 1
		vim.CMDHISTORY = []
		vim.CMDRESULTS = {}
		vim.EVALHISTORY = []
		vim.EVALRESULTS = {
				# no org_todo_keywords for b
				u_encode(u'exists("b:org_todo_keywords")'): u_encode('0'),
				# global values for org_todo_keywords
				u_encode(u'exists("g:org_todo_keywords")'): u_encode('1'),
				u_encode(u'g:org_todo_keywords'): [u_encode(u'TODO'), u_encode(u'|'), u_encode(u'DONE')],
				u_encode(u'exists("g:org_debug")'): u_encode(u'0'),
				u_encode(u'exists("g:org_debug")'): u_encode(u'0'),
				u_encode(u'exists("*repeat#set()")'): u_encode(u'0'),
				u_encode(u"v:count"): u_encode(u'0'),
				u_encode(u'b:changedtick'): u_encode(u'%d' % counter),
				u_encode(u"v:lnum"): u_encode(u'0')}
		vim.current.buffer[:] = [u_encode(i) for i in u"""
* Überschrift 1
Text 1

Bla bla
** Überschrift 1.1
Text 2

Bla Bla bla
** Überschrift 1.2
Text 3

**** Überschrift 1.2.1.falsch

Bla Bla bla bla
*** Überschrift 1.2.1
* Überschrift 2
* Überschrift 3
  asdf sdf
""".split(u'\n') ]
		vim.command("set ft=org")
		vim.feedkeys("zM")
Esempio n. 11
0
	def test_toggle_folding_first_heading_with_no_children(self):
		vim.current.buffer[:] = [u_encode(i) for i in u"""
* Überschrift 1
Text 1

Bla bla
* Überschrift 2
* Überschrift 3
  asdf sdf
""".split(u'\n') ]
		vim.command("set ft=org")

		vim.feedkeys("zR")
		for i in range(len(vim.current.buffer)):
			self.assertEqual(foldclosed(i), -1)
		vim.feedkeys("zM")
		for i, val in enumerate([-1, -1, 2, 2, 2, 2, -1, 7, 7]):
			self.assertEqual(foldclosed(i), val)

		vim.current.window.cursor = (2, 0)
		self.assertNotEqual(self.showhide.toggle_folding(), None)
		self.assertEqual(vim.CMDHISTORY[-1], u_encode(u'normal! 1zo'))
		self.assertEqual(vim.current.window.cursor, [2, 0])