Fix infinite loop on state refresh

[?]
Dec 28, 2020, 4:26 AM
YPHDYP3LZIQDWKGSFYGMQEGXKVSX3NKBJTSYVTCJ7ZIJTA36FAQAC

Dependencies

  • [2] WHQQV5QQ Add watcher to refresh on file system changes
  • [3] B4SKYP3Y Add repository model and add steps to initialize it
  • [4] MU6ZNUYZ Integrate recordAll command with input box

Change contents

  • replacement in src/repository.ts at line 4
    [3.229][2.149:196]()
    import { anyEvent } from './utils/eventUtils';
    [3.229]
    [3.229]
    import { anyEvent, filterEvent } from './utils/eventUtils';
  • edit in src/repository.ts at line 17
    [2.331]
    [3.482]
    public onDidChangeWorkspace: Event<Uri>;
    public onDidCreateWorkspace: Event<Uri>;
    public onDidDeleteWorkspace: Event<Uri>;
    public onDidAnyWorkspace: Event<Uri>;
  • edit in src/repository.ts at line 64
    [2.705]
    [2.705]
    const dotFolderPattern = /[\\/]\.pijul[\\/]/;
    const ignoreDotFolder = (uri: Uri): boolean => !dotFolderPattern.test(uri.path);
    this.onDidChangeWorkspace = filterEvent(this.onDidChange, ignoreDotFolder);
    this.onDidCreateWorkspace = filterEvent(this.onDidCreate, ignoreDotFolder);
    this.onDidDeleteWorkspace = filterEvent(this.onDidDelete, ignoreDotFolder);
  • replacement in src/repository.ts at line 72
    [2.706][2.706:781]()
    this.onDidAny(this.onAnyRepositoryFileChange, this, this.disposables);
    [2.706]
    [2.781]
    this.onDidAnyWorkspace = anyEvent(
    this.onDidChangeWorkspace,
    this.onDidCreateWorkspace,
    this.onDidDeleteWorkspace
    );
    // This must run on the Workspace event, as the `pijul ls` command will trigger an infinite loop otherwise.
    this.onDidAnyWorkspace(this.onAnyRepositoryFileChange, this, this.disposables);
  • edit in src/repository.ts at line 86
    [3.1517]
    [2.783]
    /**
    * Watcher function which refreshes the extension's state when the files in the
    * repository change.
    */