From 2902497f425ee90a62a87dd22981b5754ecf3cab Mon Sep 17 00:00:00 2001 From: Nikita Gryzlov Date: Wed, 30 Oct 2019 20:21:40 +0300 Subject: [PATCH] =?UTF-8?q?Fix=20#520=20=D0=A2=D0=B5=D0=BA=D1=81=D1=82?= =?UTF-8?q?=D1=8B=20=D0=BA=D0=BE=D0=BC=D0=BC=D0=B5=D0=BD=D1=82=D0=B0=D1=80?= =?UTF-8?q?=D0=B8=D0=B5=D0=B2=20=D0=BF=D1=80=D0=B8=20=D1=84=D0=BE=D1=80?= =?UTF-8?q?=D0=BC=D0=B0=D1=82=D0=B8=D1=80=D0=BE=D0=B2=D0=B0=D0=BD=D0=B8?= =?UTF-8?q?=D0=B8=20=D0=B4=D0=BE=D0=BB=D0=B6=D0=BD=D1=8B=20=D0=BE=D0=B1?= =?UTF-8?q?=D1=80=D0=B5=D0=B7=D0=B0=D1=82=D1=8C=D1=81=D1=8F=20=D1=81=D0=BF?= =?UTF-8?q?=D1=80=D0=B0=D0=B2=D0=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .editorconfig | 2 ++ .../bsl/languageserver/providers/FormatProvider.java | 6 +++++- src/test/resources/providers/format.bsl | 5 +++++ src/test/resources/providers/format_formatted.bsl | 5 +++++ 4 files changed, 17 insertions(+), 1 deletion(-) diff --git a/.editorconfig b/.editorconfig index 2baa238e0a8..152daa216e5 100644 --- a/.editorconfig +++ b/.editorconfig @@ -1,2 +1,4 @@ [src/test/resources/providers/format_formatted.bsl] trim_trailing_whitespace = false +[src/test/resources/providers/format.bsl] +trim_trailing_whitespace = false diff --git a/src/main/java/com/github/_1c_syntax/bsl/languageserver/providers/FormatProvider.java b/src/main/java/com/github/_1c_syntax/bsl/languageserver/providers/FormatProvider.java index 46c814286c7..4174e38b828 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/languageserver/providers/FormatProvider.java +++ b/src/main/java/com/github/_1c_syntax/bsl/languageserver/providers/FormatProvider.java @@ -230,7 +230,11 @@ private static List getTextEdits( // no-op } - newTextBuilder.append(token.getText()); + String addedText = token.getText(); + if (tokenType == BSLLexer.LINE_COMMENT || tokenType == BSLLexer.PREPROC_LINE_COMMENT) { + addedText = addedText.trim(); + } + newTextBuilder.append(addedText); // Increment on operator starts and left paren if (needIncrementIndent(tokenType)) { diff --git a/src/test/resources/providers/format.bsl b/src/test/resources/providers/format.bsl index d6ce912d197..78c2e8c7622 100644 --- a/src/test/resources/providers/format.bsl +++ b/src/test/resources/providers/format.bsl @@ -25,3 +25,8 @@ Процедура Другая() А = 0; КонецПроцедуры + +Процедура Третья() + // Комментарий с пробелами слева + // Другой комментарий с пробелами +КонецПроцедуры diff --git a/src/test/resources/providers/format_formatted.bsl b/src/test/resources/providers/format_formatted.bsl index 139eb7e2fd1..a7fafa8a5c0 100644 --- a/src/test/resources/providers/format_formatted.bsl +++ b/src/test/resources/providers/format_formatted.bsl @@ -25,3 +25,8 @@ Процедура Другая() А = 0; КонецПроцедуры + +Процедура Третья() + // Комментарий с пробелами слева + // Другой комментарий с пробелами +КонецПроцедуры