AutoYADM commit: 2025-06-09 18:24:37

This commit is contained in:
Daniel Fichtinger 2025-06-09 18:24:37 -04:00
parent c6f9a5c068
commit eafc2ae303

View file

@ -25,14 +25,19 @@ def parse_specs(data: str):
def is_cursor_in_any(cursor: Position, diagnostics: SpecList) -> bool: def is_cursor_in_any(cursor: Position, diagnostics: SpecList) -> bool:
cl, cc = cursor cl, cc = cursor
for (sl, sc), (el, ec) in diagnostics: for (sl, sc), (el, ec) in diagnostics:
if sl == el == cl and sc <= cc <= ec: if cl < sl or cl > el:
return True 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: elif sl < cl < el:
return True return True
elif cl == sl and cc >= sc:
return True
elif cl == el and cc <= sc:
return True
return False return False
@ -60,11 +65,17 @@ def main():
diagnostics = parse_specs(payload) diagnostics = parse_specs(payload)
_ = outfile.write("ok\n") _ = outfile.write("ok\n")
outfile.flush() outfile.flush()
print("ok", flush=True)
elif line.startswith("query "): elif line.startswith("query "):
_, pos = line.split(" ", 1) _, pos = line.split(" ", 1)
l, c = map(int, pos.strip().split()) l, c = map(int, pos.strip().split())
result = is_cursor_in_any((l, c), diagnostics) result = is_cursor_in_any((l, c), diagnostics)
_ = outfile.write("true\n" if result else "false\n") _ = outfile.write("true\n" if result else "false\n")
outfile.flush() outfile.flush()
print("ok", flush=True)
elif line == "exit": elif line == "exit":
break break
if __name__ == "__main__":
main()