public void SetText(string text, bool isDiff = false) { _lineNumbersControl.Clear(isDiff); if (isDiff) { TextEditor.ShowLineNumbers = false; _lineNumbersControl.SetVisibility(true); var index = TextEditor.ActiveTextAreaControl.TextArea.LeftMargins.IndexOf(_lineNumbersControl); if (index == -1) { TextEditor.ActiveTextAreaControl.TextArea.InsertLeftMargin(0, _lineNumbersControl); } _diffHighlightService = DiffHighlightService.IsCombinedDiff(text) ? CombinedDiffHighlightService.Instance : DiffHighlightService.Instance; } else { TextEditor.ShowLineNumbers = true; _lineNumbersControl.SetVisibility(false); } TextEditor.Text = text; _isGotoLineUIApplicable = !isDiff; if (isDiff) { _lineNumbersControl.DisplayLineNumFor(text); } TextEditor.Refresh(); }
private static bool IsDiffLine(string wholeText, string lineContent) { var isCombinedDiff = DiffHighlightService.IsCombinedDiff(wholeText); return(lineContent.StartsWithAny(isCombinedDiff ? new[] { "+", "-", " +", " -" } : new[] { "+", "-" })); }
private string RemovePrefix(string line) { var isCombinedDiff = DiffHighlightService.IsCombinedDiff(_internalFileViewer.GetText()); var specials = isCombinedDiff ? new[] { " ", "++", "+ ", " +", "--", "- ", " -" } : new[] { " ", "-", "+" }; if (string.IsNullOrWhiteSpace(line)) { return(line); } foreach (var special in specials.Where(line.StartsWith)) { return(line.Substring(special.Length)); } return(line); }
public void SetText(string text, bool isDiff = false) { _diffHighlightService = DiffHighlightService.IsCombinedDiff(text) ? CombinedDiffHighlightService.Instance : DiffHighlightService.Instance; _lineNumbersControl.Clear(); TextEditor.Text = text; TextEditor.Refresh(); if (isDiff) { _diffLineNumAnalyzer.StartAsync(text, () => { if (TextEditor != null && !TextEditor.Disposing && TextEditor.Visible) { TextEditor.ActiveTextAreaControl.TextArea.Refresh(); } }); } }
public void SetText(string text, bool isDiff = false) { _lineNumbersControl.Clear(); if (isDiff) { TextEditor.ShowLineNumbers = false; _lineNumbersControl.SetVisibility(true); var index = TextEditor.ActiveTextAreaControl.TextArea.LeftMargins.IndexOf(_lineNumbersControl); if (index == -1) { TextEditor.ActiveTextAreaControl.TextArea.InsertLeftMargin(0, _lineNumbersControl); } _diffHighlightService = DiffHighlightService.IsCombinedDiff(text) ? CombinedDiffHighlightService.Instance : DiffHighlightService.Instance; } else { TextEditor.ShowLineNumbers = true; _lineNumbersControl.SetVisibility(false); } TextEditor.Text = text; _isGotoLineUIApplicable = !isDiff; if (isDiff) { _diffLineNumAnalyzer.StartAsync(text, () => { if (TextEditor != null && !TextEditor.Disposing && TextEditor.Visible) { TextEditor.ActiveTextAreaControl.TextArea.Refresh(); } }); } TextEditor.Refresh(); }