@@ -98,7 +98,8 @@ function textDocument_definition_request(params::TextDocumentPositionParams, ser
9898 return locations
9999end
100100
101- function descend (x:: EXPR , target:: EXPR , offset = 0 )
101+ function descend (x:: EXPR , target:: EXPR , offset= 0 )
102+ x == target && return (true , offset)
102103 for c in x
103104 if c == target
104105 return true , offset
@@ -110,7 +111,7 @@ function descend(x::EXPR, target::EXPR, offset = 0)
110111 end
111112 offset += c. fullspan
112113 end
113- false , offset
114+ return false , offset
114115end
115116function get_file_loc (x:: EXPR , offset= 0 , c= nothing )
116117 parent = x
@@ -209,7 +210,7 @@ function textDocument_range_formatting_request(params::DocumentRangeFormattingPa
209210 return nothing
210211 end
211212
212- while ! (expr. head in (:for , :if , :function , :module , :file ))
213+ while ! (expr. head in (:for , :if , :function , :module , :file , :call ))
213214 if expr. parent != = nothing
214215 expr = expr. parent
215216 else
@@ -222,9 +223,8 @@ function textDocument_range_formatting_request(params::DocumentRangeFormattingPa
222223 c1 = 0
223224 start_offset = get_offset2 (doc, l1, c1)
224225 l2, c2 = get_position_at (doc, offset + expr. span)
225- end_offset = get_offset (doc, l2, c2)
226226
227- text = get_text (doc)[start_offset: end_offset ]
227+ text = get_text (doc)[start_offset: offset + expr . span ]
228228
229229 longest_prefix = nothing
230230 for line in eachline (IOBuffer (text))
@@ -255,7 +255,7 @@ function textDocument_range_formatting_request(params::DocumentRangeFormattingPa
255255
256256 if longest_prefix != = nothing && ! isempty (longest_prefix)
257257 io = IOBuffer ()
258- for line in eachline (IOBuffer (newcontent), keep = true )
258+ for line in eachline (IOBuffer (newcontent), keep= true )
259259 print (io, longest_prefix, line)
260260 end
261261 newcontent = String (take! (io))
0 commit comments