Jaseci-Labs / jac-analyzer

The Jaclang Language Extension for VScode is an extension that provides basic Language Server Protocol (LSP) functionalities for the Jaclang programming language.
MIT License
0 stars 3 forks source link

[FIX] Optimize Text Document Change Handling with Debouncing #52

Closed musab-mah-7 closed 3 months ago

musab-mah-7 commented 3 months ago

Optimize Text Document Change Handling with Debouncing

Summary

This PR introduces a debouncing mechanism to our language server's handling of the textDocument/didChange event. By wrapping the event handler with a debounce decorator, we aim to improve performance and reduce server load by minimizing the frequency of processing rapid, consecutive text changes.

Motivation

In our current implementation, the language server processes every text change event as it arrives. This can lead to performance issues, particularly when handling large documents or when users type rapidly, as it results in unnecessary computation and can overload the server. By introducing debouncing, we ensure that text change events are processed only after a brief period of inactivity (2 seconds), significantly reducing the computational burden and improving the overall responsiveness of our language server.

Changes

Expected Impact