Skip to content

Commit d022d04

Browse files
committed
[fix] use normalized file path in applyHint
1 parent 0111207 commit d022d04

File tree

2 files changed

+6
-8
lines changed
  • plugins
    • hls-hlint-plugin/src/Ide/Plugin
    • hls-semantic-tokens-plugin/src/Ide/Plugin/SemanticTokens

2 files changed

+6
-8
lines changed

plugins/hls-hlint-plugin/src/Ide/Plugin/Hlint.hs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -520,8 +520,9 @@ applyHint recorder ide nuri mhint verTxtDocId =
520520
ideas <- bimapExceptT (PluginInternalError . T.pack . showParseError) id $ ExceptT $ runAction' $ getIdeas recorder nuri
521521
let ideas' = maybe ideas (`filterIdeas` ideas) mhint
522522
let commands = map ideaRefactoring ideas'
523-
logWith recorder Debug $ LogGeneratedIdeas nuri commands
524-
let fp = fromNormalizedFilePath nuri
523+
nfp <- getNormalizedFilePathE $ fromNormalizedUri nuri
524+
logWith recorder Debug $ LogGeneratedIdeas nfp commands
525+
let fp = fromNormalizedFilePath nfp
525526
mbOldContent <- fmap (fmap Rope.toText) $ liftIO $ runAction' $ getFileContents nuri
526527
oldContent <- maybe (liftIO $ fmap T.decodeUtf8 (BS.readFile fp)) return mbOldContent
527528
modsum <- liftIO $ runAction' $ use_ GetModSummary nuri

plugins/hls-semantic-tokens-plugin/src/Ide/Plugin/SemanticTokens/Internal.hs

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@ import qualified Data.Map.Strict as M
3434
import Data.Maybe
3535
import Data.Text (Text)
3636
import qualified Data.Text as T
37-
import Debug.Trace
3837
import Development.IDE (Action,
3938
GetDocMap (GetDocMap),
4039
GetHieAst (GetHieAst),
@@ -61,7 +60,6 @@ import Development.IDE.GHC.Compat.Util (mkFastString)
6160
import GHC.Parser.Annotation
6261
import Ide.Logger (logWith)
6362
import Ide.Plugin.Error (PluginError (PluginInternalError, PluginRuleFailed),
64-
getNormalizedFilePathE,
6563
handleMaybe,
6664
handleMaybeM)
6765
import Ide.Plugin.SemanticTokens.Mappings
@@ -73,10 +71,9 @@ import Ide.Types
7371
import qualified Language.LSP.Protocol.Lens as L
7472
import Language.LSP.Protocol.Message (MessageResult,
7573
Method (Method_TextDocumentSemanticTokensFull, Method_TextDocumentSemanticTokensFullDelta))
76-
import Language.LSP.Protocol.Types (NormalizedFilePath,
74+
import Language.LSP.Protocol.Types (NormalizedUri, toNormalizedUri, fromNormalizedUri, getUri,
7775
Range,
7876
SemanticTokens,
79-
fromNormalizedFilePath,
8077
type (|?) (InL, InR))
8178
import Prelude hiding (span)
8279
import qualified StmContainers.Map as STM
@@ -100,8 +97,8 @@ computeSemanticTokens recorder pid _ nuri = do
10097
semanticId <- lift getAndIncreaseSemanticTokensId
10198

10299
tokenList <- sortOn fst <$> do
103-
rangesyntacticTypes <- lift $ useWithStale GetSyntacticTokens nfp
104-
rangesemanticTypes <- lift $ useWithStale GetSemanticTokens nfp
100+
rangesyntacticTypes <- lift $ useWithStale GetSyntacticTokens nuri
101+
rangesemanticTypes <- lift $ useWithStale GetSemanticTokens nuri
105102
let mk w u (toks, mapping) = map (\(ran, tok) -> (toCurrentRange mapping ran, w tok)) $ u toks
106103
maybeToExceptT (PluginRuleFailed "no syntactic nor semantic tokens") $ hoistMaybe $
107104
(mk HsSyntacticTokenType rangeSyntacticList <$> rangesyntacticTypes)

0 commit comments

Comments
 (0)