From f3754c922d88b9aab2dfb7c919634afbc060dda6 Mon Sep 17 00:00:00 2001 From: Dominik Jain Date: Fri, 17 Jul 2026 05:03:52 +0200 Subject: [PATCH] Improve documentation of line ending handling --- CHANGELOG.md | 3 ++- src/solidlsp/ls_utils.py | 7 +++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index a001291c..e8e3ac1d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -37,7 +37,8 @@ Status of the `main` branch. Changes prior to the next official version change w - During project creation, language composition percentages are now computed relative to the total number of recognised source files instead of all files, i.e. unrecognised files are ignored in the percentage computation. - - Fix: Use LSP-compliant line splitting ("\n", "\r\n" and "\r" can define line breaks); previously only "\n" considered + - Consider all LSP-compliant line endings ("\n", "\r\n" and "\r") in `TextUtils`, noting that + only "\n" appears in files read by `FileUtils.read_file` (Serena's default reading mechanism) - Fix: Apply consistent line splitting across tools, uniformly applying the LSP splitting semantics; affects `search_text` used by `search_for_pattern` tool (reported in #1684) - Fix in `TextUtils` (used by editors): Deleting up to the end of the file, referencing the line one past diff --git a/src/solidlsp/ls_utils.py b/src/solidlsp/ls_utils.py index d95723ad..b87355bd 100644 --- a/src/solidlsp/ls_utils.py +++ b/src/solidlsp/ls_utils.py @@ -32,6 +32,13 @@ class InvalidTextLocationError(Exception): class TextStepper: + r""" + A utility class for stepping through a text string line by line, keeping track of the current line and column numbers. + + It handles the newline sequences "\n", "\r\n", and "\r" as defined by the Language Server Protocol (LSP). + However, note that files read through `FileUtils.read_file` will contain only "\n" (LF). + """ + def __init__(self, chars: str): self._chars = chars self._len = len(chars)