- oldCommands = rsp ^? result . _Just . capabilities . executeCommandProvider . _Just . commands
- newCommands = fmap (fmap swap) oldCommands
- swap cmd
- | isUuid cmd = T.append uuid $ T.dropWhile (/= ':') cmd
- | otherwise = cmd
- uuid = toText $ fst $ random $ mkStdGen pid
- isUuid = isJust . fromText . T.takeWhile (/= ':')
-swapUUIDs pid (x:xs) = x:swapUUIDs pid xs
\ No newline at end of file
+ oldCommands = rsp ^? result . _Right . LSP.capabilities . executeCommandProvider . _Just . commands
+ newCommands = fmap (fmap (swapPid pid)) oldCommands
+
+swapCommands pid (x:xs) = x:swapCommands pid xs
+
+hasPid :: T.Text -> Bool
+hasPid = (>= 2) . T.length . T.filter (':' ==)
+swapPid :: Int -> T.Text -> T.Text
+swapPid pid t
+ | hasPid t = T.append (T.pack $ show pid) $ T.dropWhile (/= ':') t
+ | otherwise = t