@@ -142,8 +142,8 @@ SonarLint LSP server."
142142 (or (< pos1 pos2)
143143 ; ; before-string is inserted before after-string
144144 (and (= pos1 pos2)
145- (plist-member str1 'before -string )
146- (not (plist-member str2 'before -string )))))))))
145+ (plist-member str1 'after -string )
146+ (not (plist-member str2 'after -string )))))))))
147147 (dolist (str all-strings)
148148 (let ((pos (plist-get str :pos )))
149149 (push (buffer-substring-no-properties last-pos pos) pieces)
@@ -155,6 +155,64 @@ SonarLint LSP server."
155155 (concat (string-join (nreverse pieces))
156156 (buffer-substring-no-properties last-pos (point-max )))))
157157
158+ (defun lsp-sonarlint-test--place-overlay (line marker )
159+ " Add overlay at LINE covering chars pointed to by MARKER in current buffer."
160+ (let* ((range (lsp-sonarlint-test-range-make (buffer-string ) line marker))
161+ (line (plist-get range :line ))
162+ (from (plist-get range :from ))
163+ (to (plist-get range :to )))
164+ (save-excursion
165+ (goto-char (point-min ))
166+ (forward-line (- line 1 ))
167+ (message " addding overlay from %s to %s "
168+ (+ from (line-beginning-position ))
169+ (+ to (line-beginning-position )))
170+ (make-overlay (+ from (line-beginning-position ))
171+ (+ to (line-beginning-position ))
172+ (current-buffer )))))
173+
174+ (ert-deftest lsp-sonarlint-test--overlays-string ()
175+ " Test `lsp-sonarlint-test--buf-string-with-overlay-strings' on corner cases"
176+ (with-temp-buffer
177+ (unwind-protect
178+ (progn
179+ (insert "
180+ Some string here
181+ " )
182+ (overlay-put (lsp-sonarlint-test--place-overlay
183+ " Some string here"
184+ " ^^^^ " )
185+ 'before-string
186+ " Heho" )
187+ (overlay-put (lsp-sonarlint-test--place-overlay
188+ " Some string here"
189+ " ^^^^ " )
190+ 'after-string
191+ " after" )
192+ (overlay-put (lsp-sonarlint-test--place-overlay
193+ " Some string here"
194+ " ^ " )
195+ 'before-string
196+ " bef1" )
197+ (overlay-put (lsp-sonarlint-test--place-overlay
198+ " Some string here"
199+ " ^ " )
200+ 'after-string
201+ " aft1" )
202+ (overlay-put (lsp-sonarlint-test--place-overlay
203+ " Some string here"
204+ " ^^^^" )
205+ 'after-string
206+ "
207+ next str" )
208+ (should (equal (lsp-sonarlint-test--buf-string-with-overlay-strings)
209+ "
210+ HehoSomeafterbef1 aft1string here
211+ next str
212+ " ))
213+ )
214+ (remove-overlays ))))
215+
158216(ert-deftest lsp-sonarlint-test--display-secondary-messages ()
159217 " Test that secondary locations are displayed correctly."
160218 (let ((target-file-buf (find-file-noselect lsp-sonarlint-test--file-path)))
0 commit comments