From f28a32747bec3a210d5bb2c02648aecb6458dfae Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=91=D0=BE=D0=BD=D0=B4=D0=B0=D1=80=D0=B5=D0=B2=20=D0=98?= =?UTF-8?q?=D0=B2=D0=B0=D0=BD?= Date: Wed, 3 Oct 2018 10:36:10 +0200 Subject: [PATCH] fix #1310 --- CodeCompletion/CodeFormatter.cs | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/CodeCompletion/CodeFormatter.cs b/CodeCompletion/CodeFormatter.cs index db224989f..790828b59 100644 --- a/CodeCompletion/CodeFormatter.cs +++ b/CodeCompletion/CodeFormatter.cs @@ -243,6 +243,24 @@ namespace CodeFormatters } } + private string RemoveOverSpaces(string s) + { + if (s.IndexOf("//") != -1 || s.IndexOf("{") != -1) + return s; + StringBuilder sb = new StringBuilder(); + string[] arr = s.Split(' '); + for (int i = 0; i < arr.Length; i++) + { + if (arr[i] != "") + { + sb.Append(arr[i]); + if (i < arr.Length - 1) + sb.Append(" "); + } + } + return sb.ToString(); + } + private void WriteNode(syntax_tree_node sn) { if (sn.source_context != null) @@ -257,7 +275,7 @@ namespace CodeFormatters { int start_pos = GetPosition(sn.source_context.begin_position.line_num, sn.source_context.begin_position.column_num); int end_pos = GetPosition(sn.source_context.end_position.line_num, sn.source_context.end_position.column_num); - string node_text = prepare_comment(Text.Substring(start_pos, end_pos - start_pos + 1), false); + string node_text = prepare_comment(RemoveOverSpaces(Text.Substring(start_pos, end_pos - start_pos + 1)), false); sb.Append(node_text); }