@@ -263,19 +263,21 @@ triggers a completion immediately"
263
263
symbol)
264
264
'stop )))
265
265
266
- (defun omnisharp-company-flx-score-filter-list (query l cache )
266
+ (defun omnisharp-company-flx-score-filter-list (query candidates cache )
267
267
(let ((matches nil ))
268
- (dolist (elt l)
269
- (let* ((completion-text (omnisharp--get-company-candidate-data elt 'CompletionText ))
268
+ (dolist (candidate candidates)
269
+ (let* ((completion-text (omnisharp--get-company-candidate-data
270
+ candidate
271
+ 'CompletionText ))
270
272
(flx-val (flx-score completion-text query cache)))
271
273
(when (not (null flx-val))
272
- (setq matches (cons (cons elt flx-val) matches)))))
274
+ (setq matches (cons (cons candidate flx-val) matches)))))
273
275
274
276
(if omnisharp-company-match-sort-by-flx-score
275
277
(setq matches (sort matches (lambda (el1 el2 ) (> (nth 1 el1) (nth 1 el2)))))
276
278
(setq matches (reverse matches)))
277
279
278
- (mapcar ( lambda ( el1 ) ( car el1)) matches)))
280
+ (mapcar ' car matches)))
279
281
280
282
(defvar omnisharp-company-current-flx-match-list nil )
281
283
(defvar omnisharp-company-current-flx-arg-being-matched nil )
@@ -294,10 +296,11 @@ triggers a completion immediately"
294
296
(setq omnisharp-company-match-type 'company-match-simple )))
295
297
296
298
(cl-case command
297
- (prefix (when (and (bound-and-true-p omnisharp-mode) (not (company-in-string-or-comment)))
299
+ (prefix (when (and (bound-and-true-p omnisharp-mode)
300
+ (not (company-in-string-or-comment)))
298
301
(omnisharp-company--prefix)))
299
302
300
- (candidates (if (and ( fboundp 'flx-score ) ( eq omnisharp-company-match-type 'company-match-flx ) )
303
+ (candidates (if (eq omnisharp-company-match-type 'company-match-flx )
301
304
; ;flx matching
302
305
(progn
303
306
; ; If the completion arg is empty, just return what the server sends
@@ -309,15 +312,16 @@ triggers a completion immediately"
309
312
(setq omnisharp-company-current-flx-match-list (omnisharp--get-company-candidates arg))
310
313
(setq omnisharp-company-current-flx-arg-being-matched arg))
311
314
312
- ; ; Let flex sort the results
315
+ ; ; Let flex filter the results
313
316
(omnisharp-company-flx-score-filter-list arg
314
317
omnisharp-company-current-flx-match-list
315
318
omnisharp-company-flx-cache)))
316
319
(omnisharp--get-company-candidates arg)))
317
320
318
321
319
- ; ; because "" doesn't return everything
320
- (no-cache (or (equal arg " " ) (not (eq omnisharp-company-match-type 'company-match-simple ))))
322
+ ; ; because "" doesn't return everything, and we don't cache if we're handling the filtering
323
+ (no-cache (or (equal arg " " )
324
+ (not (eq omnisharp-company-match-type 'company-match-simple ))))
321
325
322
326
(match (if (eq omnisharp-company-match-type 'company-match-simple )
323
327
nil
@@ -338,10 +342,9 @@ triggers a completion immediately"
338
342
339
343
(ignore-case omnisharp-company-ignore-case)
340
344
341
- (sorted omnisharp-company-sort-results)
342
- ; ; (sorted (if (eq omnisharp-company-match-type 'company-match-simple)
343
- ; ; (not omnisharp-company-sort-results)
344
- ; ; t))
345
+ (sorted (if (eq omnisharp-company-match-type 'company-match-simple )
346
+ (not omnisharp-company-sort-results)
347
+ t ))
345
348
346
349
; ; Check to see if we need to do any templating
347
350
(post-completion (setq omnisharp-company-current-flx-arg-being-matched nil )
@@ -632,18 +635,14 @@ current buffer."
632
635
; ;
633
636
; ; Get the full item so we can then get the
634
637
; ; RequiredNamespaceImport value from it
635
- (completed-item
636
- (-first (lambda (a )
637
- (equal result-completion-text
638
- (cdr (assoc 'CompletionText a))))
639
- json-result-alist))
638
+ (completion-snippet
639
+ (get-text-property 0 'Snippet result-completion-text))
640
640
(required-namespace-import
641
- (cdr (assoc 'RequiredNamespaceImport
642
- completed-item))))
641
+ (get-text-property 0 'RequiredNamespaceImport result-completion-text)))
643
642
644
- (omnisharp--replace-symbol-in-buffer-with
645
- ( omnisharp--current-word-or-empty-string)
646
- result-completion-text)
643
+ (if ( and completion-snippet omnisharp-company-template-use-yasnippet ( fboundp 'yas/expand-snippet ))
644
+ ( yas/expand-snippet completion-snippet ( search-backward ( omnisharp--current-word-or-empty-string)) )
645
+ (omnisharp--replace-symbol-in-buffer-with (omnisharp--current-word-or-empty-string) result-completion-text) )
647
646
648
647
(when required-namespace-import
649
648
(omnisharp--insert-namespace-import required-namespace-import)))))
@@ -703,9 +702,11 @@ is a more sophisticated matching framework than what popup.el offers."
703
702
(mapcar
704
703
(-lambda ((&alist 'DisplayText display-text
705
704
'CompletionText completion-text
706
- 'Description description))
705
+ 'Description description
706
+ 'Snippet snippet
707
+ 'RequiredNamespaceImport require-ns-import))
707
708
(popup-make-item display-text
708
- :value completion-text
709
+ :value ( propertize completion-text 'Snippet snippet 'RequiredNamespaceImport require-ns-import)
709
710
:document description))
710
711
json-result-alist))
711
712
0 commit comments