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

« back to all changes in this revision

Viewing changes to src/addins/MonoDevelop.XmlEditor/MonoDevelop.XmlEditor.Gui/BaseXmlEditorExtension.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:
234
234
                                tracker.Engine.CurrentStateLength, previousChar, currentChar, forced);
235
235
                        
236
236
                        //closing tag completion
237
 
                        if (tracker.Engine.CurrentState is XmlFreeState && currentChar == '>') {
238
 
                                //get name of current node in document that's being ended
239
 
                                XElement el = tracker.Engine.Nodes.Peek () as XElement;
240
 
                                if (el != null && el.Region.End >= currentLocation && !el.IsClosed && el.IsNamed) {
241
 
                                        string tag = String.Concat ("</", el.Name.FullName, ">");
242
 
                                        if (XmlEditorOptions.AutoCompleteElements) {
243
 
                                                
244
 
//                                              //make sure we have a clean atomic undo so the user can undo the tag insertion
245
 
//                                              //independently of the >
246
 
//                                              bool wasInAtomicUndo = this.Editor.Document.IsInAtomicUndo;
247
 
//                                              if (wasInAtomicUndo)
248
 
//                                                      this.Editor.Document.EndAtomicUndo ();
249
 
                                                
250
 
                                                using (var undo = buf.OpenUndoGroup ()) {
251
 
                                                        buf.InsertText (buf.CursorPosition, tag);
252
 
                                                        buf.CursorPosition -= tag.Length;
253
 
                                                }
254
 
                                                
255
 
//                                              if (wasInAtomicUndo)
256
 
//                                                      this.Editor.Document.BeginAtomicUndo ();
257
 
                                                
258
 
                                                return null;
259
 
                                        } else {
260
 
                                                CompletionDataList cp = new CompletionDataList ();
261
 
                                                cp.Add (new XmlTagCompletionData (tag, 0, true));
262
 
                                                return cp;
263
 
                                        }
264
 
                                }
265
 
                                return null;
266
 
                        }
 
237
                        if (tracker.Engine.CurrentState is XmlFreeState && currentChar == '>')
 
238
                                return ClosingTagCompletion (buf, currentLocation);
267
239
                        
268
240
                        // Auto insert '>' when '/' is typed inside tag state (for quick tag closing)
269
241
                        //FIXME: avoid doing this when the next non-whitespace char is ">" or ignore the next ">" typed
392
364
                        }
393
365
                        
394
366
                        return null;
 
367
                }
 
368
 
 
369
                protected virtual ICompletionDataList ClosingTagCompletion (IEditableTextBuffer buf, TextLocation currentLocation)
 
370
                {
 
371
                        //get name of current node in document that's being ended
 
372
                        XElement el = tracker.Engine.Nodes.Peek () as XElement;
 
373
                        if (el != null && el.Region.End >= currentLocation && !el.IsClosed && el.IsNamed) {
 
374
                                string tag = String.Concat ("</", el.Name.FullName, ">");
 
375
                                if (XmlEditorOptions.AutoCompleteElements) {
 
376
 
 
377
                                        //                                              //make sure we have a clean atomic undo so the user can undo the tag insertion
 
378
                                        //                                              //independently of the >
 
379
                                        //                                              bool wasInAtomicUndo = this.Editor.Document.IsInAtomicUndo;
 
380
                                        //                                              if (wasInAtomicUndo)
 
381
                                        //                                                      this.Editor.Document.EndAtomicUndo ();
 
382
 
 
383
                                        using (var undo = buf.OpenUndoGroup ()) {
 
384
                                                buf.InsertText (buf.CursorPosition, tag);
 
385
                                                buf.CursorPosition -= tag.Length;
 
386
                                        }
 
387
 
 
388
                                        //                                              if (wasInAtomicUndo)
 
389
                                        //                                                      this.Editor.Document.BeginAtomicUndo ();
 
390
 
 
391
                                        return null;
 
392
                                } else {
 
393
                                        CompletionDataList cp = new CompletionDataList ();
 
394
                                        cp.Add (new XmlTagCompletionData (tag, 0, true));
 
395
                                        return cp;
 
396
                                }
 
397
                        }
 
398
                        return null;
395
399
                }
396
400
                
397
401
                protected virtual void GetElementCompletions (CompletionDataList list)