You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* `lsp-rename': check if supported
`lsp-rename' doesn't check whether renaming is supported first. Do that,
throwing an error otherwise.
Fixes#2314.
* `lsp-rename': support ommitted :placeholder
In `lsp--get-symbol-to-rename', handle the server not providing a
placeholder by limiting the `when-let' block to the prepare result.
* Address PR review
- Use an `unless' form instead of `if-let' to check for
"textDocument/rename". The latter was wrong anyway, and should've been
an `if'.
- Remove useless comments.
- Revert the variable name change "response" -> "prepare"
- Use `lsp-feature?' instead of reinventing it inline
* `lsp-rename': use built-in error functions
Drop `lsp--fatal-error' and `lsp--user-error', since they cannot display
propertized messages anyway.
Use `user-error' and `error' in `lsp-rename' and
`lsp--get-symbol-to-rename' instead.
* Fix renaming without prepareRename support
In `lsp--get-symbol-to-rename', return nil instead of (nil . nil) if
there is no symbol at point.
* `lsp-rename': move `user-error' into `interactive'
"rename is invalid here" makes no sense if `lsp-rename' is not called
interactively.
* Revert unrelated changes
* `lsp-rename': highlight renaming
`lsp-rename' now highlights the identifier being renamed.
To do so, refactor `lsp--get-symbol-to-rename' to return the bounds of
the symbol being renamed instead of it, and allow its placeholder to be
nil. The latter is necessary to reduce code duplication, as the two code
paths of that function (has prepareRename, doesn't have prepareRename)
would need to do the same `buffer-substring' with the same bounds.
Add a new function, `lsp--read-rename', which takes the result of a call
to `lsp--get-symbol-to-rename' and either `user-error's (if the result
was nil) or asks the user for a new symbol, highlighting the identifier
being renamed. The split was done to make them independently testable.
`lsp-rename': no longer `user-error' if NEW-NAME is nil, since that only
makes sense if it is called interactively. However, in the latter case,
`lsp--read-rename' would do the necessary error handling already.
* `lsp-rename': add tests
`lsp--read-rename' and `lsp--get-symbol-to-rename' now should really
work, since they have a comprehensive test-suite to cover them. It has
to rely on mocking a lot, though.
Fix a bug in `lsp--get-symbol-to-rename': if RESPONSE is a range,
getting its placeholder is wrong. Guard that with an `and' `not'
`lsp-range?'.
* `lsp--read-rename': use a variable to hold overlay
Using `lsp--remove-overlay' didn't actually bring any additional safety,
given that the user could still theoretically C-g between `overlay-put'
`lsp-face-rename' and `make-overlay', causing it to stay. Use a local
variable to hold it instead, which doesn't decrease safety but reduces
overhead. Note that it is still very unlikely (probably impossible) that
a user could do that using only C-g, without a debugger. There is also
no 100% safe way to do this.
* `lsp-rename-face': add missing :group
* `lsp-rename': tests: check overlays
The test for `lsp--read-rename' now checks whether the highlighting
overlay appears and disappears again, in-between calls to a mocked
`read-string', not just whether it disappears again.
This is now done by checking the `face' attribute of overlays, not by
checking the `lsp--read-rename' property, since that was removed with
the last commit.
* `lsp-rename': make prepareRename configurable
The new defcustom `lsp-rename-use-prepare' now controls whether prepareRename
should be used or not for `lsp--get-symbol-to-rename'.
* Address nit: `-doto'
The overlay is modified once, and assigned to a variable anyway. `setq' it to
`make-overlay' directly and `overlay-put' the face to it afterwards.
* Use a consistent placeholder face
`lsp-rename-placeholder-face' is now used to display the new name
instead of reusing the face of the identifier in the buffer.
The reasoning here is that reusing the symbols's face directly would
yield inconsistent placeholders, while conveying no additional
information, given that the thing being renamed is shown in that very
same prompt as it appears in the buffer.
* `lsp-face-rename': underline instead of highlight
Because `lsp-face-highlight-*' also derive from `highlight', the symbol
being renamed could only have either a documentHighlight or a rename
face. This caused inconsistent results with `lsp-idle-delay' = 0, where
either would sometimes win. By using :underline instead, the symbol
being renamed can be marked as such while having a documentHighlight
overlay active.
* Make `lsp-rename-history' public
`lsp-rename-history' should be private so that it can be excluded from savehist.
In addition, from looking at the code of other packages, history variables tend
to be public: `magit-revision-history', `evil-ex-history', ....
0 commit comments