Skip to content

Commit 9d64931

Browse files
authored
Issue #1348 Vue rename_symbol fix (#1355)
Edits in vue files need to be propagated to the TS LS, e.g. for cross-language renames
1 parent 7a0d142 commit 9d64931

2 files changed

Lines changed: 69 additions & 1 deletion

File tree

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@ Status of the `main` branch. Changes prior to the next official version change w
1010
* Dependencies:
1111
- `pywebview`: Switch back to official release (new version 6.2) #1253
1212

13+
* Language Servers:
14+
- Fix: `rename_symbol` for Vue files now correctly propagates edits to the TypeScript server, enabling cross-file renames in `.vue` files
15+
1316
# v1.1.2 (2026-04-14)
1417

1518
* General:

src/solidlsp/language_servers/vue_language_server.py

Lines changed: 66 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@
88
import pathlib
99
import shutil
1010
import threading
11-
from pathlib import Path
11+
from collections.abc import Callable
12+
from pathlib import Path, PurePath
1213
from time import sleep
1314
from typing import Any
1415

@@ -425,6 +426,70 @@ def request_rename_symbol_edit(self, relative_file_path: str, line: int, column:
425426
with self._ts_server.open_file(relative_file_path):
426427
return self._ts_server.request_rename_symbol_edit(relative_file_path, line, column, new_name)
427428

429+
def _forward_edit_to_ts_server_if_needed(self, relative_file_path: str, edit_fn: Callable[[], object]) -> None:
430+
"""
431+
Calls ``edit_fn`` on the TypeScript server if the file is open there.
432+
433+
Only applicable to non-TypeScript files (i.e. .vue files) that have been
434+
indexed on the TypeScript server for cross-file reference support.
435+
436+
:param relative_file_path: the relative path of the file that was edited
437+
:param edit_fn: callable that performs the corresponding edit on ``_ts_server``
438+
"""
439+
if self._ts_server is None or not self._ts_server_started:
440+
return
441+
if self._is_typescript_file(relative_file_path):
442+
return
443+
444+
absolute_file_path = str(PurePath(self.repository_root_path, relative_file_path))
445+
uri = pathlib.Path(absolute_file_path).as_uri()
446+
if uri in self._ts_server.open_file_buffers:
447+
edit_fn()
448+
449+
@override
450+
def insert_text_at_position(self, relative_file_path: str, line: int, column: int, text_to_be_inserted: str) -> ls_types.Position:
451+
"""
452+
Inserts text at the given position, forwarding the change to the TypeScript server if it has the file open.
453+
454+
:param relative_file_path: the relative path of the file to edit
455+
:param line: the line number
456+
:param column: the column number
457+
:param text_to_be_inserted: the text to insert
458+
:return: updated cursor position
459+
"""
460+
result = super().insert_text_at_position(relative_file_path, line, column, text_to_be_inserted)
461+
self._forward_edit_to_ts_server_if_needed(
462+
relative_file_path,
463+
lambda: self._ts_server.insert_text_at_position( # type: ignore[union-attr]
464+
relative_file_path, line, column, text_to_be_inserted
465+
),
466+
)
467+
return result
468+
469+
@override
470+
def delete_text_between_positions(
471+
self,
472+
relative_file_path: str,
473+
start: ls_types.Position,
474+
end: ls_types.Position,
475+
) -> str:
476+
"""
477+
Deletes text between the given positions, forwarding the change to the TypeScript server if it has the file open.
478+
479+
:param relative_file_path: the relative path of the file to edit
480+
:param start: start position
481+
:param end: end position
482+
:return: deleted text
483+
"""
484+
deleted_text = super().delete_text_between_positions(relative_file_path, start, end)
485+
self._forward_edit_to_ts_server_if_needed(
486+
relative_file_path,
487+
lambda: self._ts_server.delete_text_between_positions( # type: ignore[union-attr]
488+
relative_file_path, start, end
489+
),
490+
)
491+
return deleted_text
492+
428493
@classmethod
429494
def _setup_runtime_dependencies(cls, config: LanguageServerConfig, solidlsp_settings: SolidLSPSettings) -> tuple[list[str], str, str]:
430495
is_node_installed = shutil.which("node") is not None

0 commit comments

Comments
 (0)