[gedit-plugins] Fixed goto module of commander



commit f2a7b5a63138c6009a6e55d8beab1ff74370e1e4
Author: Jesse van den Kieboom <jesse icecrew nl>
Date:   Sat Mar 13 20:57:14 2010 +0100

    Fixed goto module of commander
    
    Hide the commander when done. Properly clip the line and column
    numbers  and scroll to iter

 plugins/commander/modules/goto.py |   25 ++++++++++++++++---------
 1 files changed, 16 insertions(+), 9 deletions(-)
---
diff --git a/plugins/commander/modules/goto.py b/plugins/commander/modules/goto.py
index e150162..72ac13c 100644
--- a/plugins/commander/modules/goto.py
+++ b/plugins/commander/modules/goto.py
@@ -1,12 +1,16 @@
 """Goto specific places in the document"""
 import os
+
 import commander.commands as commands
+import commander.commands.completion
+import commander.commands.result
+import commander.commands.exceptions
 
 __commander_module__ = True
 
-def __default__(view, line, column=0):
+def __default__(view, line, column=1):
 	"""Goto line number"""
-	
+
 	buf = view.get_buffer()
 	ins = buf.get_insert()
 	citer = buf.get_iter_at_mark(ins)
@@ -21,14 +25,17 @@ def __default__(view, line, column=0):
 		
 		column = int(column) - 1
 	except ValueError:
-		raise commands.exceptions.Execute('Please specify a valid line number')
+		raise commander.commands.exceptions.Execute('Please specify a valid line number')
+
+	linnum = min(max(0, linnum), buf.get_line_count() - 1)
+	citer = buf.get_iter_at_line(linnum)
 
-	linnum = max(0, linnum)
-	column = max(0, column)
+	column = min(max(0, column), citer.get_chars_in_line() - 1)
 
 	citer = buf.get_iter_at_line(linnum)
 	citer.forward_chars(column)
-	
-	buf.move_mark(ins, citer)
-	buf.move_mark(buf.get_selection_bound(), buf.get_iter_at_mark(ins))
-	return False
+
+	buf.place_cursor(citer)
+	view.scroll_to_iter(citer, 0.0, True)
+
+	return commander.commands.result.HIDE



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]