@@ -195,15 +195,24 @@ completion _ide _ complParams = do
195
195
= [ mkPragmaCompl (a <> suffix) b c
196
196
| (a, b, c, w) <- validPragmas, w == NewLine
197
197
]
198
- | " import" `T.isPrefixOf` line || not (T. null module_) || T. null word
198
+ | -- Do not suggest any pragmas any of these conditions:
199
+ -- 1. Current line is a an import
200
+ -- 2. There is a module name right before the current word.
201
+ -- Something like `Text.la` shouldn't suggest adding the
202
+ -- 'LANGUAGE' pragma.
203
+ -- 3. The user has not typed anything yet.
204
+ " import" `T.isPrefixOf` line || not (T. null module_) || T. null word
199
205
= []
200
206
| otherwise
201
207
= [ mkPragmaCompl (prefix <> pragmaTemplate <> suffix) matcher detail
202
208
| (pragmaTemplate, matcher, detail, appearWhere) <- validPragmas
203
- , Fuzzy. test word matcher
204
- , (appearWhere == NewLine && line == word)
205
- || (appearWhere == CanInline && line /= word)
206
- || (T. elem ' ' matcher && appearWhere == NewLine && Fuzzy. test line matcher)
209
+ , -- Only suggest a pragma that need its own line if the whole line
210
+ -- fuzzily matches the pragma
211
+ (appearWhere == NewLine && Fuzzy. test line matcher ) ||
212
+ -- Only suggest a pragma that appears in the middle of a line when
213
+ -- the current word is not the only thing in the line and the
214
+ -- current word fuzzily matches the pragma
215
+ (appearWhere == CanInline && line /= word && Fuzzy. test word matcher)
207
216
]
208
217
where
209
218
line = T. toLower $ VFS. fullLine pfix
0 commit comments