()
| 794 | let hasPendingProjectSave = false; |
| 795 | |
| 796 | const flushProjectConfig = async () => { |
| 797 | if (!hasPendingProjectSave && !saveInFlight) return; |
| 798 | if (saveInFlight) { |
| 799 | if (hasPendingProjectSave) { |
| 800 | shouldResave = true; |
| 801 | } |
| 802 | return; |
| 803 | } |
| 804 | saveInFlight = true; |
| 805 | shouldResave = false; |
| 806 | hasPendingProjectSave = false; |
| 807 | try { |
| 808 | const config = serializeProjectConfiguration(project); |
| 809 | await commands.setProjectConfig(config); |
| 810 | } catch (error) { |
| 811 | console.error("Failed to persist project config", error); |
| 812 | } finally { |
| 813 | saveInFlight = false; |
| 814 | if (shouldResave) { |
| 815 | shouldResave = false; |
| 816 | void flushProjectConfig(); |
| 817 | } |
| 818 | } |
| 819 | }; |
| 820 | |
| 821 | const scheduleProjectConfigSave = () => { |
| 822 | hasPendingProjectSave = true; |
no test coverage detected