From 84e6d2da90b70691451d306ac8f0c772eaf938f2 Mon Sep 17 00:00:00 2001 From: eusebiu Date: Tue, 19 Oct 2010 23:01:21 +0300 Subject: [PATCH] Fix SD-1739 - Creating WPF event handler switches to text editor but does not scroll to correct line --- .../XamlBinding/XamlCompletionItemList.cs | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/src/AddIns/BackendBindings/XamlBinding/XamlBinding/XamlCompletionItemList.cs b/src/AddIns/BackendBindings/XamlBinding/XamlBinding/XamlCompletionItemList.cs index 39cf840c52..767f1ab01a 100644 --- a/src/AddIns/BackendBindings/XamlBinding/XamlBinding/XamlCompletionItemList.cs +++ b/src/AddIns/BackendBindings/XamlBinding/XamlBinding/XamlCompletionItemList.cs @@ -194,10 +194,22 @@ namespace ICSharpCode.XamlBinding IFileDocumentProvider document = viewContent as IFileDocumentProvider; if (viewContent != null && document != null) { - if (lastMember != null) + DomRegion domRegion; + + if (lastMember != null) { unit.ProjectContent.Language.CodeGenerator.InsertCodeAfter(lastMember, new RefactoringDocumentAdapter(document.GetDocumentForFile(viewContent.PrimaryFile)), node); - else + domRegion = lastMember.BodyRegion; + } + else { unit.ProjectContent.Language.CodeGenerator.InsertCodeAtEnd(part.Region, new RefactoringDocumentAdapter(document.GetDocumentForFile(viewContent.PrimaryFile)), node); + domRegion = part.Region; + } + + // move caret to generated code + ITextEditorProvider provider = viewContent as ITextEditorProvider; + if (provider != null) { + provider.TextEditor.JumpTo(domRegion.EndLine + 2, domRegion.EndColumn - 1); + } } return true; }