Connection::Buffer: Handle Python doc string correctly

In Python, a so-called doc string consists of a string encoded in three quote (starting and ending with """ or '''). These strings were not yet recognized correctly, so that line breaks there would cause further trouble with recognizing individual lines (which is important for the linter translation).
This commit is contained in:
Sebastian Serth
2023-09-24 15:38:58 +02:00
parent 968fd5b864
commit 64c1a1cb6f

View File

@ -6,7 +6,7 @@ class Runner::Connection::Buffer
# substring either in single or double quotes (e.g., within a JSON). Originally, each line break consists of `\r\n`.
# We keep the `\r` at the end of the line (keeping "empty" lines) and replace it after buffering.
# Inspired by https://stackoverflow.com/questions/13040585/split-string-by-spaces-properly-accounting-for-quotes-and-backslashes-ruby
SPLIT_INDIVIDUAL_LINES = /(?:"(?:\\"|[^"])*"|'(?:\\'|[^'])*'|(?:[^\r\n]|\r(?=\n)))+/
SPLIT_INDIVIDUAL_LINES = /(?:"""(?:\\"|[^"])*"""|"(?!"")(?:\\"|[^"])*"|''(?:\\'|[^'])*'''|'(?!'')(?:\\'|[^'])*'|(?:[^\r\n]|\r(?=\n)))+/
def initialize
@global_buffer = +''