MCPcopy Index your code
hub / github.com/FSoft-AI4Code/HyperAgent / offset_at_position

Function offset_at_position

src/hyperagent/utils.py:258–269  ·  view source on GitHub ↗

Calculates the offset at a given position in a document. Args: doc (str): The document content. position (dict): The position object containing the line and character. Returns: int: The offset at the given position.

(doc, position)

Source from the content-addressed store, hash-verified

256 return doc[offset_at_position(doc, range["start"]):offset_at_position(doc, range["end"])]
257
258def offset_at_position(doc, position):
259 """
260 Calculates the offset at a given position in a document.
261
262 Args:
263 doc (str): The document content.
264 position (dict): The position object containing the line and character.
265
266 Returns:
267 int: The offset at the given position.
268 """
269 return position["character"] + len("".join(doc.splitlines(True)[: position["line"]]))
270
271def save_infos_to_folder(infos_dict, name, folder):
272 if not os.path.exists(folder):

Callers 1

get_textFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected