[MonoDevelop] [Fwd: [Mono-patches] r100941 - in trunk/monodevelop/main/src: addins/CBinding addins/CBinding/Gui addins/CSharpBinding addins/CSharpBinding/Gui addins/MonoDevelop.SourceEditor2 addins/MonoDevelop.SourceEditor2/MonoDevelop.SourceEditor addins/MonoDevelop.XmlEditor addins/MonoDevelop.XmlEditor/MonoDevelop.XmlEditor core/MonoDevelop.Ide core/MonoDevelop.Ide/MonoDevelop.Ide.Gui.Content]

Atsushi Eno atsushi at ximian.com
Thu Apr 17 23:39:27 EDT 2008


Hi Michael,

I have one liner patch that fixes bogus attempt to jump to -1 when 
trying to jump to top (HOME). Feel free to commit ;)

Atsushi Eno

Modified: trunk/monodevelop/main/src/addins/CSharpBinding/Gui/CSharpTextEditorExtension.cs
===================================================================
--- trunk/monodevelop/main/src/addins/CSharpBinding/Gui/CSharpTextEditorExtension.cs	2008-04-16 19:46:03 UTC (rev 100940)
+++ trunk/monodevelop/main/src/addins/CSharpBinding/Gui/CSharpTextEditorExtension.cs	2008-04-16 20:12:45 UTC (rev 100941)
@@ -189,9 +189,9 @@
 			base.TextChanged (startIndex, endIndex);
 		}
 		
-		public override bool KeyPress (Gdk.Key key, Gdk.ModifierType modifier)
+		public override bool KeyPress (Gdk.Key key, char keyChar, Gdk.ModifierType modifier)
 		{
-			if ((char)(uint)key == ',') {
+			if (keyChar == ',') {
 				// Parameter completion
 				if (CanRunParameterCompletionCommand ())
 					RunParameterCompletionCommand ();
@@ -209,13 +209,12 @@
 				bool hadSelection = Editor.SelectionEndPosition != Editor.SelectionStartPosition;
 				
 				//pass through to the base class, which actually inserts the character
-				bool retval = base.KeyPress (key, modifier);
+				bool retval = base.KeyPress (key, keyChar, modifier);
 				UpdateSmartIndentEngine ();
 				
 				//handle inserted characters
 				bool reIndent = false;
-				char lastCharInserted = KeyToChar (key);
-				//System.Console.WriteLine (lastCharInserted);
+				char lastCharInserted = TranslateKeyCharForIndenter (key, keyChar, Editor.GetCharAt (Editor.CursorPosition - 1));
 				if (!(oldLine == Editor.CursorLine && lastCharInserted == '\n') && (oldBufLen != Editor.TextLength || lastCharInserted != '\0'))
 					DoPostInsertionSmartIndent (lastCharInserted, hadSelection, out reIndent);
 				
@@ -227,20 +226,24 @@
 					DoReSmartIndent ();
 				return retval;
 			}
-			return base.KeyPress (key, modifier);
+			return base.KeyPress (key, keyChar, modifier);
 		}
 		
-		char KeyToChar (Gdk.Key key)
+		static char TranslateKeyCharForIndenter (Gdk.Key key, char keyChar, char docChar)
 		{
+			char c = keyChar;
 			switch (key) {
+			case Gdk.Key.Return:
+			case Gdk.Key.KP_Enter:
+				return '\n';
 			case Gdk.Key.Tab:
 				return '\t';
-			case Gdk.Key.KP_Enter:
-			case Gdk.Key.Return:
-				return '\n';
 			default:
-				return (char) Gdk.Keyval.ToUnicode ((uint)key);
+				if (docChar == keyChar)
+					return keyChar;
+				break;
 			}
+			return '\0';
 		}
 		
 		void ResetSmartIndentEngineToCursor (int cursor)



-------------- next part --------------
A non-text attachment was scrubbed...
Name: csharptexteditor-jumptotop.patch
Type: text/x-patch
Size: 876 bytes
Desc: not available
Url : http://lists.ximian.com/pipermail/monodevelop-list/attachments/20080418/fa2fd7e7/attachment.bin 


More information about the Monodevelop-list mailing list