234
234
tracker.Engine.CurrentStateLength, previousChar, currentChar, forced);
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) {
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 ();
250
using (var undo = buf.OpenUndoGroup ()) {
251
buf.InsertText (buf.CursorPosition, tag);
252
buf.CursorPosition -= tag.Length;
255
// if (wasInAtomicUndo)
256
// this.Editor.Document.BeginAtomicUndo ();
260
CompletionDataList cp = new CompletionDataList ();
261
cp.Add (new XmlTagCompletionData (tag, 0, true));
237
if (tracker.Engine.CurrentState is XmlFreeState && currentChar == '>')
238
return ClosingTagCompletion (buf, currentLocation);
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
369
protected virtual ICompletionDataList ClosingTagCompletion (IEditableTextBuffer buf, TextLocation currentLocation)
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) {
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 ();
383
using (var undo = buf.OpenUndoGroup ()) {
384
buf.InsertText (buf.CursorPosition, tag);
385
buf.CursorPosition -= tag.Length;
388
// if (wasInAtomicUndo)
389
// this.Editor.Document.BeginAtomicUndo ();
393
CompletionDataList cp = new CompletionDataList ();
394
cp.Add (new XmlTagCompletionData (tag, 0, true));
397
401
protected virtual void GetElementCompletions (CompletionDataList list)