@@ -11,7 +11,7 @@ mutable struct Document
1111 _version:: Int
1212 server
1313 root:: Document
14- function Document (uri:: AbstractString , text:: AbstractString , workspace_file:: Bool , server= nothing )
14+ function Document (uri:: AbstractString , text:: AbstractString , workspace_file:: Bool , server = nothing )
1515 path = something (uri2filepath (uri), " " )
1616 path == " " || isabspath (path) || throw (LSRelativePath (" Relative path `$path ` is not valid." ))
1717 cst = CSTParser. parse (text, true )
@@ -77,7 +77,7 @@ function get_offset(doc::Document, line::Integer, character::Integer)
7777 line_offsets = get_line_offsets (doc)
7878 io = IOBuffer (get_text (doc))
7979 try
80- seek (io, line_offsets[line + 1 ])
80+ seek (io, line_offsets[line+ 1 ])
8181 while character > 0
8282 c = read (io, Char)
8383 character -= 1
@@ -102,7 +102,7 @@ get_offset(doc, p::Position) = get_offset(doc, p.line, p.character)
102102get_offset (doc, r:: Range ) = get_offset (doc, r. start): get_offset (doc, r. stop)
103103
104104# 1-based. Basically the index at which (line, character) can be found in the document.
105- function get_offset2 (doc:: Document , line:: Integer , character:: Integer , forgiving_mode= false )
105+ function get_offset2 (doc:: Document , line:: Integer , character:: Integer , forgiving_mode = false )
106106 line_offsets = get_line_offsets2! (doc)
107107 text = get_text (doc)
108108
@@ -113,9 +113,9 @@ function get_offset2(doc::Document, line::Integer, character::Integer, forgiving
113113 throw (LSOffsetError (" get_offset2 crashed. More diagnostics:\n line=$line \n line_offsets='$line_offsets '" ))
114114 end
115115
116- line_offset = line_offsets[line + 1 ]
116+ line_offset = line_offsets[line+ 1 ]
117117
118- next_line_offset = line + 1 < length (line_offsets) ? line_offsets[line + 2 ] : nextind (text, lastindex (text))
118+ next_line_offset = line + 1 < length (line_offsets) ? line_offsets[line+ 2 ] : nextind (text, lastindex (text))
119119
120120 pos = line_offset
121121
@@ -134,7 +134,7 @@ function get_offset2(doc::Document, line::Integer, character::Integer, forgiving
134134 pos = nextind (text, pos)
135135 end
136136
137- return pos
137+ return pos
138138end
139139
140140# Note: to be removed
@@ -168,33 +168,33 @@ Updates the doc._line_offsets field, an n length Array each entry of which
168168gives the byte offset position of the start of each line. This always starts
169169with 0 for the first line (even if empty).
170170"""
171- function get_line_offsets (doc:: Document , force= false )
171+ function get_line_offsets (doc:: Document , force = false )
172172 if force || doc. _line_offsets === nothing
173173 doc. _line_offsets = Int[0 ]
174174 text = get_text (doc)
175175 ind = firstindex (text)
176- while ind <= lastindex (text)
176+ while ind <= lastindex (text)
177177 c = text[ind]
178178 nl = c == ' \n ' || c == ' \r '
179- if c == ' \r ' && ind + 1 <= lastindex (text) && text[ind + 1 ] == ' \n '
179+ if c == ' \r ' && ind + 1 <= lastindex (text) && text[ind+ 1 ] == ' \n '
180180 ind += 1
181181 end
182182 nl && push! (doc. _line_offsets, ind)
183183 ind = nextind (text, ind)
184184 end
185- end
185+ end
186186 return doc. _line_offsets
187187end
188188
189- function get_line_offsets2! (doc:: Document , force= false )
189+ function get_line_offsets2! (doc:: Document , force = false )
190190 if force || doc. _line_offsets2 === nothing
191191 doc. _line_offsets2 = Int[1 ]
192192 text = get_text (doc)
193193 ind = firstindex (text)
194- while ind <= lastindex (text)
194+ while ind <= lastindex (text)
195195 c = text[ind]
196196 if c == ' \n ' || c == ' \r '
197- if c == ' \r ' && ind + 1 <= lastindex (text) && text[ind + 1 ] == ' \n '
197+ if c == ' \r ' && ind + 1 <= lastindex (text) && text[ind+ 1 ] == ' \n '
198198 ind += 1
199199 end
200200 push! (doc. _line_offsets2, ind + 1 )
@@ -214,12 +214,12 @@ function get_line_of(line_offsets::Vector{Int}, offset::Integer)
214214 else
215215 line = 1
216216 while line < nlines
217- if line_offsets[line] <= offset < line_offsets[line + 1 ]
217+ if line_offsets[line] <= offset < line_offsets[line+ 1 ]
218218 break
219219 end
220220 line += 1
221221 end
222- end
222+ end
223223 return line, line_offsets[line]
224224end
225225
@@ -240,7 +240,7 @@ function get_position_at(doc::Document, offset::Integer)
240240 c = read (io, Char)
241241 character += 1
242242 if UInt32 (c) >= 0x010000
243- character += 1
243+ character += 1
244244 end
245245 end
246246 close (io)
0 commit comments