File tree Expand file tree Collapse file tree 5 files changed +62
-6
lines changed
Expand file tree Collapse file tree 5 files changed +62
-6
lines changed Original file line number Diff line number Diff line change @@ -133,6 +133,10 @@ jobs:
133133 # run the tests without parallelism to avoid running out of memory
134134 run : cabal test ghcide --test-options="$TEST_OPTS" || cabal test ghcide --test-options="$TEST_OPTS" || LSP_TEST_LOG_COLOR=0 LSP_TEST_LOG_MESSAGES=true LSP_TEST_LOG_STDERR=true cabal test ghcide --test-options="$TEST_OPTS"
135135
136+ - if : matrix.test
137+ name : Test hls-plugin-api
138+ run : cabal test hls-plugin-api --test-options="$TEST_OPTS" || cabal test hls-plugin-api --test-options="$TEST_OPTS" || LSP_TEST_LOG_COLOR=0 LSP_TEST_LOG_MESSAGES=true LSP_TEST_LOG_STDERR=true cabal test hls-plugin-api --test-options="$TEST_OPTS"
139+
136140 - if : matrix.test
137141 name : Test func-test suite
138142 env :
Original file line number Diff line number Diff line change @@ -77,3 +77,18 @@ library
7777 DataKinds
7878 KindSignatures
7979 TypeOperators
80+
81+ test-suite tests
82+ type : exitcode-stdio-1.0
83+ default-language : Haskell2010
84+ hs-source-dirs : test
85+ main-is : Main.hs
86+ ghc-options : -threaded -rtsopts -with-rtsopts=-N
87+ other-modules : Ide.PluginUtilsTest
88+ build-depends :
89+ base
90+ , hls-plugin-api
91+ , tasty
92+ , tasty-hunit
93+ , tasty-rerun
94+ , lsp-types
Original file line number Diff line number Diff line change @@ -25,6 +25,7 @@ module Ide.PluginUtils
2525 allLspCmdIds' ,
2626 installSigUsr1Handler ,
2727 subRange ,
28+ positionInRange ,
2829 usePropertyLsp ,
2930 response ,
3031 handleMaybe ,
@@ -178,7 +179,7 @@ getClientConfig = getConfig
178179getPluginConfig :: MonadLsp Config m => PluginId -> m PluginConfig
179180getPluginConfig plugin = do
180181 config <- getClientConfig
181- return $ configForPlugin config plugin
182+ return $ configForPlugin config plugin
182183
183184-- ---------------------------------------------------------------------
184185
@@ -220,11 +221,7 @@ subRange smallRange range =
220221 && positionInRange (_end smallRange) range
221222
222223positionInRange :: Position -> Range -> Bool
223- positionInRange (Position pl po) (Range (Position sl so) (Position el eo)) =
224- pl > sl && pl < el
225- || pl == sl && pl == el && po >= so && po <= eo
226- || pl == sl && po >= so
227- || pl == el && po <= eo
224+ positionInRange p (Range sp ep) = sp <= p && p <= ep
228225
229226-- ---------------------------------------------------------------------
230227
Original file line number Diff line number Diff line change 1+ module Ide.PluginUtilsTest
2+ ( tests
3+ ) where
4+
5+ import Ide.PluginUtils (positionInRange )
6+ import Language.LSP.Types (Position (Position ), Range (Range ))
7+ import Test.Tasty
8+ import Test.Tasty.HUnit
9+
10+ tests :: TestTree
11+ tests = testGroup " PluginUtils"
12+ [ positionInRangeTest
13+ ]
14+
15+ positionInRangeTest :: TestTree
16+ positionInRangeTest = testGroup " positionInRange"
17+ [ testCase " single line, after the end" $
18+ positionInRange (Position 1 10 ) (Range (Position 1 1 ) (Position 1 3 )) @?= False
19+ , testCase " single line, before the begining" $
20+ positionInRange (Position 1 0 ) (Range (Position 1 1 ) (Position 1 6 )) @?= False
21+ , testCase " single line, in range" $
22+ positionInRange (Position 1 5 ) (Range (Position 1 1 ) (Position 1 6 )) @?= True
23+ , testCase " multiline, in range" $
24+ positionInRange (Position 3 5 ) (Range (Position 1 1 ) (Position 5 6 )) @?= True
25+ , testCase " multiline, out of range" $
26+ positionInRange (Position 3 5 ) (Range (Position 3 6 ) (Position 4 10 )) @?= False
27+ ]
Original file line number Diff line number Diff line change 1+ module Main where
2+
3+ import qualified Ide.PluginUtilsTest as PluginUtilsTest
4+ import Test.Tasty
5+ import Test.Tasty.Ingredients.Rerun
6+
7+ main :: IO ()
8+ main = defaultMainWithRerun tests
9+
10+ tests :: TestTree
11+ tests = testGroup " Main"
12+ [ PluginUtilsTest. tests
13+ ]
You can’t perform that action at this time.
0 commit comments