Skip to content

Commit 716011a

Browse files
committed
Remove Client Diags from fallback and change tests
Since Server Diags are authoritive, dont fallback to client diags. Cases where server resolved all diags but client still have stale diags may break from expected behaviour. Also change tests that deviate from expectations
1 parent 4a7aea9 commit 716011a

3 files changed

Lines changed: 11 additions & 13 deletions

File tree

ghcide/src/Development/IDE/Core/PluginUtils.hs

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -225,16 +225,14 @@ activeDiagnosticsInRange :: MonadIO m => Shake.ShakeExtras -> NormalizedFilePath
225225
activeDiagnosticsInRange ide nfp range = runMaybeT (activeDiagnosticsInRangeMT ide nfp range)
226226

227227
-- Prefer server-side diagnostics if available; they are authoritative.
228-
-- Fall back to client-supplied diagnostics when none are found.
229228
injectServerDiagnostics :: IdeState -> CodeActionParams -> IO CodeActionParams
230-
injectServerDiagnostics ide params@LSP.CodeActionParams{_textDocument=LSP.TextDocumentIdentifier{_uri}, _range, _context=context} = do
231-
let clientDiags = context ^. LSP.diagnostics
229+
injectServerDiagnostics ide params@LSP.CodeActionParams{_textDocument=LSP.TextDocumentIdentifier{_uri}, _range} = do
232230
serverDiags <- case LSP.uriToNormalizedFilePath (LSP.toNormalizedUri _uri) of
233-
Nothing -> pure clientDiags
231+
Nothing -> pure []
234232
Just nfp -> do
235233
mDiags <- activeDiagnosticsInRange (shakeExtras ide) nfp _range
236234
case mDiags of
237-
Nothing -> pure clientDiags
235+
Nothing -> pure []
238236
Just diags -> pure $ diags ^.. traverse . fdLspDiagnosticL
239237
pure $ params & LSP.context . LSP.diagnostics .~ serverDiags
240238

ghcide/src/Development/IDE/Plugin/HLS.hs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -48,12 +48,12 @@ import Language.LSP.Protocol.Message
4848
import Language.LSP.Protocol.Types
4949
import qualified Language.LSP.Server as LSP
5050
import Language.LSP.VFS
51-
import Prettyprinter.Render.String (renderString)
52-
import Text.Regex.TDFA.Text ()
53-
import UnliftIO (MonadUnliftIO, liftIO,
54-
readTVarIO)
55-
import UnliftIO.Async (forConcurrently)
56-
import UnliftIO.Exception (catchAny)
51+
import Prettyprinter.Render.String (renderString)
52+
import Text.Regex.TDFA.Text ()
53+
import UnliftIO (MonadUnliftIO, liftIO,
54+
readTVarIO)
55+
import UnliftIO.Async (forConcurrently)
56+
import UnliftIO.Exception (catchAny)
5757

5858
-- ---------------------------------------------------------------------
5959
--

plugins/hls-hlint-plugin/test/Main.hs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -218,8 +218,8 @@ suggestionsTests =
218218
doc <- openDoc "TwoHints.hs" "haskell"
219219
_ <- hlintCaptureKick
220220

221-
firstLine <- map fromAction <$> getCodeActions doc (mkRange 0 0 0 0)
222-
secondLine <- map fromAction <$> getCodeActions doc (mkRange 1 0 1 0)
221+
firstLine <- map fromAction <$> getCodeActions doc (mkRange 0 0 1 0)
222+
secondLine <- map fromAction <$> getCodeActions doc (mkRange 1 0 2 0)
223223
thirdLine <- map fromAction <$> getCodeActions doc (mkRange 2 0 2 0)
224224
multiLine <- map fromAction <$> getCodeActions doc (mkRange 0 0 2 0)
225225

0 commit comments

Comments
 (0)