From 1d5ae816de65c1a693f8e298c8a987b233661963 Mon Sep 17 00:00:00 2001 From: Chris Penner Date: Tue, 2 Jul 2024 15:38:14 -0700 Subject: [PATCH 1/2] Include trailing '!' in identifier names for hover --- unison-cli/src/Unison/LSP/VFS.hs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/unison-cli/src/Unison/LSP/VFS.hs b/unison-cli/src/Unison/LSP/VFS.hs index 4be5573a45..171b0fc870 100644 --- a/unison-cli/src/Unison/LSP/VFS.hs +++ b/unison-cli/src/Unison/LSP/VFS.hs @@ -81,7 +81,9 @@ identifierSplitAtPosition uri pos = do vf <- getVirtualFile uri PosPrefixInfo {fullLine, cursorPos} <- MaybeT (VFS.getCompletionPrefix pos vf) let (before, after) = Text.splitAt (cursorPos ^. character . to fromIntegral) fullLine - pure (Text.takeWhileEnd isIdentifierChar before, Text.takeWhile isIdentifierChar after) + pure (Text.takeWhileEnd isIdentifierChar before, + -- names can end with '!', and it's not a force, so we include it in the identifier if it's at the end. + Text.takeWhile (\c -> isIdentifierChar c || c == '!') after) where isIdentifierChar c = -- Manually exclude '!' and apostrophe, since those are usually just forces and From 92a74df8f837de3c131defb8947d7b09cc059ffd Mon Sep 17 00:00:00 2001 From: ChrisPenner Date: Tue, 2 Jul 2024 22:50:40 +0000 Subject: [PATCH 2/2] automatically run ormolu --- unison-cli/src/Unison/LSP/VFS.hs | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/unison-cli/src/Unison/LSP/VFS.hs b/unison-cli/src/Unison/LSP/VFS.hs index 171b0fc870..8244d64615 100644 --- a/unison-cli/src/Unison/LSP/VFS.hs +++ b/unison-cli/src/Unison/LSP/VFS.hs @@ -81,9 +81,11 @@ identifierSplitAtPosition uri pos = do vf <- getVirtualFile uri PosPrefixInfo {fullLine, cursorPos} <- MaybeT (VFS.getCompletionPrefix pos vf) let (before, after) = Text.splitAt (cursorPos ^. character . to fromIntegral) fullLine - pure (Text.takeWhileEnd isIdentifierChar before, - -- names can end with '!', and it's not a force, so we include it in the identifier if it's at the end. - Text.takeWhile (\c -> isIdentifierChar c || c == '!') after) + pure + ( Text.takeWhileEnd isIdentifierChar before, + -- names can end with '!', and it's not a force, so we include it in the identifier if it's at the end. + Text.takeWhile (\c -> isIdentifierChar c || c == '!') after + ) where isIdentifierChar c = -- Manually exclude '!' and apostrophe, since those are usually just forces and