@@ -5554,23 +5554,21 @@ MODE is the mode used in the parent frame."
5554
5554
(goto-char end))))))
5555
5555
5556
5556
(defun lsp--buffer-string-visible ()
5557
- "Return visible buffer string.
5558
- Stolen from `org-copy-visible'."
5559
- (let ((temp (generate-new-buffer " *temp*"))
5560
- (beg (point-min))
5561
- (end (point-max)))
5562
- (while (/= beg end)
5563
- (when (get-char-property beg 'invisible)
5564
- (setq beg (next-single-char-property-change beg 'invisible nil end)))
5565
- (let* ((next (next-single-char-property-change beg 'invisible nil end))
5566
- (substring (buffer-substring beg next)))
5567
- (with-current-buffer temp (insert substring))
5568
- ;; (setq result (concat result substring))
5569
- (setq beg next)))
5570
- (setq deactivate-mark t)
5571
- (prog1 (with-current-buffer temp
5572
- (s-chop-suffix "\n" (buffer-string)))
5573
- (kill-buffer temp))))
5557
+ "Return a string of the buffer's visible text."
5558
+ (let ((beg (point-min))
5559
+ (end (point-max))
5560
+ (parts '()))
5561
+ (while (< beg end)
5562
+ (when (get-char-property beg 'invisible)
5563
+ (setq beg (next-single-char-property-change beg 'invisible nil end)))
5564
+ (let ((next (next-single-char-property-change beg 'invisible nil end)))
5565
+ (push (buffer-substring-no-properties beg next) parts)
5566
+ (setq beg next)))
5567
+ (setq parts (nreverse parts))
5568
+ (let ((result (apply #'concat parts)))
5569
+ (if (string-suffix-p "\n" result)
5570
+ (substring result 0 -1)
5571
+ result))))
5574
5572
5575
5573
(defvar lsp-buffer-major-mode nil
5576
5574
"Holds the major mode when fontification function is running.
0 commit comments