Skip to content

Commit

Permalink
Fix the order of lsp-save-restriction-and-excursion
Browse files Browse the repository at this point in the history
  • Loading branch information
yyoncho committed Jun 8, 2020
1 parent e3ddfd3 commit 21cfcf5
Showing 1 changed file with 12 additions and 12 deletions.
24 changes: 12 additions & 12 deletions lsp-mode.el
Original file line number Diff line number Diff line change
Expand Up @@ -1375,6 +1375,17 @@ INHERIT-INPUT-METHOD will be proxied to `completing-read' without changes."
download-in-progress?
buffers)

(defvar lsp--already-widened nil)

(defmacro lsp-save-restriction-and-excursion (&rest form)
(declare (indent 0) (debug t))
`(if lsp--already-widened
(save-excursion ,@form)
(-let [lsp--already-widened t]
(save-restriction
(widen)
(save-excursion ,@form)))))

;; from http://emacs.stackexchange.com/questions/8082/how-to-get-buffer-position-given-line-number-and-column-number
(defun lsp--line-character-to-point (line character)
"Return the point for character CHARACTER on line LINE."
Expand Down Expand Up @@ -3601,7 +3612,7 @@ in that particular folder."
(lsp--update-signature-help-hook)

(lsp--semantic-highlighting-warn-about-deprecated-setting)

(when (and lsp-enable-semantic-highlighting
(lsp-feature? "textDocument/semanticTokens"))
(lsp--semantic-tokens-initialize-buffer
Expand Down Expand Up @@ -4847,17 +4858,6 @@ Others: TRIGGER-CHARS"
(lsp-translate-line (1+ (gethash "line" pos-start)))
(lsp-translate-column (gethash "character" pos-start))))))

(defvar lsp--already-widened nil)

(defmacro lsp-save-restriction-and-excursion (&rest form)
(declare (indent 0) (debug t))
`(if lsp--already-widened
(save-excursion ,@form)
(-let [lsp--already-widened t]
(save-restriction
(widen)
(save-excursion ,@form)))))

(defmacro lsp-with-filename (file &rest body)
"Execute BODY with FILE as a context.
Need to handle the case when FILE indicates virtual buffer."
Expand Down

0 comments on commit 21cfcf5

Please sign in to comment.