Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/monodevelop.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/main/src
diff options
context:
space:
mode:
authorLluis Sanchez <lluis@xamarin.com>2019-05-31 21:25:51 +0300
committerGitHub <noreply@github.com>2019-05-31 21:25:51 +0300
commit6ab1d7d8b428413aaf4a2187cf1c5547ca343f16 (patch)
tree20753ad0e2b78bc73510ce9ebb20fe4a658a9f53 /main/src
parent0f5d0634dd7fe8f0f3d7fb054379a6657bcbf9df (diff)
parente4912767c44a353a06d17590ba5bda52cad0a241 (diff)
Merge pull request #7756 from mono/FixControlCharIssueInLogView
Fix Application Output hang when using ASP.Net Core Angular template
Diffstat (limited to 'main/src')
-rw-r--r--main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui.Components/LogView.cs21
1 files changed, 21 insertions, 0 deletions
diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui.Components/LogView.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui.Components/LogView.cs
index df373fa756..88987cf81a 100644
--- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui.Components/LogView.cs
+++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui.Components/LogView.cs
@@ -29,6 +29,7 @@ using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Runtime.CompilerServices;
+using System.Text.RegularExpressions;
using Gtk;
using MonoDevelop.Components;
using MonoDevelop.Components.Commands;
@@ -58,6 +59,7 @@ namespace MonoDevelop.Ide.Gui.Components
QueuedTextWrite lastTextWrite;
GLib.TimeoutHandler outputDispatcher;
bool outputDispatcherRunning = false;
+ readonly Regex consoleTextSanitizerRegex = new Regex ("(\\e[[0-9]*m)|(\b)", RegexOptions.Compiled);
const int MAX_BUFFER_LENGTH = 4000 * 1024;
@@ -624,6 +626,8 @@ namespace MonoDevelop.Ide.Gui.Components
public void WriteText (LogViewProgressMonitor monitor, string text)
{
+ text = SanitizeConsoleText (text);
+
//raw text has an extra optimisation here, as we can append it to existing updates
lock (updates) {
if (lastTextWrite != null) {
@@ -693,6 +697,23 @@ namespace MonoDevelop.Ide.Gui.Components
return scrollView.Vadjustment.Value + scrollView.Vadjustment.PageSize >= scrollView.Vadjustment.Upper;
}
+ /// <summary>
+ /// This method removes ANSI/VT100 Color escape sequences from the string, along with other
+ /// control/non-printable characters. We currently do not handle control characters performantly in the
+ /// LogView, as the text rendering component tries to render a custom glyph denoting the control code. We
+ /// also do not support colorization of the output, so the color information is redundant.
+ ///
+ /// Specifically we remove color escape sequences (\e[ + color code + m) and the backspace (\b) control
+ /// character.
+ ///
+ /// </summary>
+ /// <param name="text"></param>
+ /// <returns>original text with control characters and escape sequences removed</returns>
+ string SanitizeConsoleText(string text)
+ {
+ return consoleTextSanitizerRegex.Replace (text, string.Empty);
+ }
+
protected void UnsafeAddText (TextMark mark, string text, TextTag indentTag, TextTag extraTag)
{
//don't allow the pad to hold more than MAX_BUFFER_LENGTH chars