Add support for rename with language servers that lack prepareRename (#23000)
This adds support for LSPs that use the old rename flow which does not first ask the LSP for the rename range and check that it is a valid range to rename. Closes #16663 Release Notes: * Fixed rename symbols action when the language server does not have the capability to prepare renames - such as `luau-lsp`.
This commit is contained in:
parent
b65dc8c566
commit
bda0c67ece
7 changed files with 268 additions and 66 deletions
|
@ -307,6 +307,14 @@ impl ProjectPath {
|
|||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Default)]
|
||||
pub enum PrepareRenameResponse {
|
||||
Success(Range<Anchor>),
|
||||
OnlyUnpreparedRenameSupported,
|
||||
#[default]
|
||||
InvalidPosition,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Eq)]
|
||||
pub struct InlayHint {
|
||||
pub position: language::Anchor,
|
||||
|
@ -2908,7 +2916,7 @@ impl Project {
|
|||
buffer: Model<Buffer>,
|
||||
position: PointUtf16,
|
||||
cx: &mut ModelContext<Self>,
|
||||
) -> Task<Result<Option<Range<Anchor>>>> {
|
||||
) -> Task<Result<PrepareRenameResponse>> {
|
||||
self.request_lsp(
|
||||
buffer,
|
||||
LanguageServerToQuery::Primary,
|
||||
|
@ -2921,7 +2929,7 @@ impl Project {
|
|||
buffer: Model<Buffer>,
|
||||
position: T,
|
||||
cx: &mut ModelContext<Self>,
|
||||
) -> Task<Result<Option<Range<Anchor>>>> {
|
||||
) -> Task<Result<PrepareRenameResponse>> {
|
||||
let position = position.to_point_utf16(buffer.read(cx));
|
||||
self.prepare_rename_impl(buffer, position, cx)
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue