Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 15 additions & 2 deletions tide.el
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,8 @@ ones and overrule settings in the other lists."
(defmacro tide-on-response-success (response ignore-empty-response &rest body)
(declare (indent 2))
`(if (tide-response-success-p ,response)
,@body
(progn
,@body)
(-when-let (msg (plist-get response :message))
(unless (and ,ignore-empty-response (string-equal msg "No content available."))
(message "%s" msg)))
Expand Down Expand Up @@ -970,7 +971,13 @@ Noise can be anything like braces, reserved keywords, etc."
(defun tide-apply-refactor (selected)
(let ((response (tide-command:getEditsForRefactor (plist-get selected :refactor) (plist-get selected :action))))
(tide-on-response-success response nil
(tide-apply-code-edits (tide-plist-get response :body :edits)))))
(deactivate-mark)
(tide-apply-code-edits (tide-plist-get response :body :edits))
(-when-let (rename-location (tide-plist-get response :body :renameLocation))
(with-current-buffer (find-file-noselect (tide-plist-get response :body :renameFilename))
(tide-move-to-location rename-location)
(when (tide-can-rename-symbol-p)
(tide-rename-symbol)))))))

(defun tide-refactor ()
"Refactor code at point or current region"
Expand Down Expand Up @@ -1343,6 +1350,12 @@ number."
(error "Invalid name")
new-symbol)))

(defun tide-can-rename-symbol-p ()
(let ((response (tide-command:rename)))
(and
(tide-response-success-p response)
(eq (tide-plist-get response :body :info :canRename) t))))

(defun tide-rename-symbol ()
"Rename symbol at point."
(interactive)
Expand Down