From 49077e153340ed3640c2c392b9e5d3554a2a72d8 Mon Sep 17 00:00:00 2001 From: Dominik Jain Date: Fri, 20 Feb 2026 14:59:05 +0100 Subject: [PATCH] _request_document_symbols: Simplify opening of the file buffer By applying the _open_file_context context manager, we avoid the need for calling ensure_open_in_ls explicitly --- src/solidlsp/ls.py | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/src/solidlsp/ls.py b/src/solidlsp/ls.py index 7e9cd500..7dbc0938 100644 --- a/src/solidlsp/ls.py +++ b/src/solidlsp/ls.py @@ -1193,11 +1193,8 @@ class SolidLanguageServer(ABC): return response - if file_data is not None: - return get_raw_document_symbols(file_data) - else: - with self.open_file(relative_file_path) as opened_file_data: - return get_raw_document_symbols(opened_file_data) + with self._open_file_context(relative_file_path, file_buffer=file_data) as fd: + return get_raw_document_symbols(fd) def request_document_symbols(self, relative_file_path: str, file_buffer: LSPFileBuffer | None = None) -> DocumentSymbols: """ @@ -1227,7 +1224,6 @@ class SolidLanguageServer(ABC): log.debug("No cache hit for document symbols in %s", relative_file_path) # no cached result: request the root symbols from the language server - file_data.ensure_open_in_ls() root_symbols = self._request_document_symbols(relative_file_path, file_data) if root_symbols is None: