text: "use strict";
  Object.defineProperty(exports, "__esModule", { value: true });
  const coc_nvim_1 = require("coc.nvim");
  function createProgressListeners(client) {
      // Create a "checking files" progress indicator
      let progressListener = new class {
          constructor() {
              this.countChecked = 0;
              this.nFiles = 0;
              this.title = "";
              this.statusBarItem = null;
          }
          startProgress(start) {
              // TODO implement user cancellation (???)
              this.title = start.title;
              this.nFiles = start.nFiles;
              this.statusBarItem = coc_nvim_1.workspace.createStatusBarItem(0, { progress: true });
              this.statusBarItem.text = this.title;
          }
          percentComplete() {
              return Math.floor(this.countChecked / (this.nFiles + 1) * 100);
          }
          incrementProgress(fileName) {
              if (this.statusBarItem != null) {
                  this.countChecked++;
                  let newPercent = this.percentComplete();
                  this.statusBarItem.text = `${this.title} (${newPercent}%)... [${fileName}]`;
                  this.statusBarItem.show();
              }
          }
          endProgress() {
              this.countChecked = 0;
              this.nFiles = 0;
              this.statusBarItem.hide();
              this.statusBarItem.dispose();
              this.statusBarItem = null;
          }
      };
      // Use custom notifications to drive progressListener
      client.onNotification(`${client.id}/startProgress`, (start) => {
          progressListener.startProgress(start);
      });
      client.onNotification(`${client.id}/incrementProgress`, (fileName) => {
          progressListener.incrementProgress(fileName);
      });
      client.onNotification(`${client.id}/endProgress`, () => {
          progressListener.endProgress();
      });
  }
  exports.createProgressListeners = createProgressListeners;
  //# sourceMappingURL=progress.js.map