AutoYADM commit: 2025-06-09 18:24:37
This commit is contained in:
parent
c6f9a5c068
commit
eafc2ae303
1 changed files with 17 additions and 6 deletions
|
@ -25,14 +25,19 @@ def parse_specs(data: str):
|
|||
def is_cursor_in_any(cursor: Position, diagnostics: SpecList) -> bool:
|
||||
cl, cc = cursor
|
||||
for (sl, sc), (el, ec) in diagnostics:
|
||||
if sl == el == cl and sc <= cc <= ec:
|
||||
return True
|
||||
if cl < sl or cl > el:
|
||||
continue
|
||||
if sl == el:
|
||||
if cl == sl and sc <= cc <= ec:
|
||||
return True
|
||||
elif cl == sl:
|
||||
if cc >= sc:
|
||||
return True
|
||||
elif cl == el:
|
||||
if cc <= ec:
|
||||
return True
|
||||
elif sl < cl < el:
|
||||
return True
|
||||
elif cl == sl and cc >= sc:
|
||||
return True
|
||||
elif cl == el and cc <= sc:
|
||||
return True
|
||||
return False
|
||||
|
||||
|
||||
|
@ -60,11 +65,17 @@ def main():
|
|||
diagnostics = parse_specs(payload)
|
||||
_ = outfile.write("ok\n")
|
||||
outfile.flush()
|
||||
print("ok", flush=True)
|
||||
elif line.startswith("query "):
|
||||
_, pos = line.split(" ", 1)
|
||||
l, c = map(int, pos.strip().split())
|
||||
result = is_cursor_in_any((l, c), diagnostics)
|
||||
_ = outfile.write("true\n" if result else "false\n")
|
||||
outfile.flush()
|
||||
print("ok", flush=True)
|
||||
elif line == "exit":
|
||||
break
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue