~ubuntu-branches/ubuntu/trusty/monodevelop/trusty-proposed

« back to all changes in this revision

Viewing changes to src/core/MonoDevelop.Ide/MonoDevelop.Ide.CodeTemplates/CodeTemplate.cs

  • Committer: Package Import Robot
  • Author(s): Jo Shields
  • Date: 2013-05-12 09:46:03 UTC
  • mto: This revision was merged to the branch mainline in revision 29.
  • Revision ID: package-import@ubuntu.com-20130512094603-mad323bzcxvmcam0
Tags: upstream-4.0.5+dfsg
ImportĀ upstreamĀ versionĀ 4.0.5+dfsg

Show diffs side-by-side

added added

removed removed

Lines of Context:
282
282
                                if (result.CaretEndOffset > e.Offset)
283
283
                                        result.CaretEndOffset += delta;
284
284
                        };
285
 
                        
286
 
                        var formatter = CodeFormatterService.GetFormatter (context.Document.Editor.Document.MimeType);
287
 
                        if (formatter != null && context.Document.HasProject) {
288
 
                                formatter.OnTheFlyFormat (context.Document, 0, data.Length);
289
 
                        }
290
 
                        
 
285
 
291
286
                        IndentCode (data, context.LineIndent);
292
287
                        result.Code = data.Text;
293
288
                        data.Dispose ();
434
429
                        }
435
430
 
436
431
                        document.Editor.Caret.Location = document.Editor.OffsetToLocation (newoffset) ;
437
 
                        
438
 
/*                      if (PropertyService.Get ("OnTheFlyFormatting", false)) {
439
 
                                string mt = DesktopService.GetMimeTypeForUri (document.FileName);
440
 
                                var formatter = MonoDevelop.Ide.CodeFormatting.CodeFormatterService.GetFormatter (mt);
441
 
                                if (formatter != null && formatter.SupportsOnTheFlyFormatting) {
442
 
                                        document.Editor.Document.BeginAtomicUndo ();
443
 
                                        formatter.OnTheFlyFormat (document.Project != null ? document.Project.Policies : null, 
444
 
                                                document.Editor, offset, offset + length);
445
 
                                        document.Editor.Document.EndAtomicUndo ();
 
432
 
 
433
                        var prettyPrinter = CodeFormatterService.GetFormatter (data.MimeType);
 
434
                        if (prettyPrinter != null) {
 
435
                                int endOffset = template.InsertPosition + template.Code.Length;
 
436
                                var oldVersion = data.Version;
 
437
                                prettyPrinter.OnTheFlyFormat (document, template.InsertPosition, endOffset);
 
438
                                foreach (var textLink in template.TextLinks) {
 
439
                                        for (int i = 0; i < textLink.Links.Count; i++) {
 
440
                                                var segment = textLink.Links [i];
 
441
                                                var translatedOffset = oldVersion.MoveOffsetTo (data.Version, template.InsertPosition + segment.Offset) - template.InsertPosition;
 
442
                                                textLink.Links [i] = new TextSegment (translatedOffset, segment.Length);
 
443
                                        }
446
444
                                }
447
 
                        }*/
 
445
                        }
448
446
                        return template;
449
447
                }
450
448