all repos

clerk @ 68a2727ad67e44cd018ee1b44fbdb1940ca1e372

missing tooling for ledger/hledger
2 files changed, 15 insertions(+), 1 deletions(-)
loader: evict closed files
Author: Oleksandr Smirnov olexsmir@gmail.com
Committed at: 2026-09-03 13:51:47 +0300
Authored at: 2026-09-02 23:50:59 +0300
Change ID: uusuymkswvnkpwytnlpryxnsosnkzpqz
Parent: 336ef91
M internal/lsp/textdocument_sync.go
···
        30
        30
         func (s *server) DidClose(ctx context.Context, params *protocol.DidCloseTextDocumentParams) error {

      
        31
        31
         	u := params.TextDocument.URI

      
        32
        32
         	s.closeDoc(u)

      
        
        33
        +	s.loader.Evict(u.Path())

      
        33
        34
         

      
        34
        35
         	// clear closed doc's diagnostics; dependents rebuild from disk since the buffer text is gone.

      
        35
        36
         	s.markDependentsDirty(u)

      
M journal/loader.go
···
        156
        156
         	rj.ByPath = newByPath

      
        157
        157
         }

      
        158
        158
         

      
        159
        
        -// InvalidateFile removes a file from the content cache

      
        
        159
        +// InvalidateFile removes a file from the content cache.

      
        160
        160
         func (l *Loader) InvalidateFile(fpath string) {

      
        161
        161
         	canon := CanonicalPath(fpath)

      
        162
        162
         	l.mu.Lock()

      
        163
        163
         	delete(l.contentCache, canon)

      
        164
        164
         	l.mu.Unlock()

      
        
        165
        +}

      
        
        166
        +

      
        
        167
        +// Evict drops a file's cached content.

      
        
        168
        +func (l *Loader) Evict(fpath string) {

      
        
        169
        +	canon := CanonicalPath(fpath)

      
        
        170
        +	l.mu.Lock()

      
        
        171
        +	defer l.mu.Unlock()

      
        
        172
        +	delete(l.contentCache, canon)

      
        
        173
        +	for k := range l.parseCache {

      
        
        174
        +		if k.canon == canon {

      
        
        175
        +			delete(l.parseCache, k)

      
        
        176
        +		}

      
        
        177
        +	}

      
        165
        178
         }

      
        166
        179
         

      
        167
        180
         // readContent reads a file, preferring the content provider, then the disk content cache.