coc-git 2.7.10 → 2.7.12

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/index.js CHANGED
@@ -695,8 +695,8 @@ var require_windows = __commonJS({
695
695
  "node_modules/isexe/windows.js"(exports2, module2) {
696
696
  module2.exports = isexe;
697
697
  isexe.sync = sync;
698
- var fs5 = require("fs");
699
- function checkPathExt(path9, options) {
698
+ var fs6 = require("fs");
699
+ function checkPathExt(path10, options) {
700
700
  var pathext = options.pathExt !== void 0 ? options.pathExt : process.env.PATHEXT;
701
701
  if (!pathext) {
702
702
  return true;
@@ -707,25 +707,25 @@ var require_windows = __commonJS({
707
707
  }
708
708
  for (var i = 0; i < pathext.length; i++) {
709
709
  var p = pathext[i].toLowerCase();
710
- if (p && path9.substr(-p.length).toLowerCase() === p) {
710
+ if (p && path10.substr(-p.length).toLowerCase() === p) {
711
711
  return true;
712
712
  }
713
713
  }
714
714
  return false;
715
715
  }
716
- function checkStat(stat, path9, options) {
716
+ function checkStat(stat, path10, options) {
717
717
  if (!stat.isSymbolicLink() && !stat.isFile()) {
718
718
  return false;
719
719
  }
720
- return checkPathExt(path9, options);
720
+ return checkPathExt(path10, options);
721
721
  }
722
- function isexe(path9, options, cb) {
723
- fs5.stat(path9, function(er, stat) {
724
- cb(er, er ? false : checkStat(stat, path9, options));
722
+ function isexe(path10, options, cb) {
723
+ fs6.stat(path10, function(er, stat) {
724
+ cb(er, er ? false : checkStat(stat, path10, options));
725
725
  });
726
726
  }
727
- function sync(path9, options) {
728
- return checkStat(fs5.statSync(path9), path9, options);
727
+ function sync(path10, options) {
728
+ return checkStat(fs6.statSync(path10), path10, options);
729
729
  }
730
730
  }
731
731
  });
@@ -735,14 +735,14 @@ var require_mode = __commonJS({
735
735
  "node_modules/isexe/mode.js"(exports2, module2) {
736
736
  module2.exports = isexe;
737
737
  isexe.sync = sync;
738
- var fs5 = require("fs");
739
- function isexe(path9, options, cb) {
740
- fs5.stat(path9, function(er, stat) {
738
+ var fs6 = require("fs");
739
+ function isexe(path10, options, cb) {
740
+ fs6.stat(path10, function(er, stat) {
741
741
  cb(er, er ? false : checkStat(stat, options));
742
742
  });
743
743
  }
744
- function sync(path9, options) {
745
- return checkStat(fs5.statSync(path9), options);
744
+ function sync(path10, options) {
745
+ return checkStat(fs6.statSync(path10), options);
746
746
  }
747
747
  function checkStat(stat, options) {
748
748
  return stat.isFile() && checkMode(stat, options);
@@ -766,7 +766,7 @@ var require_mode = __commonJS({
766
766
  // node_modules/isexe/index.js
767
767
  var require_isexe = __commonJS({
768
768
  "node_modules/isexe/index.js"(exports2, module2) {
769
- var fs5 = require("fs");
769
+ var fs6 = require("fs");
770
770
  var core;
771
771
  if (process.platform === "win32" || global.TESTING_WINDOWS) {
772
772
  core = require_windows();
@@ -775,7 +775,7 @@ var require_isexe = __commonJS({
775
775
  }
776
776
  module2.exports = isexe;
777
777
  isexe.sync = sync;
778
- function isexe(path9, options, cb) {
778
+ function isexe(path10, options, cb) {
779
779
  if (typeof options === "function") {
780
780
  cb = options;
781
781
  options = {};
@@ -785,7 +785,7 @@ var require_isexe = __commonJS({
785
785
  throw new TypeError("callback not provided");
786
786
  }
787
787
  return new Promise(function(resolve, reject) {
788
- isexe(path9, options || {}, function(er, is) {
788
+ isexe(path10, options || {}, function(er, is) {
789
789
  if (er) {
790
790
  reject(er);
791
791
  } else {
@@ -794,7 +794,7 @@ var require_isexe = __commonJS({
794
794
  });
795
795
  });
796
796
  }
797
- core(path9, options || {}, function(er, is) {
797
+ core(path10, options || {}, function(er, is) {
798
798
  if (er) {
799
799
  if (er.code === "EACCES" || options && options.ignoreErrors) {
800
800
  er = null;
@@ -804,9 +804,9 @@ var require_isexe = __commonJS({
804
804
  cb(er, is);
805
805
  });
806
806
  }
807
- function sync(path9, options) {
807
+ function sync(path10, options) {
808
808
  try {
809
- return core.sync(path9, options || {});
809
+ return core.sync(path10, options || {});
810
810
  } catch (er) {
811
811
  if (options && options.ignoreErrors || er.code === "EACCES") {
812
812
  return false;
@@ -822,7 +822,7 @@ var require_isexe = __commonJS({
822
822
  var require_which = __commonJS({
823
823
  "node_modules/which/which.js"(exports2, module2) {
824
824
  var isWindows = process.platform === "win32" || process.env.OSTYPE === "cygwin" || process.env.OSTYPE === "msys";
825
- var path9 = require("path");
825
+ var path10 = require("path");
826
826
  var COLON = isWindows ? ";" : ":";
827
827
  var isexe = require_isexe();
828
828
  var getNotFoundError = (cmd) => Object.assign(new Error(`not found: ${cmd}`), { code: "ENOENT" });
@@ -860,7 +860,7 @@ var require_which = __commonJS({
860
860
  return opt.all && found.length ? resolve(found) : reject(getNotFoundError(cmd));
861
861
  const ppRaw = pathEnv[i];
862
862
  const pathPart = /^".*"$/.test(ppRaw) ? ppRaw.slice(1, -1) : ppRaw;
863
- const pCmd = path9.join(pathPart, cmd);
863
+ const pCmd = path10.join(pathPart, cmd);
864
864
  const p = !pathPart && /^\.[\\\/]/.test(cmd) ? cmd.slice(0, 2) + pCmd : pCmd;
865
865
  resolve(subStep(p, i, 0));
866
866
  });
@@ -887,7 +887,7 @@ var require_which = __commonJS({
887
887
  for (let i = 0; i < pathEnv.length; i++) {
888
888
  const ppRaw = pathEnv[i];
889
889
  const pathPart = /^".*"$/.test(ppRaw) ? ppRaw.slice(1, -1) : ppRaw;
890
- const pCmd = path9.join(pathPart, cmd);
890
+ const pCmd = path10.join(pathPart, cmd);
891
891
  const p = !pathPart && /^\.[\\\/]/.test(cmd) ? cmd.slice(0, 2) + pCmd : pCmd;
892
892
  for (let j = 0; j < pathExt.length; j++) {
893
893
  const cur = p + pathExt[j];
@@ -4537,7 +4537,7 @@ __export(index_exports, {
4537
4537
  formatBlameText: () => formatBlameText
4538
4538
  });
4539
4539
  module.exports = __toCommonJS(index_exports);
4540
- var import_coc18 = require("coc.nvim");
4540
+ var import_coc19 = require("coc.nvim");
4541
4541
 
4542
4542
  // src/constants.ts
4543
4543
  var DEFAULT_TYPES = [
@@ -4673,12 +4673,12 @@ var Bcommits = class extends import_coc.BasicList {
4673
4673
  }, { tabPersist: true });
4674
4674
  this.addAction("view", async (item, context) => {
4675
4675
  let { commit, root, file } = item.data;
4676
- let { window: window12 } = context;
4676
+ let { window: window13 } = context;
4677
4677
  let content = (await this.manager.git.exec(root, ["show", `${commit}:${file}`])).stdout;
4678
4678
  let lines = content.replace(/\n$/, "").split("\n");
4679
4679
  let name = await nvim.call("fnameescape", [`(${commit}) ${file}`]);
4680
4680
  nvim.pauseNotification();
4681
- nvim.call("win_gotoid", [window12.id], true);
4681
+ nvim.call("win_gotoid", [window13.id], true);
4682
4682
  nvim.command(`tabe ${name}`, true);
4683
4683
  nvim.call("append", [0, lines], true);
4684
4684
  nvim.command("normal! Gdd", true);
@@ -4757,6 +4757,16 @@ var Bcommits = class extends import_coc.BasicList {
4757
4757
  // src/lists/branches.ts
4758
4758
  var import_coc2 = require("coc.nvim");
4759
4759
  var import_safe = __toESM(require_safe());
4760
+ function parseBranchLine(line) {
4761
+ const name = line.slice(2);
4762
+ if (!name || name.includes(" -> ")) return void 0;
4763
+ const remote = name.startsWith("remotes/");
4764
+ return {
4765
+ current: line[0] == "*",
4766
+ branch: remote ? name.slice("remotes/".length) : name,
4767
+ remote
4768
+ };
4769
+ }
4760
4770
  var Branches = class {
4761
4771
  constructor(nvim, manager) {
4762
4772
  this.manager = manager;
@@ -4828,15 +4838,14 @@ var Branches = class {
4828
4838
  if (output == null) return;
4829
4839
  output = output.replace(/\s+$/, "");
4830
4840
  for (let line of output.split(/\r?\n/)) {
4831
- let remote = line.slice(2).startsWith("remotes/");
4841
+ const data = parseBranchLine(line);
4842
+ if (!data) continue;
4832
4843
  res.push({
4833
4844
  label: import_safe.default.yellow(line.slice(0, 2)) + line.slice(2),
4834
4845
  filterText: line.slice(2),
4835
4846
  data: {
4836
- current: line[0] == "*",
4837
4847
  root,
4838
- branch: remote ? line.slice(10) : line.slice(2),
4839
- remote
4848
+ ...data
4840
4849
  }
4841
4850
  });
4842
4851
  }
@@ -5092,14 +5101,12 @@ var Gfiles = class extends import_coc4.BasicList {
5092
5101
  this.detail = "Pass git sha as first command argument, when empty, HEAD is used.\nExample: :CocList gfiles 7b5c5cb";
5093
5102
  this.defaultAction = "edit";
5094
5103
  this.actions = [];
5095
- const preferences = import_coc4.workspace.getConfiguration("coc.preferences");
5096
- let jumpCommand = preferences.get("jumpCommand", "edit");
5097
5104
  for (let name of ["edit", "tabe", "vsplit", "split"]) {
5098
5105
  this.addAction(name, async (item, ctx) => {
5099
5106
  let { root, sha, filepath, branch } = item.data;
5100
5107
  if (!sha) return;
5101
5108
  if (branch == "HEAD") {
5102
- let cmd2 = name == "edit" ? jumpCommand : name;
5109
+ let cmd2 = name == "edit" ? import_coc4.workspace.getConfiguration("coc.preferences").get("jumpCommand", "edit") : name;
5103
5110
  if (ctx.options.position === "tab") cmd2 = "tabe";
5104
5111
  let fullpath = import_path.default.join(root, filepath);
5105
5112
  await import_coc4.workspace.jumpTo(import_coc4.Uri.file(fullpath).toString(), null, cmd2);
@@ -5107,7 +5114,7 @@ var Gfiles = class extends import_coc4.BasicList {
5107
5114
  }
5108
5115
  let content = (await this.manager.git.exec(root, ["cat-file", "-p", sha])).stdout;
5109
5116
  let lines = content.replace(/\n$/, "").split("\n");
5110
- let cmd = name == "edit" ? jumpCommand : name;
5117
+ let cmd = name == "edit" ? import_coc4.workspace.getConfiguration("coc.preferences").get("jumpCommand", "edit") : name;
5111
5118
  let bufferName = await nvim.call("fnameescape", [`(${branch}) ${filepath}`]);
5112
5119
  nvim.pauseNotification();
5113
5120
  nvim.command(`${cmd} ${bufferName}`, true);
@@ -5169,6 +5176,21 @@ var import_safe2 = __toESM(require_safe());
5169
5176
  var import_fs = __toESM(require("fs"));
5170
5177
  var import_path3 = __toESM(require("path"));
5171
5178
 
5179
+ // src/model/statusEntry.ts
5180
+ function parseStatusEntries(output) {
5181
+ const result = [];
5182
+ const entries = output.split("\0");
5183
+ for (let i = 0; i < entries.length; i++) {
5184
+ const line = entries[i];
5185
+ if (!line) continue;
5186
+ result.push({ index: line[0], tree: line[1], relative: line.slice(3) });
5187
+ if (line[0] === "R" || line[0] === "C" || line[1] === "R" || line[1] === "C") {
5188
+ i++;
5189
+ }
5190
+ }
5191
+ return result;
5192
+ }
5193
+
5172
5194
  // src/util.ts
5173
5195
  var import_child_process = require("child_process");
5174
5196
  var import_coc5 = require("coc.nvim");
@@ -5200,7 +5222,7 @@ function quoteGitPath(filepath) {
5200
5222
  }
5201
5223
  function createUnstagePatch(relpath, chunk) {
5202
5224
  if (chunk.remove.count == 0 && chunk.add.count == 0) return "";
5203
- let head = `@@ -${chunk.add.lnum},${chunk.add.count} +${chunk.add.lnum + 1 - chunk.add.count},${chunk.remove.count} @@`;
5225
+ let head = `@@ -${chunk.add.lnum},${chunk.add.count} +${chunk.remove.lnum},${chunk.remove.count} @@`;
5204
5226
  if (!head) return "";
5205
5227
  const from = quoteGitPath(`a/${relpath}`);
5206
5228
  const to = quoteGitPath(`b/${relpath}`);
@@ -5316,15 +5338,22 @@ function getUrl(fix, repoURL, name, filepath, lines) {
5316
5338
  }
5317
5339
  const encodePath = (value) => value.split("/").map(encodeURIComponent).join("/");
5318
5340
  let url = repoURL + "/blob/" + encodePath(name) + "/" + encodePath(filepath) + (anchor ? "#" + encodeURIComponent(anchor) : "");
5319
- let parts = fix.split("|");
5320
- if (parts.length < 2) return url;
5341
+ const separator = fix.lastIndexOf("|");
5342
+ if (separator === -1) return url;
5321
5343
  try {
5322
- let match = RegExp(parts[0]), result = parts[1];
5344
+ let match = RegExp(fix.slice(0, separator)), result = fix.slice(separator + 1);
5323
5345
  return url.replace(match, result);
5324
5346
  } catch (_e) {
5325
5347
  return url;
5326
5348
  }
5327
5349
  }
5350
+ async function feedTreeToggleKey(nvim, configuredKey) {
5351
+ let key = configuredKey;
5352
+ if (/^<[^"\\\r\n]+>$/.test(configuredKey)) {
5353
+ key = await nvim.call("eval", [`"\\${configuredKey}"`]);
5354
+ }
5355
+ await nvim.call("feedkeys", [key, "in"]);
5356
+ }
5328
5357
  function parseVersion(raw) {
5329
5358
  return raw.replace(/^git version /, "");
5330
5359
  }
@@ -5335,20 +5364,20 @@ function findSystemGitWin32(base, onLookup) {
5335
5364
  return findSpecificGit(import_path2.default.join(base, "Git", "cmd", "git.exe"), onLookup);
5336
5365
  }
5337
5366
  function findGitWin32InPath(onLookup) {
5338
- const whichPromise = new Promise((c, e) => (0, import_which.default)("git.exe", (err, path9) => err ? e(err) : c(path9)));
5339
- return whichPromise.then((path9) => findSpecificGit(path9, onLookup));
5367
+ const whichPromise = new Promise((c, e) => (0, import_which.default)("git.exe", (err, path10) => err ? e(err) : c(path10)));
5368
+ return whichPromise.then((path10) => findSpecificGit(path10, onLookup));
5340
5369
  }
5341
5370
  function findGitWin32(onLookup) {
5342
5371
  return findSystemGitWin32(process.env["ProgramW6432"], onLookup).then(void 0, () => findSystemGitWin32(process.env["ProgramFiles(x86)"], onLookup)).then(void 0, () => findSystemGitWin32(process.env["ProgramFiles"], onLookup)).then(void 0, () => findSystemGitWin32(import_path2.default.join(process.env["LocalAppData"], "Programs"), onLookup)).then(void 0, () => findGitWin32InPath(onLookup));
5343
5372
  }
5344
- function findSpecificGit(path9, onLookup) {
5373
+ function findSpecificGit(path10, onLookup) {
5345
5374
  return new Promise((c, e) => {
5346
- onLookup(path9);
5375
+ onLookup(path10);
5347
5376
  const buffers = [];
5348
- const child = (0, import_child_process.spawn)(path9, ["--version"]);
5377
+ const child = (0, import_child_process.spawn)(path10, ["--version"]);
5349
5378
  child.stdout.on("data", (b) => buffers.push(b));
5350
5379
  child.on("error", cpErrorHandler(e));
5351
- child.on("exit", (code) => code ? e(new Error("Not found")) : c({ path: path9, version: parseVersion(Buffer.concat(buffers).toString("utf8").trim()) }));
5380
+ child.on("exit", (code) => code ? e(new Error("Not found")) : c({ path: path10, version: parseVersion(Buffer.concat(buffers).toString("utf8").trim()) }));
5352
5381
  });
5353
5382
  }
5354
5383
  function cpErrorHandler(cb) {
@@ -5365,9 +5394,9 @@ function findGitDarwin(onLookup) {
5365
5394
  if (err) {
5366
5395
  return e("git not found");
5367
5396
  }
5368
- const path9 = gitPathBuffer.toString().replace(/^\s+|\s+$/g, "");
5369
- if (path9 !== "/usr/bin/git") {
5370
- findSpecificGit(path9, onLookup).then(c, e);
5397
+ const path10 = gitPathBuffer.toString().replace(/^\s+|\s+$/g, "");
5398
+ if (path10 !== "/usr/bin/git") {
5399
+ findSpecificGit(path10, onLookup).then(c, e);
5371
5400
  return;
5372
5401
  }
5373
5402
  (0, import_child_process.exec)("xcode-select -p", (err2) => {
@@ -5375,7 +5404,7 @@ function findGitDarwin(onLookup) {
5375
5404
  e("git not found");
5376
5405
  return;
5377
5406
  }
5378
- findSpecificGit(path9, onLookup).then(c, e);
5407
+ findSpecificGit(path10, onLookup).then(c, e);
5379
5408
  });
5380
5409
  });
5381
5410
  });
@@ -5404,6 +5433,21 @@ function onceEvent(event) {
5404
5433
  }
5405
5434
 
5406
5435
  // src/lists/gstatus.ts
5436
+ async function commitWithFugitive(nvim, items) {
5437
+ let { root } = items[0].data;
5438
+ const cwd = await nvim.call("getcwd");
5439
+ let escapedRoot = await nvim.call("fnameescape", [root]);
5440
+ let escapedCwd = await nvim.call("fnameescape", [cwd]);
5441
+ await nvim.command(`lcd ${escapedRoot}`);
5442
+ try {
5443
+ let escapedFiles = await Promise.all(items.map((item) => nvim.call("fnameescape", [item.data.relative])));
5444
+ await nvim.command(`G commit -v -- ${escapedFiles.join(" ")}`);
5445
+ } catch (e) {
5446
+ import_coc6.window.showErrorMessage(`G commit command failed, make sure fugitive installed.`);
5447
+ } finally {
5448
+ await nvim.command(`lcd ${escapedCwd}`);
5449
+ }
5450
+ }
5407
5451
  var STATUS_MAP = {
5408
5452
  " ": " ",
5409
5453
  M: import_safe2.default.cyan("~"),
@@ -5416,19 +5460,6 @@ var STATUS_MAP = {
5416
5460
  "?": import_safe2.default.gray("?"),
5417
5461
  "!": import_safe2.default.gray("!")
5418
5462
  };
5419
- function parseStatusEntries(output) {
5420
- let result = [];
5421
- let entries = output.split("\0");
5422
- for (let i = 0; i < entries.length; i++) {
5423
- let line = entries[i];
5424
- if (!line) continue;
5425
- result.push({ index: line[0], tree: line[1], relative: line.slice(3) });
5426
- if (line[0] === "R" || line[0] === "C" || line[1] === "R" || line[1] === "C") {
5427
- i++;
5428
- }
5429
- }
5430
- return result;
5431
- }
5432
5463
  var GStatus = class extends import_coc6.BasicList {
5433
5464
  constructor(nvim, manager) {
5434
5465
  super();
@@ -5452,15 +5483,7 @@ var GStatus = class extends import_coc6.BasicList {
5452
5483
  }]);
5453
5484
  });
5454
5485
  this.addMultipleAction("commit", async (items) => {
5455
- let { root } = items[0].data;
5456
- let escapedRoot = await nvim.call("fnameescape", [root]);
5457
- await nvim.command(`lcd ${escapedRoot}`);
5458
- let escapedFiles = await Promise.all(items.map((item) => nvim.call("fnameescape", [item.data.relative])));
5459
- try {
5460
- await nvim.command(`G commit -v -- ${escapedFiles.join(" ")}`);
5461
- } catch (e) {
5462
- import_coc6.window.showErrorMessage(`G commit command failed, make sure fugitive installed.`);
5463
- }
5486
+ await commitWithFugitive(nvim, items);
5464
5487
  });
5465
5488
  this.addAction("reset", async (item) => {
5466
5489
  let { staged, tree, relative, root } = item.data;
@@ -5602,20 +5625,20 @@ var GChunks = class extends import_coc7.BasicList {
5602
5625
  let stagedDiff = await buf.repo.getStagedChunks(relpath);
5603
5626
  let chunks = (_a = Object.values(stagedDiff)[0]) != null ? _a : [];
5604
5627
  if (chunks.length > 0) {
5605
- for (let diff of chunks) {
5628
+ for (let chunk of chunks) {
5606
5629
  let adjust = 0;
5607
5630
  let stagedSign = import_safe3.default.green("*");
5608
- let line = diff.add.lnum;
5609
- for (let diff2 of diffs) {
5610
- if (diff2.end >= line) {
5631
+ let line = chunk.add.lnum;
5632
+ for (let unstagedDiff of diffs) {
5633
+ if (unstagedDiff.end >= line) {
5611
5634
  break;
5612
5635
  }
5613
- adjust += diff2.added.count;
5614
- adjust -= diff2.removed.count;
5636
+ adjust += unstagedDiff.added.count;
5637
+ adjust -= unstagedDiff.removed.count;
5615
5638
  }
5616
5639
  line += adjust;
5617
5640
  res.push({
5618
- label: `${stagedSign} Line:${line} ${diff.lines[0]}`,
5641
+ label: `${stagedSign} Line:${line} ${chunk.lines[0]}`,
5619
5642
  data: {
5620
5643
  line
5621
5644
  }
@@ -5698,8 +5721,8 @@ var GitStatus = class {
5698
5721
  if (!this._enabled) this.setGitStatus("");
5699
5722
  this.scheduleRefresh(0);
5700
5723
  }, null, this.disposables);
5701
- import_coc9.events.on("BufEnter", this.refresh, this, this.disposables);
5702
- import_coc9.events.on("FocusGained", this.refresh, this, this.disposables);
5724
+ import_coc9.events.on("BufEnter", () => this.scheduleRefresh(100), this, this.disposables);
5725
+ import_coc9.events.on("FocusGained", () => this.scheduleRefresh(100), this, this.disposables);
5703
5726
  import_coc9.events.on("BufWritePost", () => this.scheduleRefresh(50), this, this.disposables);
5704
5727
  this.disposables.push({ dispose: () => this.clearTimer() });
5705
5728
  this.scheduleRefresh(300);
@@ -6136,8 +6159,10 @@ var DocumentManager = class {
6136
6159
  import_coc10.window.showWarningMessage(`not belongs to git repository.`);
6137
6160
  return null;
6138
6161
  }
6139
- let repo = this.service.getRepoFromRoot(root);
6140
- return repo.getDiffAll(category);
6162
+ return this.getDiffAllForRoot(root, category);
6163
+ }
6164
+ async getDiffAllForRoot(root, category) {
6165
+ return this.service.getRepoFromRoot(root).getDiffAll(category);
6141
6166
  }
6142
6167
  dispose() {
6143
6168
  (0, import_coc10.disposeAll)(this.disposables);
@@ -6180,13 +6205,13 @@ function parseNameStatus(output) {
6180
6205
  }
6181
6206
  if (status === "R" || status === "C") {
6182
6207
  const oldPath = fields[index++];
6183
- const path9 = fields[index++];
6184
- if (!oldPath || !path9) throw parserError("name-status", "missing rename/copy path");
6185
- result.push({ status, score, oldPath, path: path9 });
6208
+ const path10 = fields[index++];
6209
+ if (!oldPath || !path10) throw parserError("name-status", "missing rename/copy path");
6210
+ result.push({ status, score, oldPath, path: path10 });
6186
6211
  } else {
6187
- const path9 = fields[index++];
6188
- if (!path9) throw parserError("name-status", "missing path");
6189
- result.push({ status, path: path9 });
6212
+ const path10 = fields[index++];
6213
+ if (!path10) throw parserError("name-status", "missing path");
6214
+ result.push({ status, path: path10 });
6190
6215
  }
6191
6216
  }
6192
6217
  return result;
@@ -6205,7 +6230,7 @@ function parseNumstat(output) {
6205
6230
  }
6206
6231
  const additionsText = record.slice(0, firstTab);
6207
6232
  const deletionsText = record.slice(firstTab + 1, secondTab);
6208
- const path9 = record.slice(secondTab + 1);
6233
+ const path10 = record.slice(secondTab + 1);
6209
6234
  const binary = additionsText === "-" || deletionsText === "-";
6210
6235
  if (binary && (additionsText !== "-" || deletionsText !== "-")) {
6211
6236
  throw parserError("numstat", "only binary records may contain -");
@@ -6213,9 +6238,9 @@ function parseNumstat(output) {
6213
6238
  if (!binary && (!/^\d+$/.test(additionsText) || !/^\d+$/.test(deletionsText))) {
6214
6239
  throw parserError("numstat", `invalid line counts in ${JSON.stringify(record)}`);
6215
6240
  }
6216
- if (path9) {
6241
+ if (path10) {
6217
6242
  result.push({
6218
- path: path9,
6243
+ path: path10,
6219
6244
  additions: binary ? void 0 : Number(additionsText),
6220
6245
  deletions: binary ? void 0 : Number(deletionsText),
6221
6246
  binary
@@ -6380,9 +6405,12 @@ function patchArguments(comparison, change) {
6380
6405
  return args;
6381
6406
  }
6382
6407
  function commitUri(comparison, relativePath) {
6408
+ return revisionUri(comparison.commit.sha, relativePath);
6409
+ }
6410
+ function revisionUri(revision, relativePath) {
6383
6411
  return import_coc11.Uri.from({
6384
6412
  scheme: COMMIT_DOCUMENT_SCHEME,
6385
- authority: comparison.commit.sha,
6413
+ authority: revision,
6386
6414
  path: `/${relativePath}`
6387
6415
  });
6388
6416
  }
@@ -6409,7 +6437,27 @@ var CommitDocumentProvider = class {
6409
6437
  }
6410
6438
  async open(root, comparison, change, targetWinId, line) {
6411
6439
  const uri = commitUri(comparison, change.path);
6412
- const resource = { uri, root, comparison, change };
6440
+ const resource = { kind: "comparison", uri, root, comparison, change };
6441
+ await this.openResource(resource, targetWinId, line);
6442
+ }
6443
+ async openRevision(root, revision, relativePath, targetWinId, line) {
6444
+ const result = await this.git.exec(root, ["rev-parse", "--verify", "--end-of-options", `${revision}^{commit}`]);
6445
+ const sha = result.stdout.trim();
6446
+ if (!sha) throw new Error(`Invalid Git revision: ${revision}`);
6447
+ const object = `${sha}:${relativePath}`;
6448
+ const type = (await this.git.exec(root, ["cat-file", "-t", object])).stdout.trim();
6449
+ if (type !== "blob") throw new Error(`Git path is not a file: ${relativePath}`);
6450
+ const resource = {
6451
+ kind: "revision",
6452
+ uri: revisionUri(sha, relativePath),
6453
+ root,
6454
+ revision: sha,
6455
+ relativePath
6456
+ };
6457
+ await this.openResource(resource, targetWinId, line);
6458
+ }
6459
+ async openResource(resource, targetWinId, line) {
6460
+ const { uri } = resource;
6413
6461
  this.resources.set(uri.toString(), resource);
6414
6462
  const moved = await import_coc11.workspace.nvim.call("win_gotoid", [targetWinId]);
6415
6463
  if (!moved) await import_coc11.workspace.nvim.command("new");
@@ -6430,6 +6478,14 @@ var CommitDocumentProvider = class {
6430
6478
  async load(resource, token) {
6431
6479
  if (resource.content !== void 0 && resource.hunks) return;
6432
6480
  const options = token ? { cancellationToken: token } : void 0;
6481
+ if (resource.kind === "revision") {
6482
+ const object2 = `${resource.revision}:${resource.relativePath}`;
6483
+ const content2 = await this.git.exec(resource.root, ["cat-file", "-p", object2], options);
6484
+ if (token == null ? void 0 : token.isCancellationRequested) return;
6485
+ resource.content = content2.stdout.replace(/\r?\n$/, "");
6486
+ resource.hunks = [];
6487
+ return;
6488
+ }
6433
6489
  const object = `${resource.comparison.commit.sha}:${resource.change.path}`;
6434
6490
  const [content, patch] = await Promise.all([
6435
6491
  this.git.exec(resource.root, ["cat-file", "-p", object], options),
@@ -7307,14 +7363,7 @@ var GitBuffer = class {
7307
7363
  import_coc12.window.showErrorMessage("Not positioned in git chunk");
7308
7364
  return;
7309
7365
  }
7310
- let head;
7311
- if (diff.changeType === "add" /* Add */) {
7312
- head = `@@ -${diff.removed.start + 1},0 +${diff.removed.start + 1},${diff.added.count} @@`;
7313
- } else if (diff.changeType === "delete" /* Delete */) {
7314
- head = `@@ -${diff.removed.start},${diff.removed.count} +${diff.removed.start},0 @@`;
7315
- } else if (diff.changeType === "changed" /* Change */) {
7316
- head = `@@ -${diff.removed.start},${diff.removed.count} +${diff.removed.start},${diff.added.count} @@`;
7317
- }
7366
+ const head = diff.head;
7318
7367
  const from = quoteGitPath(`a/${relpath}`);
7319
7368
  const to = quoteGitPath(`b/${relpath}`);
7320
7369
  const lines = [
@@ -8511,6 +8560,9 @@ var GitService = class {
8511
8560
  var import_coc16 = require("coc.nvim");
8512
8561
  var import_safe5 = __toESM(require_safe());
8513
8562
  var import_url2 = require("url");
8563
+ function isIssuePage(value) {
8564
+ return Array.isArray(value);
8565
+ }
8514
8566
  function byteSlice(content, start, end) {
8515
8567
  let buf = Buffer.from(content, "utf8");
8516
8568
  return buf.slice(start, end).toString("utf8");
@@ -8605,7 +8657,7 @@ function addSource(context, service) {
8605
8657
  const pageUri = `${uri}&page=${pageIndex}`;
8606
8658
  pageIndex++;
8607
8659
  let info = await (0, import_coc16.fetch)(pageUri, { headers: { "Private-Token": token } });
8608
- if (!info.length) {
8660
+ if (!isIssuePage(info) || info.length === 0) {
8609
8661
  break;
8610
8662
  }
8611
8663
  for (let i = 0, len = info.length; i < len; i++) {
@@ -8642,7 +8694,7 @@ function addSource(context, service) {
8642
8694
  page_idx++;
8643
8695
  try {
8644
8696
  let info = await (0, import_coc16.fetch)(page_uri, { headers });
8645
- if (info.length == 0) {
8697
+ if (!isIssuePage(info) || info.length === 0) {
8646
8698
  break;
8647
8699
  }
8648
8700
  for (let i = 0, len = info.length; i < len; i++) {
@@ -9092,9 +9144,7 @@ var CommitFilesController = class {
9092
9144
  const element = node;
9093
9145
  if (element.kind !== "root" && element.kind !== "directory") return;
9094
9146
  const configuredKey = import_coc17.workspace.getConfiguration("tree").get("key.toggle", "t");
9095
- const key = configuredKey.startsWith("<") && configuredKey.endsWith(">") ? `\\${configuredKey}` : configuredKey;
9096
- const escaped = key.replace(/\\/g, "\\\\").replace(/"/g, '\\"');
9097
- await import_coc17.workspace.nvim.call("eval", [`feedkeys("${escaped}", "in")`]);
9147
+ await feedTreeToggleKey(import_coc17.workspace.nvim, configuredKey);
9098
9148
  }
9099
9149
  async open(revision, requestedRoot, options = {}) {
9100
9150
  var _a;
@@ -9328,156 +9378,550 @@ var CommitFilesController = class {
9328
9378
  }
9329
9379
  };
9330
9380
 
9381
+ // src/tree/statusFiles.ts
9382
+ var import_fs5 = __toESM(require("fs"));
9383
+ var import_path9 = __toESM(require("path"));
9384
+ var import_coc18 = require("coc.nvim");
9385
+ function emptyAggregate2() {
9386
+ return { fileCount: 0, stagedCount: 0, unstagedCount: 0, untrackedCount: 0, conflictCount: 0 };
9387
+ }
9388
+ function isUntracked(entry) {
9389
+ return entry.index === "?" && entry.tree === "?";
9390
+ }
9391
+ function isConflict(entry) {
9392
+ return entry.index === "U" || entry.tree === "U" || entry.index + entry.tree === "AA" || entry.index + entry.tree === "DD";
9393
+ }
9394
+ function isStaged(entry) {
9395
+ return entry.index !== " " && entry.index !== "?" && entry.index !== "!";
9396
+ }
9397
+ function isUnstaged(entry) {
9398
+ return entry.tree !== " " && entry.tree !== "?" && entry.tree !== "!";
9399
+ }
9400
+ function addFileAggregate2(target, entry) {
9401
+ target.fileCount++;
9402
+ if (isStaged(entry)) target.stagedCount++;
9403
+ if (isUnstaged(entry)) target.unstagedCount++;
9404
+ if (isUntracked(entry)) target.untrackedCount++;
9405
+ if (isConflict(entry)) target.conflictCount++;
9406
+ }
9407
+ function addAggregate2(target, source) {
9408
+ target.fileCount += source.fileCount;
9409
+ target.stagedCount += source.stagedCount;
9410
+ target.unstagedCount += source.unstagedCount;
9411
+ target.untrackedCount += source.untrackedCount;
9412
+ target.conflictCount += source.conflictCount;
9413
+ }
9414
+ function compareNodes2(left, right) {
9415
+ if (left.kind === "directory" && right.kind !== "directory") return -1;
9416
+ if (left.kind !== "directory" && right.kind === "directory") return 1;
9417
+ return left.relativePath.localeCompare(right.relativePath);
9418
+ }
9419
+ function buildStatusTree(rootPath, entries) {
9420
+ const root = {
9421
+ ...emptyAggregate2(),
9422
+ kind: "root",
9423
+ id: `${rootPath}\0root`,
9424
+ name: import_path9.default.basename(rootPath) || rootPath,
9425
+ relativePath: "",
9426
+ parent: void 0,
9427
+ root: rootPath,
9428
+ children: []
9429
+ };
9430
+ const directories = /* @__PURE__ */ new Map();
9431
+ const ensureDirectory = (segments) => {
9432
+ if (!segments.length) return root;
9433
+ const relativePath = segments.join("/");
9434
+ const existing = directories.get(relativePath);
9435
+ if (existing) return existing;
9436
+ const parent = ensureDirectory(segments.slice(0, -1));
9437
+ const directory = {
9438
+ ...emptyAggregate2(),
9439
+ kind: "directory",
9440
+ id: `${rootPath}\0directory\0${relativePath}`,
9441
+ name: segments[segments.length - 1],
9442
+ relativePath,
9443
+ parent,
9444
+ children: []
9445
+ };
9446
+ directories.set(relativePath, directory);
9447
+ parent.children.push(directory);
9448
+ return directory;
9449
+ };
9450
+ for (const entry of entries) {
9451
+ const segments = entry.relative.split("/");
9452
+ const name = segments.pop();
9453
+ if (!name) continue;
9454
+ const parent = ensureDirectory(segments);
9455
+ parent.children.push({
9456
+ kind: "file",
9457
+ id: `${rootPath}\0file\0${entry.relative}`,
9458
+ name,
9459
+ relativePath: entry.relative,
9460
+ parent,
9461
+ entry
9462
+ });
9463
+ }
9464
+ const aggregate = (node) => {
9465
+ const own = emptyAggregate2();
9466
+ for (const child of node.children) {
9467
+ if (child.kind === "file") addFileAggregate2(own, child.entry);
9468
+ else {
9469
+ aggregate(child);
9470
+ addAggregate2(own, child);
9471
+ }
9472
+ }
9473
+ Object.assign(node, own);
9474
+ node.children.sort(compareNodes2);
9475
+ };
9476
+ aggregate(root);
9477
+ return root;
9478
+ }
9479
+ function firstFile(node) {
9480
+ for (const child of node.children) {
9481
+ if (child.kind === "file") return child;
9482
+ const file = firstFile(child);
9483
+ if (file) return file;
9484
+ }
9485
+ return void 0;
9486
+ }
9487
+ function escapeDisplay2(value) {
9488
+ return value.replace(/\r/g, "\\r").replace(/\n/g, "\\n").replace(/\t/g, "\\t");
9489
+ }
9490
+ var STATUS_NAMES = {
9491
+ M: "Modified",
9492
+ A: "Added",
9493
+ D: "Deleted",
9494
+ R: "Renamed",
9495
+ C: "Copied",
9496
+ T: "Type changed",
9497
+ U: "Unmerged"
9498
+ };
9499
+ function aggregateDescription(value) {
9500
+ const parts = [`${value.fileCount} file${value.fileCount === 1 ? "" : "s"}`];
9501
+ if (value.stagedCount) parts.push(`${value.stagedCount} staged`);
9502
+ if (value.unstagedCount) parts.push(`${value.unstagedCount} unstaged`);
9503
+ if (value.untrackedCount) parts.push(`${value.untrackedCount} untracked`);
9504
+ if (value.conflictCount) parts.push(`${value.conflictCount} conflicted`);
9505
+ return parts.join(" \xB7 ");
9506
+ }
9507
+ function fileDescription2(entry) {
9508
+ var _a, _b;
9509
+ const code = `[${entry.index}${entry.tree}]`;
9510
+ if (isUntracked(entry)) return `${code} \xB7 Untracked`;
9511
+ if (entry.index === "!" && entry.tree === "!") return `${code} \xB7 Ignored`;
9512
+ const parts = [code];
9513
+ if (isStaged(entry)) parts.push(`staged: ${(_a = STATUS_NAMES[entry.index]) != null ? _a : entry.index}`);
9514
+ if (isUnstaged(entry)) parts.push(`unstaged: ${(_b = STATUS_NAMES[entry.tree]) != null ? _b : entry.tree}`);
9515
+ if (isConflict(entry) && !parts.some((part) => part.includes("Unmerged"))) parts.push("conflicted");
9516
+ return parts.join(" \xB7 ");
9517
+ }
9518
+ function statusIcon2(entry) {
9519
+ if (isConflict(entry)) return { text: "!", hlGroup: "Error" };
9520
+ if (isUntracked(entry)) return { text: "?", hlGroup: "Comment" };
9521
+ const status = entry.tree !== " " ? entry.tree : entry.index;
9522
+ if (status === "A" || status === "C") return { text: "+", hlGroup: "DiffAdd" };
9523
+ if (status === "D") return { text: "-", hlGroup: "DiffDelete" };
9524
+ if (status === "R") return { text: "R", hlGroup: "DiffChange" };
9525
+ return { text: "~", hlGroup: "DiffChange" };
9526
+ }
9527
+ function toggleCommand(node) {
9528
+ return { command: "git.statusFiles.toggle", title: "Toggle directory", arguments: [node] };
9529
+ }
9530
+ var StatusFilesProvider = class {
9531
+ constructor(rootPath, entries, actions) {
9532
+ this.actions = actions;
9533
+ this.emitter = new import_coc18.Emitter();
9534
+ this.onDidChangeTreeData = this.emitter.event;
9535
+ this.root = buildStatusTree(rootPath, entries);
9536
+ }
9537
+ setEntries(entries) {
9538
+ this.root = buildStatusTree(this.root.root, entries);
9539
+ this.emitter.fire(void 0);
9540
+ }
9541
+ getTreeItem(element) {
9542
+ if (element.kind === "root") {
9543
+ const item2 = new import_coc18.TreeItem(escapeDisplay2(element.name), element.children.length ? import_coc18.TreeItemCollapsibleState.Expanded : import_coc18.TreeItemCollapsibleState.None);
9544
+ item2.id = element.id;
9545
+ item2.description = aggregateDescription(element);
9546
+ item2.tooltip = escapeDisplay2(element.root);
9547
+ item2.command = { command: "git.statusFiles.refresh", title: "Refresh Git status" };
9548
+ return item2;
9549
+ }
9550
+ if (element.kind === "directory") {
9551
+ const item2 = new import_coc18.TreeItem(escapeDisplay2(element.name), element.children.length ? import_coc18.TreeItemCollapsibleState.Expanded : import_coc18.TreeItemCollapsibleState.None);
9552
+ item2.id = element.id;
9553
+ item2.description = aggregateDescription(element);
9554
+ item2.tooltip = escapeDisplay2(element.relativePath);
9555
+ item2.command = toggleCommand(element);
9556
+ return item2;
9557
+ }
9558
+ const item = new import_coc18.TreeItem(escapeDisplay2(element.name), import_coc18.TreeItemCollapsibleState.None);
9559
+ item.id = element.id;
9560
+ item.icon = statusIcon2(element.entry);
9561
+ item.description = fileDescription2(element.entry);
9562
+ item.tooltip = `${escapeDisplay2(element.relativePath)}
9563
+ ${fileDescription2(element.entry)}`;
9564
+ item.command = { command: "git.statusFiles.open", title: "Open file", arguments: [element] };
9565
+ return item;
9566
+ }
9567
+ getChildren(element) {
9568
+ if (!element) return [this.root];
9569
+ return element.kind === "file" ? [] : element.children;
9570
+ }
9571
+ getParent(element) {
9572
+ return element.parent;
9573
+ }
9574
+ resolveActions(_item, element) {
9575
+ if (element.kind === "root") return [{ title: "Refresh", handler: () => this.actions.refresh() }];
9576
+ if (element.kind === "directory") return [{ title: "Copy directory path", handler: (node) => this.actions.copyPath(node) }];
9577
+ const actions = [
9578
+ { title: "Open file", handler: (node) => this.actions.openFile(node) },
9579
+ { title: "Copy relative path", handler: (node) => this.actions.copyPath(node) }
9580
+ ];
9581
+ const entry = element.entry;
9582
+ if (isUntracked(entry) || isUnstaged(entry)) actions.push({ title: "Add", handler: (node) => this.actions.addFile(node) });
9583
+ if (isStaged(entry)) actions.push({ title: "Restore staged changes", handler: (node) => this.actions.restoreStagedFile(node) });
9584
+ if (isUnstaged(entry) && !isUntracked(entry) && !isConflict(entry)) {
9585
+ actions.push({ title: "Restore working tree changes", handler: (node) => this.actions.restoreWorkingTreeFile(node) });
9586
+ }
9587
+ return actions;
9588
+ }
9589
+ dispose() {
9590
+ this.emitter.dispose();
9591
+ }
9592
+ };
9593
+ var StatusFilesController = class {
9594
+ constructor(manager, commitDocuments) {
9595
+ this.manager = manager;
9596
+ this.commitDocuments = commitDocuments;
9597
+ }
9598
+ async open(requestedRoot) {
9599
+ let root = requestedRoot;
9600
+ if (!root) root = await this.manager.resolveGitRootFromBufferOrCwd(await import_coc18.workspace.nvim.call("bufnr", ["%"]));
9601
+ if (!root) {
9602
+ import_coc18.window.showWarningMessage("Can't resolve git repository for current buffer or cwd.");
9603
+ return;
9604
+ }
9605
+ try {
9606
+ root = await this.manager.git.getRepositoryRoot(root);
9607
+ } catch (_e) {
9608
+ import_coc18.window.showWarningMessage("Can't resolve git repository for current buffer or cwd.");
9609
+ return;
9610
+ }
9611
+ const targetWinId = await import_coc18.workspace.nvim.call("win_getid");
9612
+ this.disposeSession();
9613
+ try {
9614
+ const entries = await this.loadEntries(root);
9615
+ const provider = new StatusFilesProvider(root, entries, this.actions);
9616
+ const view = import_coc18.window.createTreeView("git.statusFiles", {
9617
+ treeDataProvider: provider,
9618
+ enableFilter: true,
9619
+ winfixwidth: true,
9620
+ bufhidden: "wipe",
9621
+ canSelectMany: false,
9622
+ autoWidth: true
9623
+ });
9624
+ view.title = "Git Status";
9625
+ view.description = aggregateDescription(buildStatusTree(root, entries));
9626
+ this.session = { root, provider, view, targetWinId };
9627
+ await view.show(import_coc18.workspace.getConfiguration("git").get("statusTree.splitCommand", "belowright 40vs"));
9628
+ const file = firstFile(provider.getChildren()[0]);
9629
+ if (file) await view.reveal(file, { select: true, focus: true, expand: true });
9630
+ view.onDidChangeVisibility((event) => {
9631
+ var _a;
9632
+ if (!event.visible && ((_a = this.session) == null ? void 0 : _a.view) === view) this.disposeSession();
9633
+ });
9634
+ } catch (e) {
9635
+ this.disposeSession();
9636
+ import_coc18.window.showErrorMessage(`Failed to open Git Status: ${e.message}`);
9637
+ }
9638
+ }
9639
+ async toggle(node) {
9640
+ if (!node || typeof node !== "object") return;
9641
+ const element = node;
9642
+ if (element.kind !== "root" && element.kind !== "directory") return;
9643
+ const configuredKey = import_coc18.workspace.getConfiguration("tree").get("key.toggle", "t");
9644
+ await feedTreeToggleKey(import_coc18.workspace.nvim, configuredKey);
9645
+ }
9646
+ async refresh() {
9647
+ const session = this.session;
9648
+ if (!session) return;
9649
+ try {
9650
+ const entries = await this.loadEntries(session.root);
9651
+ if (this.session !== session) return;
9652
+ session.provider.setEntries(entries);
9653
+ session.view.description = aggregateDescription(buildStatusTree(session.root, entries));
9654
+ } catch (e) {
9655
+ import_coc18.window.showErrorMessage(`Failed to refresh Git Status: ${e.message}`);
9656
+ }
9657
+ }
9658
+ close() {
9659
+ this.disposeSession();
9660
+ }
9661
+ async openFile(node) {
9662
+ var _a, _b, _c;
9663
+ const session = this.session;
9664
+ if (!session) return;
9665
+ const absolute = import_path9.default.resolve(session.root, ...node.relativePath.split("/"));
9666
+ const relative = import_path9.default.relative(session.root, absolute);
9667
+ if (relative.startsWith(`..${import_path9.default.sep}`) || import_path9.default.isAbsolute(relative)) {
9668
+ import_coc18.window.showWarningMessage(`Working tree path is outside repository: ${escapeDisplay2(node.relativePath)}`);
9669
+ return;
9670
+ }
9671
+ let stat;
9672
+ try {
9673
+ stat = await import_fs5.default.promises.stat(absolute);
9674
+ } catch (error) {
9675
+ if (error.code !== "ENOENT" && error.code !== "ENOTDIR") {
9676
+ import_coc18.window.showErrorMessage(`Failed to inspect working tree path: ${escapeDisplay2(node.relativePath)}`);
9677
+ return;
9678
+ }
9679
+ try {
9680
+ await this.commitDocuments.openRevision(session.root, "HEAD", node.relativePath, session.targetWinId);
9681
+ } catch (_error) {
9682
+ import_coc18.window.showWarningMessage(`File not found in working tree or HEAD: ${escapeDisplay2(node.relativePath)}`);
9683
+ }
9684
+ return;
9685
+ }
9686
+ if (!stat.isFile()) {
9687
+ import_coc18.window.showWarningMessage(`Working tree path is not a file: ${escapeDisplay2(node.relativePath)}`);
9688
+ return;
9689
+ }
9690
+ let line = 1;
9691
+ try {
9692
+ const groups = await this.manager.getDiffAllForRoot(session.root, 0 /* All */);
9693
+ line = Math.max(1, (_c = (_b = (_a = groups.get(node.relativePath)) == null ? void 0 : _a[0]) == null ? void 0 : _b.start) != null ? _c : 1);
9694
+ } catch (_e) {
9695
+ }
9696
+ const moved = await import_coc18.workspace.nvim.call("win_gotoid", [session.targetWinId]);
9697
+ if (!moved) await import_coc18.workspace.nvim.command("new");
9698
+ try {
9699
+ await import_coc18.workspace.jumpTo(import_coc18.Uri.file(absolute), import_coc18.Position.create(line - 1, 0));
9700
+ } catch (e) {
9701
+ import_coc18.window.showErrorMessage(`Failed to open working tree file: ${e.message}`);
9702
+ }
9703
+ }
9704
+ async addFile(node) {
9705
+ await this.updateFile(node, ["add", "--", node.relativePath]);
9706
+ }
9707
+ async restoreStagedFile(node) {
9708
+ await this.updateFile(node, ["reset", "--", node.relativePath]);
9709
+ }
9710
+ async restoreWorkingTreeFile(node) {
9711
+ await this.updateFile(node, ["checkout", "--", node.relativePath]);
9712
+ }
9713
+ get actions() {
9714
+ return {
9715
+ refresh: () => this.refresh(),
9716
+ openFile: (node) => this.openFile(node),
9717
+ addFile: (node) => this.addFile(node),
9718
+ restoreStagedFile: (node) => this.restoreStagedFile(node),
9719
+ restoreWorkingTreeFile: (node) => this.restoreWorkingTreeFile(node),
9720
+ copyPath: (node) => import_coc18.workspace.nvim.call("setreg", ["+", node.relativePath]).then(() => void 0)
9721
+ };
9722
+ }
9723
+ async updateFile(node, args) {
9724
+ const session = this.session;
9725
+ if (!session) return;
9726
+ try {
9727
+ await this.manager.git.exec(session.root, args);
9728
+ await this.refresh();
9729
+ } catch (e) {
9730
+ import_coc18.window.showErrorMessage(`Failed to update Git status for ${escapeDisplay2(node.relativePath)}: ${e.message}`);
9731
+ }
9732
+ }
9733
+ async loadEntries(root) {
9734
+ const result = await this.manager.git.exec(root, ["status", "--porcelain=v1", "-z", "-uall"]);
9735
+ return parseStatusEntries(result.stdout);
9736
+ }
9737
+ disposeSession() {
9738
+ const session = this.session;
9739
+ if (!session) return;
9740
+ this.session = void 0;
9741
+ session.provider.dispose();
9742
+ session.view.dispose();
9743
+ }
9744
+ dispose() {
9745
+ this.close();
9746
+ }
9747
+ };
9748
+
9331
9749
  // src/index.ts
9332
9750
  async function activate(context) {
9333
9751
  var _a;
9334
- const config = import_coc18.workspace.getConfiguration("git");
9752
+ const config = import_coc19.workspace.getConfiguration("git");
9335
9753
  const { subscriptions } = context;
9336
9754
  let gitInfo;
9337
9755
  try {
9338
9756
  let pathHint = config.get("command", "git");
9339
- gitInfo = await findGit(pathHint, (path9) => context.logger.info(`Looking for git in: ${path9}`));
9757
+ gitInfo = await findGit(pathHint, (path10) => context.logger.info(`Looking for git in: ${path10}`));
9340
9758
  } catch (e) {
9341
- import_coc18.window.showErrorMessage("git command required for coc-git");
9759
+ import_coc19.window.showErrorMessage("git command required for coc-git");
9342
9760
  return;
9343
9761
  }
9344
- const virtualTextSrcId = await import_coc18.workspace.nvim.createNamespace("coc-git-virtual");
9345
- const conflictSrcId = await import_coc18.workspace.nvim.createNamespace("coc-git-conflicts");
9346
- const commitDocumentSrcId = await import_coc18.workspace.nvim.createNamespace("coc-git-commit-document");
9347
- const { nvim } = import_coc18.workspace;
9762
+ const virtualTextSrcId = await import_coc19.workspace.nvim.createNamespace("coc-git-virtual");
9763
+ const conflictSrcId = await import_coc19.workspace.nvim.createNamespace("coc-git-conflicts");
9764
+ const commitDocumentSrcId = await import_coc19.workspace.nvim.createNamespace("coc-git-commit-document");
9765
+ const { nvim } = import_coc19.workspace;
9348
9766
  const service = new GitService(gitInfo);
9349
9767
  const manager = new DocumentManager(nvim, service, virtualTextSrcId, conflictSrcId);
9350
9768
  subscriptions.push(manager);
9351
9769
  const commitDocuments = new CommitDocumentProvider(service.git, commitDocumentSrcId);
9352
9770
  subscriptions.push(commitDocuments);
9353
- subscriptions.push(import_coc18.workspace.registerTextDocumentContentProvider(COMMIT_DOCUMENT_SCHEME, commitDocuments));
9771
+ subscriptions.push(import_coc19.workspace.registerTextDocumentContentProvider(COMMIT_DOCUMENT_SCHEME, commitDocuments));
9354
9772
  nvim.command("highlight default link CocGitCommitAdd DiffAdd", true);
9355
9773
  nvim.command("highlight default link CocGitCommitDelete DiffDelete", true);
9356
9774
  const commitFiles = new CommitFilesController(manager);
9357
9775
  subscriptions.push(commitFiles);
9776
+ const statusFiles = new StatusFilesController(manager, commitDocuments);
9777
+ subscriptions.push(statusFiles);
9358
9778
  addSource(context, service);
9359
- subscriptions.push(import_coc18.commands.registerCommand("git.refresh", () => {
9779
+ subscriptions.push(import_coc19.commands.registerCommand("git.refresh", () => {
9360
9780
  manager.refresh();
9361
9781
  }));
9362
- subscriptions.push(import_coc18.workspace.registerKeymap(["n"], "git-nextchunk", async () => {
9782
+ subscriptions.push(import_coc19.commands.registerCommand("git.statusTree", async () => {
9783
+ await statusFiles.open();
9784
+ }));
9785
+ subscriptions.push(import_coc19.commands.registerCommand("git.statusFiles.open", async (node) => {
9786
+ await statusFiles.openFile(node);
9787
+ }, void 0, true));
9788
+ subscriptions.push(import_coc19.commands.registerCommand("git.statusFiles.add", async (node) => {
9789
+ await statusFiles.addFile(node);
9790
+ }, void 0, true));
9791
+ subscriptions.push(import_coc19.commands.registerCommand("git.statusFiles.restoreStaged", async (node) => {
9792
+ await statusFiles.restoreStagedFile(node);
9793
+ }, void 0, true));
9794
+ subscriptions.push(import_coc19.commands.registerCommand("git.statusFiles.restoreWorkingTree", async (node) => {
9795
+ await statusFiles.restoreWorkingTreeFile(node);
9796
+ }, void 0, true));
9797
+ subscriptions.push(import_coc19.commands.registerCommand("git.statusFiles.refresh", async () => {
9798
+ await statusFiles.refresh();
9799
+ }, void 0, true));
9800
+ subscriptions.push(import_coc19.commands.registerCommand("git.statusFiles.toggle", async (node) => {
9801
+ await statusFiles.toggle(node);
9802
+ }, void 0, true));
9803
+ subscriptions.push(import_coc19.commands.registerCommand("git.statusFiles.close", () => {
9804
+ statusFiles.close();
9805
+ }, void 0, true));
9806
+ subscriptions.push(import_coc19.workspace.registerKeymap(["n"], "git-nextchunk", async () => {
9363
9807
  if (!await commitDocuments.nextChunk()) await manager.nextChunk();
9364
9808
  }, { sync: false }));
9365
- subscriptions.push(import_coc18.workspace.registerKeymap(["n"], "git-prevchunk", async () => {
9809
+ subscriptions.push(import_coc19.workspace.registerKeymap(["n"], "git-prevchunk", async () => {
9366
9810
  if (!await commitDocuments.prevChunk()) await manager.prevChunk();
9367
9811
  }, { sync: false }));
9368
- subscriptions.push(import_coc18.workspace.registerKeymap(["n"], "git-nextconflict", async () => {
9812
+ subscriptions.push(import_coc19.workspace.registerKeymap(["n"], "git-nextconflict", async () => {
9369
9813
  await manager.nextConflict();
9370
9814
  }, { sync: false }));
9371
- subscriptions.push(import_coc18.workspace.registerKeymap(["n"], "git-prevconflict", async () => {
9815
+ subscriptions.push(import_coc19.workspace.registerKeymap(["n"], "git-prevconflict", async () => {
9372
9816
  await manager.prevConflict();
9373
9817
  }, { sync: false }));
9374
- subscriptions.push(import_coc18.workspace.registerKeymap(["n"], "git-keepcurrent", async () => {
9818
+ subscriptions.push(import_coc19.workspace.registerKeymap(["n"], "git-keepcurrent", async () => {
9375
9819
  await manager.keepCurrent();
9376
9820
  }, { sync: false }));
9377
- subscriptions.push(import_coc18.workspace.registerKeymap(["n"], "git-keepincoming", async () => {
9821
+ subscriptions.push(import_coc19.workspace.registerKeymap(["n"], "git-keepincoming", async () => {
9378
9822
  await manager.keepIncoming();
9379
9823
  }, { sync: false }));
9380
- subscriptions.push(import_coc18.workspace.registerKeymap(["n"], "git-keepboth", async () => {
9824
+ subscriptions.push(import_coc19.workspace.registerKeymap(["n"], "git-keepboth", async () => {
9381
9825
  await manager.keepBoth();
9382
9826
  }, { sync: false }));
9383
- subscriptions.push(import_coc18.workspace.registerKeymap(["n"], "git-chunkinfo", async () => {
9827
+ subscriptions.push(import_coc19.workspace.registerKeymap(["n"], "git-chunkinfo", async () => {
9384
9828
  await manager.chunkInfo();
9385
9829
  }, { sync: false }));
9386
- subscriptions.push(import_coc18.workspace.registerKeymap(["n"], "git-commit", async () => {
9830
+ subscriptions.push(import_coc19.workspace.registerKeymap(["n"], "git-commit", async () => {
9387
9831
  await manager.showCommit();
9388
9832
  }, { sync: false }));
9389
- subscriptions.push(import_coc18.workspace.registerKeymap(["n"], "git-showblamedoc", async () => {
9833
+ subscriptions.push(import_coc19.workspace.registerKeymap(["n"], "git-showblamedoc", async () => {
9390
9834
  await manager.showBlameDoc();
9391
9835
  }, { sync: false }));
9392
- subscriptions.push(import_coc18.commands.registerCommand("git.nextChunk", async () => {
9836
+ subscriptions.push(import_coc19.commands.registerCommand("git.nextChunk", async () => {
9393
9837
  if (!await commitDocuments.nextChunk()) await manager.nextChunk();
9394
9838
  }));
9395
- subscriptions.push(import_coc18.commands.registerCommand("git.prevChunk", async () => {
9839
+ subscriptions.push(import_coc19.commands.registerCommand("git.prevChunk", async () => {
9396
9840
  if (!await commitDocuments.prevChunk()) await manager.prevChunk();
9397
9841
  }));
9398
- subscriptions.push(import_coc18.commands.registerCommand("git.keepCurrent", async () => {
9842
+ subscriptions.push(import_coc19.commands.registerCommand("git.keepCurrent", async () => {
9399
9843
  await manager.keepCurrent();
9400
9844
  }));
9401
- subscriptions.push(import_coc18.commands.registerCommand("git.keepIncoming", async () => {
9845
+ subscriptions.push(import_coc19.commands.registerCommand("git.keepIncoming", async () => {
9402
9846
  await manager.keepIncoming();
9403
9847
  }));
9404
- subscriptions.push(import_coc18.commands.registerCommand("git.keepBoth", async () => {
9848
+ subscriptions.push(import_coc19.commands.registerCommand("git.keepBoth", async () => {
9405
9849
  await manager.keepBoth();
9406
9850
  }));
9407
- subscriptions.push(import_coc18.commands.registerCommand("git.chunkInfo", async () => {
9851
+ subscriptions.push(import_coc19.commands.registerCommand("git.chunkInfo", async () => {
9408
9852
  await manager.chunkInfo();
9409
9853
  }));
9410
- subscriptions.push(import_coc18.commands.registerCommand("git.allChunkInfo", async () => {
9854
+ subscriptions.push(import_coc19.commands.registerCommand("git.allChunkInfo", async () => {
9411
9855
  return await manager.allChunkInfo();
9412
9856
  }));
9413
- subscriptions.push(import_coc18.commands.registerCommand("git.chunkStage", async () => {
9857
+ subscriptions.push(import_coc19.commands.registerCommand("git.chunkStage", async () => {
9414
9858
  await manager.chunkStage();
9415
9859
  }));
9416
- subscriptions.push(import_coc18.commands.registerCommand("git.chunkUnstage", async () => {
9860
+ subscriptions.push(import_coc19.commands.registerCommand("git.chunkUnstage", async () => {
9417
9861
  await manager.chunkUnstage();
9418
9862
  }));
9419
- subscriptions.push(import_coc18.commands.registerCommand("git.chunkUndo", async () => {
9863
+ subscriptions.push(import_coc19.commands.registerCommand("git.chunkUndo", async () => {
9420
9864
  await manager.chunkUndo();
9421
9865
  }));
9422
- subscriptions.push(import_coc18.commands.registerCommand("git.showCommit", async () => {
9866
+ subscriptions.push(import_coc19.commands.registerCommand("git.showCommit", async () => {
9423
9867
  await manager.showCommit();
9424
9868
  }));
9425
- subscriptions.push(import_coc18.commands.registerCommand("git.commitFiles.open", async (revision, root) => {
9869
+ subscriptions.push(import_coc19.commands.registerCommand("git.commitFiles.open", async (revision, root) => {
9426
9870
  await commitFiles.open(revision, root);
9427
9871
  }, void 0, true));
9428
- subscriptions.push(import_coc18.commands.registerCommand("git.showCommitTree", async () => {
9872
+ subscriptions.push(import_coc19.commands.registerCommand("git.showCommitTree", async () => {
9429
9873
  const current = await manager.getCurrentCommit();
9430
9874
  if (current) await commitFiles.open(current.sha, current.root, { showCurrentFile: true, line: current.line });
9431
9875
  }));
9432
- subscriptions.push(import_coc18.commands.registerCommand("git.commitFiles.invoke", async (node) => {
9876
+ subscriptions.push(import_coc19.commands.registerCommand("git.commitFiles.invoke", async (node) => {
9433
9877
  await commitFiles.invoke(node);
9434
9878
  }, void 0, true));
9435
- subscriptions.push(import_coc18.commands.registerCommand("git.commitFiles.toggle", async (node) => {
9879
+ subscriptions.push(import_coc19.commands.registerCommand("git.commitFiles.toggle", async (node) => {
9436
9880
  await commitFiles.toggle(node);
9437
9881
  }, void 0, true));
9438
- subscriptions.push(import_coc18.commands.registerCommand("git.commitFiles.openDocument", async (root, comparison, change, targetWinId, line) => {
9882
+ subscriptions.push(import_coc19.commands.registerCommand("git.commitFiles.openDocument", async (root, comparison, change, targetWinId, line) => {
9439
9883
  targetWinId = targetWinId != null ? targetWinId : await nvim.call("win_getid");
9440
9884
  await commitDocuments.open(root, comparison, change, targetWinId, line);
9441
9885
  }, void 0, true));
9442
- subscriptions.push(import_coc18.commands.registerCommand("git.browserOpen", async () => {
9886
+ subscriptions.push(import_coc19.commands.registerCommand("git.browserOpen", async () => {
9443
9887
  await manager.browser();
9444
9888
  }));
9445
- subscriptions.push(import_coc18.commands.registerCommand("git.copyUrl", async (...args) => {
9889
+ subscriptions.push(import_coc19.commands.registerCommand("git.copyUrl", async (...args) => {
9446
9890
  await manager.browser("copy", args);
9447
9891
  }));
9448
- subscriptions.push(import_coc18.commands.registerCommand("git.copyPermalink", async (...args) => {
9892
+ subscriptions.push(import_coc19.commands.registerCommand("git.copyPermalink", async (...args) => {
9449
9893
  await manager.browser("copy", args, true);
9450
9894
  }));
9451
- subscriptions.push(import_coc18.commands.registerCommand("git.push", async (...args) => {
9895
+ subscriptions.push(import_coc19.commands.registerCommand("git.push", async (...args) => {
9452
9896
  await manager.push(args);
9453
9897
  }));
9454
- subscriptions.push(import_coc18.commands.registerCommand("git.diffCached", async () => {
9898
+ subscriptions.push(import_coc19.commands.registerCommand("git.diffCached", async () => {
9455
9899
  await manager.diffCached();
9456
9900
  }));
9457
- subscriptions.push(import_coc18.commands.registerCommand("git.toggleGutters", async () => {
9901
+ subscriptions.push(import_coc19.commands.registerCommand("git.toggleGutters", async () => {
9458
9902
  await manager.toggleGutters();
9459
9903
  }));
9460
- subscriptions.push(import_coc18.commands.registerCommand("git.foldUnchanged", async () => {
9904
+ subscriptions.push(import_coc19.commands.registerCommand("git.foldUnchanged", async () => {
9461
9905
  await manager.toggleFold();
9462
9906
  }));
9463
- subscriptions.push(import_coc18.commands.registerCommand("git.showBlameDoc", async () => {
9907
+ subscriptions.push(import_coc19.commands.registerCommand("git.showBlameDoc", async () => {
9464
9908
  await manager.showBlameDoc();
9465
9909
  }));
9466
- subscriptions.push(import_coc18.listManager.registerList(new GStatus(nvim, manager)));
9467
- subscriptions.push(import_coc18.listManager.registerList(new Branches(nvim, manager)));
9468
- subscriptions.push(import_coc18.listManager.registerList(new Commits(nvim, manager)));
9469
- subscriptions.push(import_coc18.listManager.registerList(new Bcommits(nvim, manager)));
9470
- subscriptions.push(import_coc18.listManager.registerList(new Gfiles(nvim, manager)));
9471
- subscriptions.push(import_coc18.listManager.registerList(new GChunks(nvim, manager)));
9472
- subscriptions.push(import_coc18.listManager.registerList(new GChanges(nvim, manager)));
9473
- subscriptions.push(import_coc18.languages.registerCompletionItemProvider("semantic-commit", "Commit", (_a = config.get("semanticCommit.filetypes")) != null ? _a : [], {
9910
+ subscriptions.push(import_coc19.listManager.registerList(new GStatus(nvim, manager)));
9911
+ subscriptions.push(import_coc19.listManager.registerList(new Branches(nvim, manager)));
9912
+ subscriptions.push(import_coc19.listManager.registerList(new Commits(nvim, manager)));
9913
+ subscriptions.push(import_coc19.listManager.registerList(new Bcommits(nvim, manager)));
9914
+ subscriptions.push(import_coc19.listManager.registerList(new Gfiles(nvim, manager)));
9915
+ subscriptions.push(import_coc19.listManager.registerList(new GChunks(nvim, manager)));
9916
+ subscriptions.push(import_coc19.listManager.registerList(new GChanges(nvim, manager)));
9917
+ subscriptions.push(import_coc19.languages.registerCompletionItemProvider("semantic-commit", "Commit", (_a = config.get("semanticCommit.filetypes")) != null ? _a : [], {
9474
9918
  provideCompletionItems: async (document, position) => {
9475
9919
  if (position.line !== 0) {
9476
9920
  return [];
9477
9921
  }
9478
9922
  const text = document.getText(
9479
- import_coc18.Range.create(
9480
- import_coc18.Position.create(position.line, 0),
9923
+ import_coc19.Range.create(
9924
+ import_coc19.Position.create(position.line, 0),
9481
9925
  position
9482
9926
  )
9483
9927
  );
@@ -9487,10 +9931,10 @@ async function activate(context) {
9487
9931
  return DEFAULT_TYPES.map((o) => {
9488
9932
  return {
9489
9933
  label: o.value,
9490
- kind: import_coc18.CompletionItemKind.Snippet,
9934
+ kind: import_coc19.CompletionItemKind.Snippet,
9491
9935
  documentation: { kind: "plaintext", value: o.name },
9492
9936
  // detail: o.name,
9493
- insertTextFormat: import_coc18.InsertTextFormat.Snippet,
9937
+ insertTextFormat: import_coc19.InsertTextFormat.Snippet,
9494
9938
  // tslint:disable-next-line: no-invalid-template-strings
9495
9939
  insertText: o.value + text2 + "\n\n"
9496
9940
  };
@@ -9499,12 +9943,12 @@ async function activate(context) {
9499
9943
  return [];
9500
9944
  }
9501
9945
  }));
9502
- subscriptions.push(import_coc18.workspace.registerKeymap(["o", "x"], "git-chunk-inner", async () => {
9946
+ subscriptions.push(import_coc19.workspace.registerKeymap(["o", "x"], "git-chunk-inner", async () => {
9503
9947
  let diff = await manager.getCurrentChunk();
9504
9948
  if (!diff) return;
9505
9949
  await nvim.command(`normal! ${diff.start}GV${diff.end}G`);
9506
9950
  }, { sync: true, silent: true }));
9507
- subscriptions.push(import_coc18.workspace.registerKeymap(["o", "x"], "git-chunk-outer", async () => {
9951
+ subscriptions.push(import_coc19.workspace.registerKeymap(["o", "x"], "git-chunk-outer", async () => {
9508
9952
  let diff = await manager.getCurrentChunk();
9509
9953
  if (!diff) return;
9510
9954
  let total = await nvim.call("line", ["$"]);