Commit ff680df
Properly process changes to open configuration files
Summary:
ELP as an LSP server operates in a dyamic environment, by design. The key thing ts must deal with is changes to files. A given project loaded into ELP has to process file-changes from two primarily different sources.
The first is open files in the LSP client (VS Code), and these are sent via LSP protocol as they happen, as well as generating a `DidSaveTextDocument` notification when saved.
The other is changes that happen on the filesystem directly, from any source, such as an external editor, version countrol operation, build, or the like. These are monitored via a file watcher, and the watching is also delegated to the LSP client.
There are some wrinkles to this. We send a registration message to the client to watch all files of interest in a project, both source and configuration. So of necessity this will overlap with any files that are also open in the IDE. To avoid double processing these, we only process open files in the `DidSaveTextDocument` notification, and do not process open files in the `DidChangeWatchedFiles` notification.
This is all very well, but at some point there was a rationalisation of change processing, with the realisation that we only care about `DidSaveTextDocument` notifications for triggering diagnostic requests for open files for diagnostic sources not providing on-change diagnostics. Which is now most of them.
So we modified the registered scope for `DidSaveTextDocument` to only be `.erl`/`.hrl` files.
This meant that we no longer processed changes to configuration files that are open in the IDE, which is the main way they pick up changes.
## This diff
We restore the desired immediate reaction to changed files by never doing the check in the `DidSaveTextDocument` notification processing, since it never applied anyway, and so always doing it in `DidChangeWatchedFiles`.
We also tidy up the registering of watched files by first unregistering, otherwise the client accumulates multiple watches for the same files, and sends a change notification for each registration it has. Even with this removal, we still get 2 notifications per file change, so add logic to de-dupe them while processing, as updating config can be an expensive operation.
Reviewed By: jcpetruzza
Differential Revision: D85956439
fbshipit-source-id: 961618711347d173596f69f5fd94a435b3fd45b11 parent 90530e3 commit ff680df
1 file changed
+36
-16
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
852 | 852 | | |
853 | 853 | | |
854 | 854 | | |
855 | | - | |
| 855 | + | |
856 | 856 | | |
| 857 | + | |
| 858 | + | |
857 | 859 | | |
858 | 860 | | |
859 | 861 | | |
860 | 862 | | |
861 | | - | |
862 | | - | |
863 | | - | |
864 | | - | |
865 | | - | |
866 | | - | |
867 | | - | |
868 | 863 | | |
869 | 864 | | |
870 | 865 | | |
| |||
881 | 876 | | |
882 | 877 | | |
883 | 878 | | |
| 879 | + | |
| 880 | + | |
884 | 881 | | |
885 | 882 | | |
| 883 | + | |
886 | 884 | | |
| 885 | + | |
| 886 | + | |
| 887 | + | |
| 888 | + | |
887 | 889 | | |
888 | 890 | | |
889 | 891 | | |
890 | 892 | | |
891 | 893 | | |
| 894 | + | |
| 895 | + | |
| 896 | + | |
| 897 | + | |
| 898 | + | |
| 899 | + | |
| 900 | + | |
| 901 | + | |
| 902 | + | |
892 | 903 | | |
893 | | - | |
894 | | - | |
895 | | - | |
896 | | - | |
897 | | - | |
898 | | - | |
899 | | - | |
900 | 904 | | |
901 | 905 | | |
902 | 906 | | |
| |||
1429 | 1433 | | |
1430 | 1434 | | |
1431 | 1435 | | |
| 1436 | + | |
| 1437 | + | |
| 1438 | + | |
| 1439 | + | |
| 1440 | + | |
| 1441 | + | |
| 1442 | + | |
| 1443 | + | |
| 1444 | + | |
| 1445 | + | |
| 1446 | + | |
| 1447 | + | |
| 1448 | + | |
| 1449 | + | |
| 1450 | + | |
| 1451 | + | |
1432 | 1452 | | |
1433 | | - | |
| 1453 | + | |
1434 | 1454 | | |
1435 | 1455 | | |
1436 | 1456 | | |
| |||
0 commit comments