File tree Expand file tree Collapse file tree 4 files changed +18
-1
lines changed
main/java/com/github/_1c_syntax/bsl/languageserver/context
java/com/github/_1c_syntax/bsl/languageserver/context Expand file tree Collapse file tree 4 files changed +18
-1
lines changed Original file line number Diff line number Diff line change 44* .md eol =lf
55* .json eol =lf
66* .bat eol =crlf
7+ src /test /resources /context /DocumentContextBrokenLineFeeds.bsl binary
Original file line number Diff line number Diff line change 6565import java .util .Map ;
6666import java .util .Optional ;
6767import java .util .concurrent .locks .ReentrantLock ;
68+ import java .util .regex .Pattern ;
6869import java .util .stream .Collectors ;
6970
7071import static java .util .Objects .requireNonNull ;
7576@ RequiredArgsConstructor
7677public class DocumentContext {
7778
79+ private static final Pattern CONTENT_SPLIT_PATTERN = Pattern .compile ("\r ?\n |\r " );
80+
7881 private final URI uri ;
7982
8083 @ Nullable
@@ -315,7 +318,7 @@ private static FileType computeFileType(URI uri) {
315318 }
316319
317320 private String [] computeContentList () {
318- return getContent () .split (" \n " , -1 );
321+ return CONTENT_SPLIT_PATTERN .split (getContent () , -1 );
319322 }
320323
321324 private SymbolTree computeSymbolTree () {
Original file line number Diff line number Diff line change @@ -216,6 +216,18 @@ void testContentList() {
216216 assertThat (contentList ).hasSize (40 );
217217 }
218218
219+ @ Test
220+ void testContentListWithStandaloneCR () {
221+ // given
222+ var documentContext = getDocumentContext ("./src/test/resources/context/DocumentContextBrokenLineFeeds.bsl" );
223+
224+ // when
225+ var contentList = documentContext .getContentList ();
226+
227+ // then
228+ assertThat (contentList ).hasSize (3 );
229+ }
230+
219231 @ Test
220232 void testEOF () {
221233 // given
Original file line number Diff line number Diff line change 1+ ПереводCR ЕщеОдинCR
You can’t perform that action at this time.
0 commit comments