|
80 | 80 | '("F" "daFo" "safo")
|
81 | 81 | '("F" "daFo" "safo"))))
|
82 | 82 |
|
83 |
| -(ert-deftest lsp-completion-test-get-context () |
| 83 | +(ert-deftest lsp-completion-test-get-context-trigger-characters-no-cache () |
84 | 84 | (setq lsp-completion--cache nil)
|
85 | 85 | (cl-labels ((do-get-context (arg)
|
86 | 86 | (let ((non-essential arg))
|
87 |
| - (lsp-completion--get-context '("_")))) |
| 87 | + (lsp-completion--get-context '("_") nil))) |
88 | 88 | (do-test-trigger-kind (arg)
|
89 | 89 | (lsp:completion-context-trigger-kind
|
90 | 90 | (do-get-context arg)))
|
|
102 | 102 | (should (equal (do-test-trigger-kind t) 2))
|
103 | 103 | (should (equal (do-test-trigger-character t) "_")))))
|
104 | 104 |
|
| 105 | +(ert-deftest lsp-completion-test-get-context-incomplete-completion () |
| 106 | + (setq lsp-completion--cache (list "not-used" :incomplete)) |
| 107 | + (cl-labels ((do-get-context (arg same-session?) |
| 108 | + (let ((non-essential arg)) |
| 109 | + (lsp-completion--get-context '("_") same-session?))) |
| 110 | + (do-test-trigger-kind (arg same-session?) |
| 111 | + (lsp:completion-context-trigger-kind |
| 112 | + (do-get-context arg same-session?)))) |
| 113 | + (mocklet ((lsp-completion--looking-back-trigger-characterp)) |
| 114 | + ;; When the user manually invokes completion, |
| 115 | + (should (equal (do-test-trigger-kind nil nil) 1)) ;; and the session is different: expect a new completion |
| 116 | + (should (equal (do-test-trigger-kind nil t) 3)) ;; and the session is the same: expect a continued completion |
| 117 | + |
| 118 | + ;; When the user is typing a non-trigger character into the buffer, |
| 119 | + (should (equal (do-test-trigger-kind t nil) 1)) ;; and the session is different: expect a new completion |
| 120 | + (should (equal (do-test-trigger-kind t t) 3))) ;; and the session is the same: expect a continued completion |
| 121 | + |
| 122 | + (mocklet ((lsp-completion--looking-back-trigger-characterp => "_")) |
| 123 | + ;; When the user manually invokes completion, |
| 124 | + (should (equal (do-test-trigger-kind nil nil) 1)) ;; and the session is different: expect a new completion |
| 125 | + (should (equal (do-test-trigger-kind nil t) 3)) ;; and the session is the same: expect a continued completion |
| 126 | + |
| 127 | + ;; When the user is typing a trigger-character into the buffer, |
| 128 | + (should (equal (do-test-trigger-kind t nil) 2)) ;; and the session is different: expect a new trigger-character completion |
| 129 | + (should (equal (do-test-trigger-kind t t) 2))) ;; and the session is the same: expect a new trigger-character completion |
| 130 | + )) |
| 131 | + |
105 | 132 | (provide 'lsp-completion-test)
|
106 | 133 | ;;; lsp-completion-test.el ends here
|
0 commit comments