Skip to content

Commit 13e51ef

Browse files
committed
hls-notes-plugin: Allow single line notes to be indented
1 parent d431f21 commit 13e51ef

File tree

3 files changed

+7
-6
lines changed

3 files changed

+7
-6
lines changed

plugins/hls-notes-plugin/src/Ide/Plugin/Notes.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ findNotesInFile file recorder = do
137137
noteRefRegex, noteRegex :: Regex
138138
(noteRefRegex, noteRegex) =
139139
( mkReg ("note \\[(.+)\\]" :: String)
140-
, mkReg ("note \\[([[:print:]]+)\\][[:blank:]]*[[:space:]](--)?[[:blank:]]*~~~" :: String)
140+
, mkReg ("note \\[([[:print:]]+)\\][[:blank:]]*[[:space:]][[:blank:]]*(--)?[[:blank:]]*~~~" :: String)
141141
)
142142
where
143143
mkReg = makeRegexOpts (defaultCompOpt { caseSensitive = False }) defaultExecOpt

plugins/hls-notes-plugin/test/NotesTest.hs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,8 @@ gotoNoteTests = testGroup "Goto Note Definition"
3030
defs <- getDefinitions doc (Position 5 64)
3131
liftIO $ do
3232
fp <- canonicalizePath "NoteDef.hs"
33-
defs @?= InL (Definition (InR [Location (filePathToUri fp) (Range (Position 18 9) (Position 18 9))]))
33+
defs @?= InL (Definition (InR [Location (filePathToUri fp) (Range (Position 18 11) (Position 18 11))]))
34+
3435
, testCase "invalid_note" $ runSessionWithServer def plugin testDataDir $ do
3536
doc <- openDoc "NoteDef.hs" "haskell"
3637
_ <- waitForAllProgressDone

plugins/hls-notes-plugin/test/testdata/NoteDef.hs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,10 @@ This is also a very common thing to do for GHC
1616
1717
-}
1818

19-
-- Note [Single line comments]
20-
-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~
21-
-- GHC's notes script only allows multiline comments to define notes, but in the
22-
-- HLS codebase this single line style can be found as well.
19+
-- Note [Single line comments]
20+
-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~
21+
-- GHC's notes script only allows multiline comments to define notes, but in the
22+
-- HLS codebase this single line style can be found as well.
2323

2424
{- Note [Not a valid Note]
2525

0 commit comments

Comments
 (0)