Skip to content

Commit 8d6e8f3

Browse files
authored
Merge pull request #265 from serokell/prepare-rename-null
Add proper support for prepareRename
2 parents 74d15fb + 1a81bfc commit 8d6e8f3

File tree

2 files changed

+13
-2
lines changed

2 files changed

+13
-2
lines changed

lsp-types/src/Language/LSP/Types/Message.hs

+1-1
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,7 @@ type family ResponseResult (m :: Method f Request) :: Type where
193193
ResponseResult TextDocumentOnTypeFormatting = List TextEdit
194194
-- Rename
195195
ResponseResult TextDocumentRename = WorkspaceEdit
196-
ResponseResult TextDocumentPrepareRename = Range |? RangeWithPlaceholder
196+
ResponseResult TextDocumentPrepareRename = Maybe (Range |? RangeWithPlaceholder)
197197
-- FoldingRange
198198
ResponseResult TextDocumentFoldingRange = List FoldingRange
199199
ResponseResult TextDocumentSelectionRange = List SelectionRange

src/Language/LSP/Server/Processing.hs

+12-1
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ inferServerCapabilities clientCaps o h =
153153
, _documentFormattingProvider = supportedBool STextDocumentFormatting
154154
, _documentRangeFormattingProvider = supportedBool STextDocumentRangeFormatting
155155
, _documentOnTypeFormattingProvider = documentOnTypeFormattingProvider
156-
, _renameProvider = supportedBool STextDocumentRename
156+
, _renameProvider = renameProvider
157157
, _documentLinkProvider = supported' STextDocumentDocumentLink $ DocumentLinkOptions
158158
(Just False)
159159
(supported SDocumentLinkResolve)
@@ -233,6 +233,17 @@ inferServerCapabilities clientCaps o h =
233233
error "executeCommandCommands needs to be set if a executeCommandHandler is set"
234234
| otherwise = Nothing
235235

236+
clientSupportsPrepareRename = fromMaybe False $
237+
clientCaps ^? LSP.textDocument . _Just . LSP.rename . _Just . LSP.prepareSupport . _Just
238+
239+
renameProvider
240+
| clientSupportsPrepareRename
241+
, supported_b STextDocumentRename
242+
, supported_b STextDocumentPrepareRename = Just $
243+
InR . RenameOptions Nothing . Just $ True
244+
| supported_b STextDocumentRename = Just (InL True)
245+
| otherwise = Just (InL False)
246+
236247
sync = case textDocumentSync o of
237248
Just x -> Just (InL x)
238249
Nothing -> Nothing

0 commit comments

Comments
 (0)