From 64c1a1cb6f10bce916e546089930b4aac51f10da Mon Sep 17 00:00:00 2001 From: Sebastian Serth Date: Sun, 24 Sep 2023 15:38:58 +0200 Subject: [PATCH] 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). --- lib/runner/connection/buffer.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/runner/connection/buffer.rb b/lib/runner/connection/buffer.rb index dcd01169..72df996d 100644 --- a/lib/runner/connection/buffer.rb +++ b/lib/runner/connection/buffer.rb @@ -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 = +''