void HandleTextReplaced(object sender, MonoDevelop.Core.Text.TextChangeEventArgs e)
 {
     for (int i = 0; i < e.TextChanges.Count; ++i)
     {
         var change = e.TextChanges[i];
         stateTracker.ResetEngineToPosition(Editor, change.NewOffset);
         if (wasInVerbatimString == null)
         {
             return;
         }
         if (change.RemovalLength != 1 /*|| textEditorData.Document.CurrentAtomicUndoOperationType == OperationType.Format*/)
         {
             return;
         }
         SafeUpdateIndentEngine(Math.Min(Editor.Length, change.NewOffset + change.InsertionLength + 1));
         if (wasInVerbatimString == true && !stateTracker.IsInsideVerbatimString)
         {
             Editor.TextChanging -= HandleTextReplacing;
             Editor.TextChanged  -= HandleTextReplaced;
             ConvertVerbatimStringToNormal(Editor, change.NewOffset + change.InsertionLength + 1);
             Editor.TextChanging += HandleTextReplacing;
             Editor.TextChanged  += HandleTextReplaced;
         }
     }
 }
		/// <summary>
		/// Replaces the current version with a new version.
		/// </summary>
		/// <param name="change">Change from current version to new version</param>
		public void AppendChange (TextChangeEventArgs change)
		{
			if (change == null)
				throw new ArgumentNullException ("change");
			currentVersion.change = change;
			currentVersion.next = new Version (currentVersion);
			currentVersion = currentVersion.next;
		}
 void Editor_TextChanged(object sender, MonoDevelop.Core.Text.TextChangeEventArgs e)
 {
     if (Editor.IsInAtomicUndo)
     {
         return;
     }
     RemoveWidget();
     HandleCaretPositionChanged(null, EventArgs.Empty);
 }
Exemplo n.º 4
0
        void HandleTextReplacing(object sender, MonoDevelop.Core.Text.TextChangeEventArgs e)
        {
            var handler = TextChanged;

            if (handler != null)
            {
                var oldText = CurrentText;
                var newText = oldText.Replace(e.Offset, e.RemovalLength, e.InsertedText.Text);
                handler(this, new Microsoft.CodeAnalysis.Text.TextChangeEventArgs(oldText, newText, new TextChangeRange(TextSpan.FromBounds(e.Offset, e.Offset + e.RemovalLength), e.InsertionLength)));
            }
        }
Exemplo n.º 5
0
        void Doc_TextChanging(object sender, MonoDevelop.Core.Text.TextChangeEventArgs e)
        {
            var lineSegment = LineSegment.Segment;

            for (int i = 0; i < e.TextChanges.Count; ++i)
            {
                var change = e.TextChanges[i];
                if (lineSegment.IsInside(change.Offset) || lineSegment.IsInside(change.Offset + change.RemovalLength) ||
                    change.Offset <= lineSegment.Offset && lineSegment.Offset <= change.Offset + change.RemovalLength)
                {
                    doc.RemoveMarker(this);
                }
            }
        }
Exemplo n.º 6
0
 public static ISegment AdjustSegment(this ISegment segment, TextChangeEventArgs args)
 {
     if (segment == null)
     {
         throw new ArgumentNullException("segment");
     }
     if (args.Offset < segment.Offset)
     {
         return(new TextSegment(segment.Offset + args.InsertionLength - args.RemovalLength, segment.Length));
     }
     if (args.Offset <= segment.EndOffset)
     {
         return(new TextSegment(segment.Offset, segment.Length));
     }
     return(segment);
 }
        void HandleTextReplacing(object sender, MonoDevelop.Core.Text.TextChangeEventArgs e)
        {
            wasInVerbatimString = null;
            var o = e.Offset + e.RemovalLength;

            if (o < 0 || o + 1 > Editor.Length || e.RemovalLength != 1 /* || textEditorData.Document.IsInUndo*/)
            {
                return;
            }
            if (Editor.GetCharAt(o) != '"')
            {
                return;
            }
            SafeUpdateIndentEngine(o + 1);
            wasInVerbatimString = stateTracker.IsInsideVerbatimString;
        }
 void HandleTextReplacing(object sender, MonoDevelop.Core.Text.TextChangeEventArgs e)
 {
     wasInVerbatimString = null;
     for (int i = 0; i < e.TextChanges.Count; ++i)
     {
         var change = e.TextChanges[i];
         var o      = change.Offset + change.RemovalLength;
         if (o < 0 || o + 1 > Editor.Length || change.RemovalLength != 1 /* || textEditorData.Document.IsInUndo*/)
         {
             continue;
         }
         if (Editor.GetCharAt(o) != '"')
         {
             continue;
         }
         SafeUpdateIndentEngine(o + 1);
         wasInVerbatimString = stateTracker.IsInsideVerbatimString;
     }
 }
        // Handles text modifications in hidden document
        void UnderlyingDocument_TextReplacing(object sender, MonoDevelop.Core.Text.TextChangeEventArgs e)
        {
            if (razorDocument == null)
            {
                return;
            }

            EnsureUnderlyingDocumentSet();
            foreach (var change in e.TextChanges.Reverse())
            {
                int off = CalculateCaretPosition(change.Offset);

                if (change.RemovalLength > 0)
                {
                    int removalLength = change.RemovalLength;
                    if (off + removalLength > HiddenDoc.Editor.Length)
                    {
                        removalLength = HiddenDoc.Editor.Length - off;
                    }
                    HiddenDoc.Editor.RemoveText(off, removalLength);
                }
                if (change.InsertionLength > 0)
                {
                    if (isInCSharpContext)
                    {
                        HiddenDoc.Editor.InsertText(off, change.InsertedText.Text);
                        HiddenDoc.HiddenAnalysisDocument = HiddenDoc.HiddenAnalysisDocument.WithText(Microsoft.CodeAnalysis.Text.SourceText.From(HiddenDoc.Editor.Text));
                    }
                    else                       // Insert spaces to correctly calculate offsets until next reparse
                    {
                        HiddenDoc.Editor.InsertText(off, new String(' ', change.InsertionLength));
                    }
                }
                if (codeFragment != null)
                {
                    codeFragment.EndOffset += (change.InsertionLength - change.RemovalLength);
                }
            }
        }
Exemplo n.º 10
0
		void HandleTextChanging (object sender, TextChangeEventArgs e)
		{
			foreach (var segment in originalProjections) {
				if (segment.Contains (e.Offset)) {
					var projectedOffset = e.Offset - segment.Offset + segment.LinkedTo.Offset;
					projectedEditor.ReplaceText (projectedOffset, e.RemovalLength, e.InsertedText);
				}
			}

			originalProjections.UpdateOnTextReplace (sender, e);
		}
Exemplo n.º 11
0
        void TrackDocument_TextChanged(object sender, MonoDevelop.Core.Text.TextChangeEventArgs e)
        {
            if (lineStates == null || e.TextChanges.Count == 0)
            {
                return;
            }
            for (int i = e.TextChanges.Count - 1; i >= 0; i--)
            {
                var change = e.TextChanges [i];
                if (change.RemovalLength == 0)
                {
                    continue;
                }

                var startLine     = trackDocumentSnapshot.GetLineByOffset(change.Offset);
                var endRemoveLine = trackDocumentSnapshot.GetLineByOffset(change.Offset + change.RemovalLength);
                if (startLine == null || endRemoveLine == null)
                {
                    continue;
                }
                try {
                    var lineNumber = startLine.LineNumber;
                    lineStates.RemoveRange(lineNumber, endRemoveLine.LineNumber - lineNumber);
                } catch (Exception ex) {
                    LoggingService.LogError("error while DiffTracker.TrackDocument_TextChanged changing update", ex);
                }
            }

            for (int i = 0; i < e.TextChanges.Count; ++i)
            {
                var change        = e.TextChanges[i];
                var startLine     = trackDocument.GetLineByOffset(change.NewOffset);
                var endLine       = trackDocument.GetLineByOffset(change.NewOffset + change.InsertionLength);
                var lineNumber    = startLine.LineNumber;
                var insertedLines = endLine.LineNumber - lineNumber;
                if (insertedLines == 0)
                {
                    var oldState = lineNumber < lineStates.Count ? lineStates [lineNumber] : null;
                    if (oldState != null && oldState.state == TextDocument.LineState.Dirty)
                    {
                        continue;
                    }
                    lineStates[lineNumber] = LineChangeInfo.Dirty;
                    if (trackDocument != null)
                    {
                        trackDocument.CommitMultipleLineUpdate(lineNumber, lineNumber + insertedLines);
                    }
                    continue;
                }
                try {
                    lineStates.InsertRange(lineNumber, insertedLines, LineChangeInfo.Dirty);
                    if (trackDocument != null)
                    {
                        trackDocument.CommitMultipleLineUpdate(lineNumber, lineNumber + insertedLines);
                    }
                } catch (Exception ex) {
                    LoggingService.LogError("error while DiffTracker.TrackDocument_TextChanged changed update", ex);
                }
            }
            trackDocumentSnapshot = trackDocument.CreateDocumentSnapshot();
        }
Exemplo n.º 12
0
 void HandleTextChanged(object sender, MonoDevelop.Core.Text.TextChangeEventArgs e)
 {
     InformAutoSave();
 }
Exemplo n.º 13
0
		void DocumentTextReplaced (object sender, TextChangeEventArgs e)
		{
			List<string> vars = template.ParseVariables (textEditor.Text);
			foreach (string var in vars) {
				if (!variables.Any (v => v.Name == var) && !template.Variables.Any (v => v.Name == var)) {
					variables.Add (new CodeTemplateVariable (var) {
						Default = GettextCatalog.GetString ("notset")
					});
				}
			}
			for (int i = 0; i < variables.Count; i++) {
				CodeTemplateVariable var = variables[i];
				if (!vars.Any (v => v == var.Name)) {
					variables.RemoveAt (i);
					i--;
				}
			}
			this.UpdateVariables ();
		}
Exemplo n.º 14
0
 public static IEnumerable <ISegment> AdjustSegments(this IEnumerable <ISegment> segments, TextChangeEventArgs args)
 {
     if (segments == null)
     {
         throw new ArgumentNullException("segments");
     }
     foreach (var segment in segments)
     {
         yield return(segment.AdjustSegment(args));
     }
 }
		// Handles text modifications in hidden document
		void UnderlyingDocument_TextReplacing (object sender, TextChangeEventArgs e)
		{
			if (razorDocument == null)
				return;

			EnsureUnderlyingDocumentSet ();
			int off = CalculateCaretPosition (e.Offset);

			if (e.RemovalLength > 0) {
				int removalLength = e.RemovalLength;
				if (off + removalLength > HiddenDoc.Editor.Length)
					removalLength = HiddenDoc.Editor.Length - off;
				HiddenDoc.Editor.RemoveText (off, removalLength);
			}
			if (e.InsertionLength > 0) {
				if (isInCSharpContext) {
					HiddenDoc.Editor.InsertText (off, e.InsertedText.Text);
					HiddenDoc.HiddenAnalysisDocument = HiddenDoc.HiddenAnalysisDocument.WithText (Microsoft.CodeAnalysis.Text.SourceText.From (HiddenDoc.Editor.Text));
				} else // Insert spaces to correctly calculate offsets until next reparse
					HiddenDoc.Editor.InsertText (off, new String (' ', e.InsertionLength));
			}
			if (codeFragment != null)
				codeFragment.EndOffset += (e.InsertionLength - e.RemovalLength);
		}
Exemplo n.º 16
0
 void Editor_TextChanged(object sender, md.Core.Text.TextChangeEventArgs e)
 {
     Preview.Update();
 }
		void HandleTextChanged (object sender, TextChangeEventArgs e)
		{
			InformAutoSave ();
		}