Fix renames that cover method calls
That was a tough one to debug! I almost thought it was a bug in fennel, but it, of course, turned out to be a fennel-ls problem. When you have a symbol like (foo:bar), fennel compiles it by "macroexpanding" it to (: foo :bar). When fennel macroexpands a macro, it tries to clean up the output by giving it a best-guess bytestart/byteend. Fennel-ls was picking up *both* the accurate `foo:bar` sym and the best-guess virtual `foo` sym as separate references to `foo`. When computing the renames, the best-guess values were getting used, which made the replacement range inaccurate.
This commit is contained in:
parent
be5e167d67
commit
6f9935a781
@ -317,8 +317,9 @@ are declared / referenced in which places."
|
||||
ast (icollect [ok ast parser &until (not ok)] ast)]
|
||||
|
||||
(λ collect-everything [ast result]
|
||||
(when (or (table? ast) (list? ast) (sym? ast))
|
||||
(tset result ast true))
|
||||
(when (or (table? ast) (list? ast))
|
||||
(tset result ast true)
|
||||
(each [k v (iter ast)]
|
||||
(collect-everything k result)
|
||||
(collect-everything v result))))
|
||||
|
||||
@ -207,7 +207,8 @@ Every time the client sends a message, it gets handled by a function in the corr
|
||||
(let [usages (icollect [_ {: symbol} (ipairs definition.referenced-by)
|
||||
&into [{:range (message.multisym->range self def-file definition.binding 1)
|
||||
:newText new-name}]]
|
||||
(if (not (rawequal symbol definition.binding))
|
||||
(if (and (. file.lexical symbol)
|
||||
(not (rawequal symbol definition.binding)))
|
||||
{:newText new-name
|
||||
:range (message.multisym->range self def-file symbol 1)}))]
|
||||
|
||||
|
||||
@ -31,7 +31,9 @@
|
||||
(check-rename "(let [old-name {:field 10}] old-name.field)" 0 9 :new-name
|
||||
"(let [new-name {:field 10}] new-name.field)")
|
||||
(check-rename "(let [old-name {:field 10}] old-name.field)" 0 30 :new-name
|
||||
"(let [new-name {:field 10}] new-name.field)"))
|
||||
"(let [new-name {:field 10}] new-name.field)")
|
||||
(check-rename "(let [[old-name] [{:field 10}]] (old-name:field 10))" 0 7 :new-name
|
||||
"(let [[new-name] [{:field 10}]] (new-name:field 10))"))
|
||||
|
||||
(it "renames from destructure/args"
|
||||
(check-rename "(fn [{: x}] x)" 0 8 :foo "(fn [{: foo}] foo)")
|
||||
|
||||
Loading…
Reference in New Issue
Block a user