@@ -23,14 +23,16 @@ import Development.IDE.Core.UseStale
23
23
import Development.IDE.GHC.ExactPrint (GetAnnotatedParsedSource (GetAnnotatedParsedSource ))
24
24
import qualified Ide.Plugin.Config as Plugin
25
25
import Ide.Types
26
- import Language.LSP.Server (LspM , sendRequest , getClientCapabilities )
26
+ import Language.LSP.Server (LspM , sendRequest , getClientCapabilities , getVersionedTextDoc )
27
27
import qualified Language.LSP.Types as LSP
28
+ import qualified Language.LSP.Types.Lens as J
28
29
import Language.LSP.Types hiding (CodeLens , CodeAction )
29
30
import Wingman.AbstractLSP.Types
30
31
import Wingman.EmptyCase (fromMaybeT )
31
32
import Wingman.LanguageServer (runIde , getTacticConfigAction , getIdeDynflags , mkWorkspaceEdits , runStaleIde , showLspMessage , mkShowMessageParams )
32
33
import Wingman.StaticPlugin (enableQuasiQuotes )
33
34
import Wingman.Types
35
+ import Control.Lens ((^.) )
34
36
35
37
36
38
------------------------------------------------------------------------------
@@ -111,7 +113,7 @@ runContinuation plId cont state (fc, b) = do
111
113
GraftEdit gr -> do
112
114
ccs <- lift getClientCapabilities
113
115
TrackedStale pm _ <- mapMaybeT liftIO $ stale GetAnnotatedParsedSource
114
- case mkWorkspaceEdits (enableQuasiQuotes le_dflags) ccs (fc_uri le_fileContext) (unTrack pm) gr of
116
+ case mkWorkspaceEdits (enableQuasiQuotes le_dflags) ccs (fc_uri le_fileContext) (textVersion fc) ( unTrack pm) gr of
115
117
Left errs ->
116
118
pure $ Just $ ResponseError
117
119
{ _code = InternalError
@@ -176,11 +178,13 @@ codeActionProvider
176
178
)
177
179
-> PluginMethodHandler IdeState TextDocumentCodeAction
178
180
codeActionProvider sort k state plId
179
- (CodeActionParams _ _ (TextDocumentIdentifier uri) range _) = do
181
+ (CodeActionParams _ _ docId@ (TextDocumentIdentifier uri) range _) = do
182
+ version <- (^. J. version) <$> getVersionedTextDoc docId
180
183
fromMaybeT (Right $ List [] ) $ do
181
184
let fc = FileContext
182
185
{ fc_uri = uri
183
186
, fc_range = Just $ unsafeMkCurrent range
187
+ , textVersion = version
184
188
}
185
189
env <- buildEnv state plId fc
186
190
args <- fetchTargetArgs @ target env
@@ -203,11 +207,13 @@ codeLensProvider
203
207
)
204
208
-> PluginMethodHandler IdeState TextDocumentCodeLens
205
209
codeLensProvider sort k state plId
206
- (CodeLensParams _ _ (TextDocumentIdentifier uri)) = do
210
+ (CodeLensParams _ _ docId@ (TextDocumentIdentifier uri)) = do
211
+ version <- (^. J. version) <$> getVersionedTextDoc docId
207
212
fromMaybeT (Right $ List [] ) $ do
208
213
let fc = FileContext
209
214
{ fc_uri = uri
210
215
, fc_range = Nothing
216
+ , textVersion = version
211
217
}
212
218
env <- buildEnv state plId fc
213
219
args <- fetchTargetArgs @ target env
0 commit comments