@@ -32,6 +32,9 @@ function set_doc(x::EXPR, doc)
3232 x. meta. error = doc
3333end
3434
35+ function get_path (doc)
36+ return doc. _path
37+ end
3538
3639function get_text (doc:: Document )
3740 return doc. _content
6568"""
6669 get_offset(doc, line, char)
6770
68- Returns the byte offset position corresponding to a line/character position.
71+ Returns the 0 based byte offset position corresponding to a line/character position.
6972This takes 0 based line/char inputs. Corresponding functions are available for
7073Position and Range arguments, the latter returning a UnitRange{Int}.
7174"""
@@ -99,6 +102,7 @@ get_offset(doc, p::Position) = get_offset(doc, p.line, p.character)
99102get_offset (doc, r:: Range ) = get_offset (doc, r. start): get_offset (doc, r. stop)
100103
101104# 1-based. Basically the index at which (line, character) can be found in the document.
105+ get_offset2 (doc:: Document , p:: Position , forgiving_mode= false ) = get_offset2 (doc, p. line, p. character, forgiving_mode)
102106function get_offset2 (doc:: Document , line:: Integer , character:: Integer , forgiving_mode= false )
103107 line_offsets = get_line_offsets2! (doc)
104108 text = get_text (doc)
@@ -131,9 +135,12 @@ function get_offset2(doc::Document, line::Integer, character::Integer, forgiving
131135 pos = nextind (text, pos)
132136 end
133137
134- return pos
138+ return pos
135139end
136140
141+ # get_offset, but correct
142+ get_offset3 (args... ) = get_offset2 (args... ) - 1
143+
137144# Note: to be removed
138145function obscure_text (s)
139146 i = 1
0 commit comments