coc-git 2.7.9 → 2.7.10

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 fs4 = require("fs");
699
- function checkPathExt(path8, options) {
698
+ var fs5 = require("fs");
699
+ function checkPathExt(path9, 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 && path8.substr(-p.length).toLowerCase() === p) {
710
+ if (p && path9.substr(-p.length).toLowerCase() === p) {
711
711
  return true;
712
712
  }
713
713
  }
714
714
  return false;
715
715
  }
716
- function checkStat(stat, path8, options) {
716
+ function checkStat(stat, path9, options) {
717
717
  if (!stat.isSymbolicLink() && !stat.isFile()) {
718
718
  return false;
719
719
  }
720
- return checkPathExt(path8, options);
720
+ return checkPathExt(path9, options);
721
721
  }
722
- function isexe(path8, options, cb) {
723
- fs4.stat(path8, function(er, stat) {
724
- cb(er, er ? false : checkStat(stat, path8, options));
722
+ function isexe(path9, options, cb) {
723
+ fs5.stat(path9, function(er, stat) {
724
+ cb(er, er ? false : checkStat(stat, path9, options));
725
725
  });
726
726
  }
727
- function sync(path8, options) {
728
- return checkStat(fs4.statSync(path8), path8, options);
727
+ function sync(path9, options) {
728
+ return checkStat(fs5.statSync(path9), path9, 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 fs4 = require("fs");
739
- function isexe(path8, options, cb) {
740
- fs4.stat(path8, function(er, stat) {
738
+ var fs5 = require("fs");
739
+ function isexe(path9, options, cb) {
740
+ fs5.stat(path9, function(er, stat) {
741
741
  cb(er, er ? false : checkStat(stat, options));
742
742
  });
743
743
  }
744
- function sync(path8, options) {
745
- return checkStat(fs4.statSync(path8), options);
744
+ function sync(path9, options) {
745
+ return checkStat(fs5.statSync(path9), 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 fs4 = require("fs");
769
+ var fs5 = 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(path8, options, cb) {
778
+ function isexe(path9, 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(path8, options || {}, function(er, is) {
788
+ isexe(path9, 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(path8, options || {}, function(er, is) {
797
+ core(path9, 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(path8, options) {
807
+ function sync(path9, options) {
808
808
  try {
809
- return core.sync(path8, options || {});
809
+ return core.sync(path9, 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 path8 = require("path");
825
+ var path9 = 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 = path8.join(pathPart, cmd);
863
+ const pCmd = path9.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 = path8.join(pathPart, cmd);
890
+ const pCmd = path9.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];
@@ -971,7 +971,7 @@ var require_safer = __commonJS({
971
971
  "node_modules/safer-buffer/safer.js"(exports2, module2) {
972
972
  "use strict";
973
973
  var buffer = require("buffer");
974
- var Buffer2 = buffer.Buffer;
974
+ var Buffer3 = buffer.Buffer;
975
975
  var safer = {};
976
976
  var key;
977
977
  for (key in buffer) {
@@ -980,12 +980,12 @@ var require_safer = __commonJS({
980
980
  safer[key] = buffer[key];
981
981
  }
982
982
  var Safer = safer.Buffer = {};
983
- for (key in Buffer2) {
984
- if (!Buffer2.hasOwnProperty(key)) continue;
983
+ for (key in Buffer3) {
984
+ if (!Buffer3.hasOwnProperty(key)) continue;
985
985
  if (key === "allocUnsafe" || key === "allocUnsafeSlow") continue;
986
- Safer[key] = Buffer2[key];
986
+ Safer[key] = Buffer3[key];
987
987
  }
988
- safer.Buffer.prototype = Buffer2.prototype;
988
+ safer.Buffer.prototype = Buffer3.prototype;
989
989
  if (!Safer.from || Safer.from === Uint8Array.from) {
990
990
  Safer.from = function(value, encodingOrOffset, length) {
991
991
  if (typeof value === "number") {
@@ -994,7 +994,7 @@ var require_safer = __commonJS({
994
994
  if (value && typeof value.length === "undefined") {
995
995
  throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type " + typeof value);
996
996
  }
997
- return Buffer2(value, encodingOrOffset, length);
997
+ return Buffer3(value, encodingOrOffset, length);
998
998
  };
999
999
  }
1000
1000
  if (!Safer.alloc) {
@@ -1005,7 +1005,7 @@ var require_safer = __commonJS({
1005
1005
  if (size < 0 || size >= 2 * (1 << 30)) {
1006
1006
  throw new RangeError('The value "' + size + '" is invalid for option "size"');
1007
1007
  }
1008
- var buf = Buffer2(size);
1008
+ var buf = Buffer3(size);
1009
1009
  if (!fill || fill.length === 0) {
1010
1010
  buf.fill(0);
1011
1011
  } else if (typeof encoding === "string") {
@@ -1082,7 +1082,7 @@ var require_bom_handling = __commonJS({
1082
1082
  var require_internal = __commonJS({
1083
1083
  "node_modules/iconv-lite/encodings/internal.js"(exports2, module2) {
1084
1084
  "use strict";
1085
- var Buffer2 = require_safer().Buffer;
1085
+ var Buffer3 = require_safer().Buffer;
1086
1086
  module2.exports = {
1087
1087
  // Encodings
1088
1088
  utf8: { type: "_internal", bomAware: true },
@@ -1104,7 +1104,7 @@ var require_internal = __commonJS({
1104
1104
  else if (this.enc === "cesu8") {
1105
1105
  this.enc = "utf8";
1106
1106
  this.encoder = InternalEncoderCesu8;
1107
- if (Buffer2.from("eda0bdedb2a9", "hex").toString() !== "\u{1F4A9}") {
1107
+ if (Buffer3.from("eda0bdedb2a9", "hex").toString() !== "\u{1F4A9}") {
1108
1108
  this.decoder = InternalDecoderCesu8;
1109
1109
  this.defaultCharUnicode = iconv2.defaultCharUnicode;
1110
1110
  }
@@ -1120,8 +1120,8 @@ var require_internal = __commonJS({
1120
1120
  this.decoder = new StringDecoder(codec.enc);
1121
1121
  }
1122
1122
  InternalDecoder.prototype.write = function(buf) {
1123
- if (!Buffer2.isBuffer(buf)) {
1124
- buf = Buffer2.from(buf);
1123
+ if (!Buffer3.isBuffer(buf)) {
1124
+ buf = Buffer3.from(buf);
1125
1125
  }
1126
1126
  return this.decoder.write(buf);
1127
1127
  };
@@ -1132,7 +1132,7 @@ var require_internal = __commonJS({
1132
1132
  this.enc = codec.enc;
1133
1133
  }
1134
1134
  InternalEncoder.prototype.write = function(str) {
1135
- return Buffer2.from(str, this.enc);
1135
+ return Buffer3.from(str, this.enc);
1136
1136
  };
1137
1137
  InternalEncoder.prototype.end = function() {
1138
1138
  };
@@ -1144,15 +1144,15 @@ var require_internal = __commonJS({
1144
1144
  var completeQuads = str.length - str.length % 4;
1145
1145
  this.prevStr = str.slice(completeQuads);
1146
1146
  str = str.slice(0, completeQuads);
1147
- return Buffer2.from(str, "base64");
1147
+ return Buffer3.from(str, "base64");
1148
1148
  };
1149
1149
  InternalEncoderBase64.prototype.end = function() {
1150
- return Buffer2.from(this.prevStr, "base64");
1150
+ return Buffer3.from(this.prevStr, "base64");
1151
1151
  };
1152
1152
  function InternalEncoderCesu8(options, codec) {
1153
1153
  }
1154
1154
  InternalEncoderCesu8.prototype.write = function(str) {
1155
- var buf = Buffer2.alloc(str.length * 3), bufIdx = 0;
1155
+ var buf = Buffer3.alloc(str.length * 3), bufIdx = 0;
1156
1156
  for (var i = 0; i < str.length; i++) {
1157
1157
  var charCode = str.charCodeAt(i);
1158
1158
  if (charCode < 128)
@@ -1234,7 +1234,7 @@ var require_internal = __commonJS({
1234
1234
  var require_utf32 = __commonJS({
1235
1235
  "node_modules/iconv-lite/encodings/utf32.js"(exports2) {
1236
1236
  "use strict";
1237
- var Buffer2 = require_safer().Buffer;
1237
+ var Buffer3 = require_safer().Buffer;
1238
1238
  exports2._utf32 = Utf32Codec;
1239
1239
  function Utf32Codec(codecOptions, iconv2) {
1240
1240
  this.iconv = iconv2;
@@ -1252,8 +1252,8 @@ var require_utf32 = __commonJS({
1252
1252
  this.highSurrogate = 0;
1253
1253
  }
1254
1254
  Utf32Encoder.prototype.write = function(str) {
1255
- var src = Buffer2.from(str, "ucs2");
1256
- var dst = Buffer2.alloc(src.length * 2);
1255
+ var src = Buffer3.from(str, "ucs2");
1256
+ var dst = Buffer3.alloc(src.length * 2);
1257
1257
  var write32 = this.isLE ? dst.writeUInt32LE : dst.writeUInt32BE;
1258
1258
  var offset = 0;
1259
1259
  for (var i = 0; i < src.length; i += 2) {
@@ -1287,7 +1287,7 @@ var require_utf32 = __commonJS({
1287
1287
  Utf32Encoder.prototype.end = function() {
1288
1288
  if (!this.highSurrogate)
1289
1289
  return;
1290
- var buf = Buffer2.alloc(4);
1290
+ var buf = Buffer3.alloc(4);
1291
1291
  if (this.isLE)
1292
1292
  buf.writeUInt32LE(this.highSurrogate, 0);
1293
1293
  else
@@ -1305,7 +1305,7 @@ var require_utf32 = __commonJS({
1305
1305
  return "";
1306
1306
  var i = 0;
1307
1307
  var codepoint = 0;
1308
- var dst = Buffer2.alloc(src.length + 4);
1308
+ var dst = Buffer3.alloc(src.length + 4);
1309
1309
  var offset = 0;
1310
1310
  var isLE = this.isLE;
1311
1311
  var overflow = this.overflow;
@@ -1453,7 +1453,7 @@ var require_utf32 = __commonJS({
1453
1453
  var require_utf16 = __commonJS({
1454
1454
  "node_modules/iconv-lite/encodings/utf16.js"(exports2) {
1455
1455
  "use strict";
1456
- var Buffer2 = require_safer().Buffer;
1456
+ var Buffer3 = require_safer().Buffer;
1457
1457
  exports2.utf16be = Utf16BECodec;
1458
1458
  function Utf16BECodec() {
1459
1459
  }
@@ -1463,7 +1463,7 @@ var require_utf16 = __commonJS({
1463
1463
  function Utf16BEEncoder() {
1464
1464
  }
1465
1465
  Utf16BEEncoder.prototype.write = function(str) {
1466
- var buf = Buffer2.from(str, "ucs2");
1466
+ var buf = Buffer3.from(str, "ucs2");
1467
1467
  for (var i = 0; i < buf.length; i += 2) {
1468
1468
  var tmp = buf[i];
1469
1469
  buf[i] = buf[i + 1];
@@ -1479,7 +1479,7 @@ var require_utf16 = __commonJS({
1479
1479
  Utf16BEDecoder.prototype.write = function(buf) {
1480
1480
  if (buf.length == 0)
1481
1481
  return "";
1482
- var buf2 = Buffer2.alloc(buf.length + 1), i = 0, j = 0;
1482
+ var buf2 = Buffer3.alloc(buf.length + 1), i = 0, j = 0;
1483
1483
  if (this.overflowByte !== -1) {
1484
1484
  buf2[0] = buf[0];
1485
1485
  buf2[1] = this.overflowByte;
@@ -1587,7 +1587,7 @@ var require_utf16 = __commonJS({
1587
1587
  var require_utf7 = __commonJS({
1588
1588
  "node_modules/iconv-lite/encodings/utf7.js"(exports2) {
1589
1589
  "use strict";
1590
- var Buffer2 = require_safer().Buffer;
1590
+ var Buffer3 = require_safer().Buffer;
1591
1591
  exports2.utf7 = Utf7Codec;
1592
1592
  exports2.unicode11utf7 = "utf7";
1593
1593
  function Utf7Codec(codecOptions, iconv2) {
@@ -1601,7 +1601,7 @@ var require_utf7 = __commonJS({
1601
1601
  this.iconv = codec.iconv;
1602
1602
  }
1603
1603
  Utf7Encoder.prototype.write = function(str) {
1604
- return Buffer2.from(str.replace(nonDirectChars, function(chunk) {
1604
+ return Buffer3.from(str.replace(nonDirectChars, function(chunk) {
1605
1605
  return "+" + (chunk === "+" ? "" : this.iconv.encode(chunk, "utf16-be").toString("base64").replace(/=+$/, "")) + "-";
1606
1606
  }.bind(this)));
1607
1607
  };
@@ -1635,7 +1635,7 @@ var require_utf7 = __commonJS({
1635
1635
  res += "+";
1636
1636
  } else {
1637
1637
  var b64str = base64Accum + this.iconv.decode(buf.slice(lastI, i2), "ascii");
1638
- res += this.iconv.decode(Buffer2.from(b64str, "base64"), "utf16-be");
1638
+ res += this.iconv.decode(Buffer3.from(b64str, "base64"), "utf16-be");
1639
1639
  }
1640
1640
  if (buf[i2] != minusChar)
1641
1641
  i2--;
@@ -1652,7 +1652,7 @@ var require_utf7 = __commonJS({
1652
1652
  var canBeDecoded = b64str.length - b64str.length % 8;
1653
1653
  base64Accum = b64str.slice(canBeDecoded);
1654
1654
  b64str = b64str.slice(0, canBeDecoded);
1655
- res += this.iconv.decode(Buffer2.from(b64str, "base64"), "utf16-be");
1655
+ res += this.iconv.decode(Buffer3.from(b64str, "base64"), "utf16-be");
1656
1656
  }
1657
1657
  this.inBase64 = inBase64;
1658
1658
  this.base64Accum = base64Accum;
@@ -1661,7 +1661,7 @@ var require_utf7 = __commonJS({
1661
1661
  Utf7Decoder.prototype.end = function() {
1662
1662
  var res = "";
1663
1663
  if (this.inBase64 && this.base64Accum.length > 0)
1664
- res = this.iconv.decode(Buffer2.from(this.base64Accum, "base64"), "utf16-be");
1664
+ res = this.iconv.decode(Buffer3.from(this.base64Accum, "base64"), "utf16-be");
1665
1665
  this.inBase64 = false;
1666
1666
  this.base64Accum = "";
1667
1667
  return res;
@@ -1676,11 +1676,11 @@ var require_utf7 = __commonJS({
1676
1676
  function Utf7IMAPEncoder(options, codec) {
1677
1677
  this.iconv = codec.iconv;
1678
1678
  this.inBase64 = false;
1679
- this.base64Accum = Buffer2.alloc(6);
1679
+ this.base64Accum = Buffer3.alloc(6);
1680
1680
  this.base64AccumIdx = 0;
1681
1681
  }
1682
1682
  Utf7IMAPEncoder.prototype.write = function(str) {
1683
- var inBase64 = this.inBase64, base64Accum = this.base64Accum, base64AccumIdx = this.base64AccumIdx, buf = Buffer2.alloc(str.length * 5 + 10), bufIdx = 0;
1683
+ var inBase64 = this.inBase64, base64Accum = this.base64Accum, base64AccumIdx = this.base64AccumIdx, buf = Buffer3.alloc(str.length * 5 + 10), bufIdx = 0;
1684
1684
  for (var i2 = 0; i2 < str.length; i2++) {
1685
1685
  var uChar = str.charCodeAt(i2);
1686
1686
  if (32 <= uChar && uChar <= 126) {
@@ -1717,7 +1717,7 @@ var require_utf7 = __commonJS({
1717
1717
  return buf.slice(0, bufIdx);
1718
1718
  };
1719
1719
  Utf7IMAPEncoder.prototype.end = function() {
1720
- var buf = Buffer2.alloc(10), bufIdx = 0;
1720
+ var buf = Buffer3.alloc(10), bufIdx = 0;
1721
1721
  if (this.inBase64) {
1722
1722
  if (this.base64AccumIdx > 0) {
1723
1723
  bufIdx += buf.write(this.base64Accum.slice(0, this.base64AccumIdx).toString("base64").replace(/\//g, ",").replace(/=+$/, ""), bufIdx);
@@ -1750,7 +1750,7 @@ var require_utf7 = __commonJS({
1750
1750
  res += "&";
1751
1751
  } else {
1752
1752
  var b64str = base64Accum + this.iconv.decode(buf.slice(lastI, i2), "ascii").replace(/,/g, "/");
1753
- res += this.iconv.decode(Buffer2.from(b64str, "base64"), "utf16-be");
1753
+ res += this.iconv.decode(Buffer3.from(b64str, "base64"), "utf16-be");
1754
1754
  }
1755
1755
  if (buf[i2] != minusChar)
1756
1756
  i2--;
@@ -1767,7 +1767,7 @@ var require_utf7 = __commonJS({
1767
1767
  var canBeDecoded = b64str.length - b64str.length % 8;
1768
1768
  base64Accum = b64str.slice(canBeDecoded);
1769
1769
  b64str = b64str.slice(0, canBeDecoded);
1770
- res += this.iconv.decode(Buffer2.from(b64str, "base64"), "utf16-be");
1770
+ res += this.iconv.decode(Buffer3.from(b64str, "base64"), "utf16-be");
1771
1771
  }
1772
1772
  this.inBase64 = inBase64;
1773
1773
  this.base64Accum = base64Accum;
@@ -1776,7 +1776,7 @@ var require_utf7 = __commonJS({
1776
1776
  Utf7IMAPDecoder.prototype.end = function() {
1777
1777
  var res = "";
1778
1778
  if (this.inBase64 && this.base64Accum.length > 0)
1779
- res = this.iconv.decode(Buffer2.from(this.base64Accum, "base64"), "utf16-be");
1779
+ res = this.iconv.decode(Buffer3.from(this.base64Accum, "base64"), "utf16-be");
1780
1780
  this.inBase64 = false;
1781
1781
  this.base64Accum = "";
1782
1782
  return res;
@@ -1788,7 +1788,7 @@ var require_utf7 = __commonJS({
1788
1788
  var require_sbcs_codec = __commonJS({
1789
1789
  "node_modules/iconv-lite/encodings/sbcs-codec.js"(exports2) {
1790
1790
  "use strict";
1791
- var Buffer2 = require_safer().Buffer;
1791
+ var Buffer3 = require_safer().Buffer;
1792
1792
  exports2._sbcs = SBCSCodec;
1793
1793
  function SBCSCodec(codecOptions, iconv2) {
1794
1794
  if (!codecOptions)
@@ -1801,8 +1801,8 @@ var require_sbcs_codec = __commonJS({
1801
1801
  asciiString += String.fromCharCode(i);
1802
1802
  codecOptions.chars = asciiString + codecOptions.chars;
1803
1803
  }
1804
- this.decodeBuf = Buffer2.from(codecOptions.chars, "ucs2");
1805
- var encodeBuf = Buffer2.alloc(65536, iconv2.defaultCharSingleByte.charCodeAt(0));
1804
+ this.decodeBuf = Buffer3.from(codecOptions.chars, "ucs2");
1805
+ var encodeBuf = Buffer3.alloc(65536, iconv2.defaultCharSingleByte.charCodeAt(0));
1806
1806
  for (var i = 0; i < codecOptions.chars.length; i++)
1807
1807
  encodeBuf[codecOptions.chars.charCodeAt(i)] = i;
1808
1808
  this.encodeBuf = encodeBuf;
@@ -1813,7 +1813,7 @@ var require_sbcs_codec = __commonJS({
1813
1813
  this.encodeBuf = codec.encodeBuf;
1814
1814
  }
1815
1815
  SBCSEncoder.prototype.write = function(str) {
1816
- var buf = Buffer2.alloc(str.length);
1816
+ var buf = Buffer3.alloc(str.length);
1817
1817
  for (var i = 0; i < str.length; i++)
1818
1818
  buf[i] = this.encodeBuf[str.charCodeAt(i)];
1819
1819
  return buf;
@@ -1825,7 +1825,7 @@ var require_sbcs_codec = __commonJS({
1825
1825
  }
1826
1826
  SBCSDecoder.prototype.write = function(buf) {
1827
1827
  var decodeBuf = this.decodeBuf;
1828
- var newBuf = Buffer2.alloc(buf.length * 2);
1828
+ var newBuf = Buffer3.alloc(buf.length * 2);
1829
1829
  var idx1 = 0, idx2 = 0;
1830
1830
  for (var i = 0; i < buf.length; i++) {
1831
1831
  idx1 = buf[i] * 2;
@@ -2452,7 +2452,7 @@ var require_sbcs_data_generated = __commonJS({
2452
2452
  var require_dbcs_codec = __commonJS({
2453
2453
  "node_modules/iconv-lite/encodings/dbcs-codec.js"(exports2) {
2454
2454
  "use strict";
2455
- var Buffer2 = require_safer().Buffer;
2455
+ var Buffer3 = require_safer().Buffer;
2456
2456
  exports2._dbcs = DBCSCodec;
2457
2457
  var UNASSIGNED = -1;
2458
2458
  var GB18030_CODE = -2;
@@ -2664,7 +2664,7 @@ var require_dbcs_codec = __commonJS({
2664
2664
  this.gb18030 = codec.gb18030;
2665
2665
  }
2666
2666
  DBCSEncoder.prototype.write = function(str) {
2667
- var newBuf = Buffer2.alloc(str.length * (this.gb18030 ? 4 : 3)), leadSurrogate = this.leadSurrogate, seqObj = this.seqObj, nextChar = -1, i2 = 0, j = 0;
2667
+ var newBuf = Buffer3.alloc(str.length * (this.gb18030 ? 4 : 3)), leadSurrogate = this.leadSurrogate, seqObj = this.seqObj, nextChar = -1, i2 = 0, j = 0;
2668
2668
  while (true) {
2669
2669
  if (nextChar === -1) {
2670
2670
  if (i2 == str.length) break;
@@ -2760,7 +2760,7 @@ var require_dbcs_codec = __commonJS({
2760
2760
  DBCSEncoder.prototype.end = function() {
2761
2761
  if (this.leadSurrogate === -1 && this.seqObj === void 0)
2762
2762
  return;
2763
- var newBuf = Buffer2.alloc(10), j = 0;
2763
+ var newBuf = Buffer3.alloc(10), j = 0;
2764
2764
  if (this.seqObj) {
2765
2765
  var dbcsCode = this.seqObj[DEF_CHAR];
2766
2766
  if (dbcsCode !== void 0) {
@@ -2790,7 +2790,7 @@ var require_dbcs_codec = __commonJS({
2790
2790
  this.gb18030 = codec.gb18030;
2791
2791
  }
2792
2792
  DBCSDecoder.prototype.write = function(buf) {
2793
- var newBuf = Buffer2.alloc(buf.length * 2), nodeIdx = this.nodeIdx, prevBytes = this.prevBytes, prevOffset = this.prevBytes.length, seqStart = -this.prevBytes.length, uCode;
2793
+ var newBuf = Buffer3.alloc(buf.length * 2), nodeIdx = this.nodeIdx, prevBytes = this.prevBytes, prevOffset = this.prevBytes.length, seqStart = -this.prevBytes.length, uCode;
2794
2794
  for (var i2 = 0, j = 0; i2 < buf.length; i2++) {
2795
2795
  var curByte = i2 >= 0 ? buf[i2] : prevBytes[i2 + prevOffset];
2796
2796
  var uCode = this.decodeTables[nodeIdx][curByte];
@@ -4319,7 +4319,7 @@ var require_encodings = __commonJS({
4319
4319
  var require_streams = __commonJS({
4320
4320
  "node_modules/iconv-lite/lib/streams.js"(exports2, module2) {
4321
4321
  "use strict";
4322
- var Buffer2 = require_safer().Buffer;
4322
+ var Buffer3 = require_safer().Buffer;
4323
4323
  module2.exports = function(stream_module) {
4324
4324
  var Transform = stream_module.Transform;
4325
4325
  function IconvLiteEncoderStream(conv, options) {
@@ -4358,7 +4358,7 @@ var require_streams = __commonJS({
4358
4358
  chunks.push(chunk);
4359
4359
  });
4360
4360
  this.on("end", function() {
4361
- cb(null, Buffer2.concat(chunks));
4361
+ cb(null, Buffer3.concat(chunks));
4362
4362
  });
4363
4363
  return this;
4364
4364
  };
@@ -4372,7 +4372,7 @@ var require_streams = __commonJS({
4372
4372
  constructor: { value: IconvLiteDecoderStream }
4373
4373
  });
4374
4374
  IconvLiteDecoderStream.prototype._transform = function(chunk, encoding, done) {
4375
- if (!Buffer2.isBuffer(chunk) && !(chunk instanceof Uint8Array))
4375
+ if (!Buffer3.isBuffer(chunk) && !(chunk instanceof Uint8Array))
4376
4376
  return done(new Error("Iconv decoding stream needs buffers as its input."));
4377
4377
  try {
4378
4378
  var res = this.conv.write(chunk);
@@ -4414,7 +4414,7 @@ var require_streams = __commonJS({
4414
4414
  var require_lib = __commonJS({
4415
4415
  "node_modules/iconv-lite/lib/index.js"(exports2, module2) {
4416
4416
  "use strict";
4417
- var Buffer2 = require_safer().Buffer;
4417
+ var Buffer3 = require_safer().Buffer;
4418
4418
  var bomHandling = require_bom_handling();
4419
4419
  var iconv2 = module2.exports;
4420
4420
  iconv2.encodings = null;
@@ -4425,7 +4425,7 @@ var require_lib = __commonJS({
4425
4425
  var encoder = iconv2.getEncoder(encoding, options);
4426
4426
  var res = encoder.write(str);
4427
4427
  var trail = encoder.end();
4428
- return trail && trail.length > 0 ? Buffer2.concat([res, trail]) : res;
4428
+ return trail && trail.length > 0 ? Buffer3.concat([res, trail]) : res;
4429
4429
  };
4430
4430
  iconv2.decode = function decode(buf, encoding, options) {
4431
4431
  if (typeof buf === "string") {
@@ -4433,7 +4433,7 @@ var require_lib = __commonJS({
4433
4433
  console.error("Iconv-lite warning: decode()-ing strings is deprecated. Refer to https://github.com/ashtuchkin/iconv-lite/wiki/Use-Buffers-when-decoding");
4434
4434
  iconv2.skipDecodeWarning = true;
4435
4435
  }
4436
- buf = Buffer2.from("" + (buf || ""), "binary");
4436
+ buf = Buffer3.from("" + (buf || ""), "binary");
4437
4437
  }
4438
4438
  var decoder = iconv2.getDecoder(encoding, options);
4439
4439
  var res = decoder.write(buf);
@@ -4537,7 +4537,7 @@ __export(index_exports, {
4537
4537
  formatBlameText: () => formatBlameText
4538
4538
  });
4539
4539
  module.exports = __toCommonJS(index_exports);
4540
- var import_coc16 = require("coc.nvim");
4540
+ var import_coc18 = 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: window10 } = context;
4676
+ let { window: window12 } = 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", [window10.id], true);
4681
+ nvim.call("win_gotoid", [window12.id], true);
4682
4682
  nvim.command(`tabe ${name}`, true);
4683
4683
  nvim.call("append", [0, lines], true);
4684
4684
  nvim.command("normal! Gdd", true);
@@ -4709,6 +4709,11 @@ var Bcommits = class extends import_coc.BasicList {
4709
4709
  nvim.command(`call setpos('.', [bufnr('%'), 0, 0, 0])`, true);
4710
4710
  await nvim.resumeNotification();
4711
4711
  });
4712
+ this.addAction("changes", async (item) => {
4713
+ let { commit, root } = item.data;
4714
+ if (!commit) return;
4715
+ await import_coc.commands.executeCommand("git.commitFiles.open", commit, root);
4716
+ });
4712
4717
  import_coc.events.on("BufEnter", async (bufnr) => {
4713
4718
  if (!this.bufnr || bufnr != this.bufnr) return;
4714
4719
  let diff = await nvim.eval("&diff");
@@ -5024,6 +5029,11 @@ var Commits = class extends import_coc3.BasicList {
5024
5029
  if (!commit) return;
5025
5030
  nvim.command(`CocList gfiles ${commit}`, true);
5026
5031
  });
5032
+ this.addAction("changes", async (item) => {
5033
+ let { commit, root } = item.data;
5034
+ if (!commit) return;
5035
+ await import_coc3.commands.executeCommand("git.commitFiles.open", commit, root);
5036
+ });
5027
5037
  }
5028
5038
  cacheKey(root, commit) {
5029
5039
  return `${root}\0${commit}`;
@@ -5325,20 +5335,20 @@ function findSystemGitWin32(base, onLookup) {
5325
5335
  return findSpecificGit(import_path2.default.join(base, "Git", "cmd", "git.exe"), onLookup);
5326
5336
  }
5327
5337
  function findGitWin32InPath(onLookup) {
5328
- const whichPromise = new Promise((c, e) => (0, import_which.default)("git.exe", (err, path8) => err ? e(err) : c(path8)));
5329
- return whichPromise.then((path8) => findSpecificGit(path8, 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));
5330
5340
  }
5331
5341
  function findGitWin32(onLookup) {
5332
5342
  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));
5333
5343
  }
5334
- function findSpecificGit(path8, onLookup) {
5344
+ function findSpecificGit(path9, onLookup) {
5335
5345
  return new Promise((c, e) => {
5336
- onLookup(path8);
5346
+ onLookup(path9);
5337
5347
  const buffers = [];
5338
- const child = (0, import_child_process.spawn)(path8, ["--version"]);
5348
+ const child = (0, import_child_process.spawn)(path9, ["--version"]);
5339
5349
  child.stdout.on("data", (b) => buffers.push(b));
5340
5350
  child.on("error", cpErrorHandler(e));
5341
- child.on("exit", (code) => code ? e(new Error("Not found")) : c({ path: path8, version: parseVersion(Buffer.concat(buffers).toString("utf8").trim()) }));
5351
+ child.on("exit", (code) => code ? e(new Error("Not found")) : c({ path: path9, version: parseVersion(Buffer.concat(buffers).toString("utf8").trim()) }));
5342
5352
  });
5343
5353
  }
5344
5354
  function cpErrorHandler(cb) {
@@ -5355,9 +5365,9 @@ function findGitDarwin(onLookup) {
5355
5365
  if (err) {
5356
5366
  return e("git not found");
5357
5367
  }
5358
- const path8 = gitPathBuffer.toString().replace(/^\s+|\s+$/g, "");
5359
- if (path8 !== "/usr/bin/git") {
5360
- findSpecificGit(path8, onLookup).then(c, e);
5368
+ const path9 = gitPathBuffer.toString().replace(/^\s+|\s+$/g, "");
5369
+ if (path9 !== "/usr/bin/git") {
5370
+ findSpecificGit(path9, onLookup).then(c, e);
5361
5371
  return;
5362
5372
  }
5363
5373
  (0, import_child_process.exec)("xcode-select -p", (err2) => {
@@ -5365,7 +5375,7 @@ function findGitDarwin(onLookup) {
5365
5375
  e("git not found");
5366
5376
  return;
5367
5377
  }
5368
- findSpecificGit(path8, onLookup).then(c, e);
5378
+ findSpecificGit(path9, onLookup).then(c, e);
5369
5379
  });
5370
5380
  });
5371
5381
  });
@@ -6056,6 +6066,13 @@ var DocumentManager = class {
6056
6066
  let buf = await this.buffer;
6057
6067
  if (buf) await buf.showCommit();
6058
6068
  }
6069
+ async getCurrentCommit() {
6070
+ let buf = await this.buffer;
6071
+ if (!buf) return void 0;
6072
+ let current = await buf.getCurrentCommit();
6073
+ if (!current) return void 0;
6074
+ return { sha: current.sha, root: buf.repo.root, line: current.line };
6075
+ }
6059
6076
  async showBlameDoc() {
6060
6077
  let buf = await this.buffer;
6061
6078
  let line = await this.nvim.call("line", ".");
@@ -6133,11 +6150,350 @@ var DocumentManager = class {
6133
6150
  }
6134
6151
  };
6135
6152
 
6153
+ // src/model/commitDocument.ts
6154
+ var import_coc11 = require("coc.nvim");
6155
+
6156
+ // src/model/commit.ts
6157
+ function parserError(kind, detail) {
6158
+ return new Error(`Invalid Git ${kind} output: ${detail}`);
6159
+ }
6160
+ function parseNameStatus(output) {
6161
+ if (!output) return [];
6162
+ const fields = output.endsWith("\0") ? output.slice(0, -1).split("\0") : output.split("\0");
6163
+ const result = [];
6164
+ let index = 0;
6165
+ while (index < fields.length) {
6166
+ const token = fields[index++];
6167
+ const match = token.match(/^([ACDMRTUXB])([0-9]+)?$/);
6168
+ if (!match) throw parserError("name-status", `invalid status token ${JSON.stringify(token)}`);
6169
+ const status = match[1];
6170
+ const scoreText = match[2];
6171
+ if ((status === "R" || status === "C") && !scoreText) {
6172
+ throw parserError("name-status", `missing similarity score for ${status}`);
6173
+ }
6174
+ if (scoreText && status !== "R" && status !== "C") {
6175
+ throw parserError("name-status", `score on ${status} record`);
6176
+ }
6177
+ const score = scoreText ? Number(scoreText) : void 0;
6178
+ if (score !== void 0 && (!Number.isSafeInteger(score) || score < 0 || score > 100)) {
6179
+ throw parserError("name-status", `invalid score ${scoreText}`);
6180
+ }
6181
+ if (status === "R" || status === "C") {
6182
+ 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 });
6186
+ } else {
6187
+ const path9 = fields[index++];
6188
+ if (!path9) throw parserError("name-status", "missing path");
6189
+ result.push({ status, path: path9 });
6190
+ }
6191
+ }
6192
+ return result;
6193
+ }
6194
+ function parseNumstat(output) {
6195
+ if (!output) return [];
6196
+ const fields = output.endsWith("\0") ? output.slice(0, -1).split("\0") : output.split("\0");
6197
+ const result = [];
6198
+ let index = 0;
6199
+ while (index < fields.length) {
6200
+ const record = fields[index++];
6201
+ const firstTab = record.indexOf(" ");
6202
+ const secondTab = firstTab < 0 ? -1 : record.indexOf(" ", firstTab + 1);
6203
+ if (firstTab < 0 || secondTab < 0) {
6204
+ throw parserError("numstat", `missing tab separators in ${JSON.stringify(record)}`);
6205
+ }
6206
+ const additionsText = record.slice(0, firstTab);
6207
+ const deletionsText = record.slice(firstTab + 1, secondTab);
6208
+ const path9 = record.slice(secondTab + 1);
6209
+ const binary = additionsText === "-" || deletionsText === "-";
6210
+ if (binary && (additionsText !== "-" || deletionsText !== "-")) {
6211
+ throw parserError("numstat", "only binary records may contain -");
6212
+ }
6213
+ if (!binary && (!/^\d+$/.test(additionsText) || !/^\d+$/.test(deletionsText))) {
6214
+ throw parserError("numstat", `invalid line counts in ${JSON.stringify(record)}`);
6215
+ }
6216
+ if (path9) {
6217
+ result.push({
6218
+ path: path9,
6219
+ additions: binary ? void 0 : Number(additionsText),
6220
+ deletions: binary ? void 0 : Number(deletionsText),
6221
+ binary
6222
+ });
6223
+ continue;
6224
+ }
6225
+ const oldPath = fields[index++];
6226
+ const newPath = fields[index++];
6227
+ if (!oldPath || !newPath) throw parserError("numstat", "missing rename/copy path");
6228
+ result.push({
6229
+ oldPath,
6230
+ path: newPath,
6231
+ additions: binary ? void 0 : Number(additionsText),
6232
+ deletions: binary ? void 0 : Number(deletionsText),
6233
+ binary
6234
+ });
6235
+ }
6236
+ return result;
6237
+ }
6238
+ function mergeChanges(statusOutput, numstatOutput) {
6239
+ var _a, _b;
6240
+ const statuses = parseNameStatus(statusOutput);
6241
+ const stats = parseNumstat(numstatOutput);
6242
+ const statusMap = /* @__PURE__ */ new Map();
6243
+ for (const status of statuses) {
6244
+ const key = `${(_a = status.oldPath) != null ? _a : ""}\0${status.path}`;
6245
+ if (statusMap.has(key)) throw parserError("diff", `duplicate status key ${JSON.stringify(key)}`);
6246
+ statusMap.set(key, status);
6247
+ }
6248
+ const result = [];
6249
+ const statKeys = /* @__PURE__ */ new Set();
6250
+ for (const stat of stats) {
6251
+ const key = `${(_b = stat.oldPath) != null ? _b : ""}\0${stat.path}`;
6252
+ if (statKeys.has(key)) throw parserError("diff", `duplicate numstat key ${JSON.stringify(key)}`);
6253
+ statKeys.add(key);
6254
+ const status = statusMap.get(key);
6255
+ if (!status) throw parserError("diff", `numstat without name-status for ${JSON.stringify(key)}`);
6256
+ result.push({
6257
+ status: status.status,
6258
+ score: status.score,
6259
+ path: status.path,
6260
+ oldPath: status.oldPath,
6261
+ additions: stat.additions,
6262
+ deletions: stat.deletions,
6263
+ binary: stat.binary
6264
+ });
6265
+ statusMap.delete(key);
6266
+ }
6267
+ if (statusMap.size) {
6268
+ const key = statusMap.keys().next().value;
6269
+ throw parserError("diff", `name-status without numstat for ${JSON.stringify(key)}`);
6270
+ }
6271
+ return result;
6272
+ }
6273
+ function metadataFromOutput(output, revision) {
6274
+ const fields = output.split("\0");
6275
+ if (fields.length !== 6) {
6276
+ throw parserError("commit metadata", `expected 6 fields for ${JSON.stringify(revision)}`);
6277
+ }
6278
+ const [sha, shortSha, parentText, author, authoredAt, subject] = fields;
6279
+ if (!sha || !shortSha) throw parserError("commit metadata", `missing SHA for ${JSON.stringify(revision)}`);
6280
+ return {
6281
+ sha,
6282
+ shortSha,
6283
+ parents: parentText ? parentText.split(" ") : [],
6284
+ author,
6285
+ authoredAt,
6286
+ subject
6287
+ };
6288
+ }
6289
+ async function resolveCommit(git, root, revision, token) {
6290
+ const verified = await git.exec(root, ["rev-parse", "--verify", "--end-of-options", `${revision}^{commit}`], {
6291
+ cancellationToken: token
6292
+ });
6293
+ const sha = verified.stdout.trim();
6294
+ if (!sha) throw new Error(`Invalid Git commit: ${revision}`);
6295
+ const metadata = await git.exec(root, ["show", "-s", "--no-patch", "--format=%H%x00%h%x00%P%x00%an%x00%aI%x00%s", sha], {
6296
+ cancellationToken: token
6297
+ });
6298
+ return metadataFromOutput(metadata.stdout, revision);
6299
+ }
6300
+ function comparisonArgs(commitSha, baseSha, initial, kind) {
6301
+ if (initial) {
6302
+ return ["--no-pager", "diff-tree", "--root", "--no-commit-id", "-r", "--no-ext-diff", "--no-textconv", "--no-color", "--no-relative", "--ignore-submodules=none", "--find-renames=50%", "--find-copies=50%", `--${kind}`, "-z", commitSha, "--"];
6303
+ }
6304
+ return ["--no-pager", "diff", "--no-ext-diff", "--no-textconv", "--no-color", "--no-relative", "--ignore-submodules=none", "--find-renames=50%", "--find-copies=50%", `--${kind}`, "-z", baseSha, commitSha, "--"];
6305
+ }
6306
+ async function runComparison(git, root, commit, baseSha, token) {
6307
+ const initial = !baseSha;
6308
+ const options = { cancellationToken: token };
6309
+ const [status, numstat] = await Promise.all([
6310
+ git.exec(root, comparisonArgs(commit.sha, baseSha, initial, "name-status"), options),
6311
+ git.exec(root, comparisonArgs(commit.sha, baseSha, initial, "numstat"), options)
6312
+ ]);
6313
+ return mergeChanges(status.stdout, numstat.stdout);
6314
+ }
6315
+ async function loadComparisonForCommit(git, root, commit, parentIndex = 0, token) {
6316
+ let baseSha;
6317
+ if (commit.parents.length) {
6318
+ if (!Number.isInteger(parentIndex) || parentIndex < 0 || parentIndex >= commit.parents.length) {
6319
+ throw new Error(`Invalid parent index ${parentIndex} for ${commit.shortSha}`);
6320
+ }
6321
+ baseSha = commit.parents[parentIndex];
6322
+ }
6323
+ const changes = await runComparison(git, root, commit, baseSha, token);
6324
+ return {
6325
+ commit,
6326
+ baseSha,
6327
+ parentIndex: baseSha ? parentIndex : void 0,
6328
+ changes
6329
+ };
6330
+ }
6331
+ async function assertParentAvailable(git, root, parentSha, token) {
6332
+ await git.exec(root, ["cat-file", "-e", `${parentSha}^{commit}`], { cancellationToken: token });
6333
+ }
6334
+ function patchArgs(comparison, change) {
6335
+ const paths = change.oldPath ? [change.oldPath, change.path] : [change.path];
6336
+ if (comparison.baseSha) {
6337
+ return ["--no-pager", "diff", "-p", "--no-ext-diff", "--no-textconv", "--no-color", "--no-relative", "--ignore-submodules=none", "--find-renames=50%", "--find-copies=50%", comparison.baseSha, comparison.commit.sha, "--", ...paths];
6338
+ }
6339
+ return ["--no-pager", "diff-tree", "--root", "--no-commit-id", "-r", "-p", "--no-ext-diff", "--no-textconv", "--no-color", "--no-relative", "--ignore-submodules=none", "--find-renames=50%", "--find-copies=50%", comparison.commit.sha, "--", ...paths];
6340
+ }
6341
+
6342
+ // src/model/commitDocument.ts
6343
+ var COMMIT_DOCUMENT_SCHEME = "coc-git";
6344
+ function count(value) {
6345
+ return value === void 0 ? 1 : Number(value);
6346
+ }
6347
+ function contentLineCount(content) {
6348
+ return content ? content.split("\n").length : 1;
6349
+ }
6350
+ function parseCommitDocumentPatch(output) {
6351
+ const hunks = [];
6352
+ let current;
6353
+ for (const line of output.split(/\r?\n/)) {
6354
+ const match = line.match(/^@@ -(\d+)(?:,(\d+))? \+(\d+)(?:,(\d+))? @@/);
6355
+ if (match) {
6356
+ const addedStart = Number(match[3]);
6357
+ const addedCount = count(match[4]);
6358
+ const start = Math.max(1, addedStart);
6359
+ current = {
6360
+ start,
6361
+ end: addedCount > 0 ? addedStart + addedCount - 1 : start,
6362
+ addedStart,
6363
+ addedCount,
6364
+ deleted: [],
6365
+ deletedLine: addedCount > 0 || addedStart === 0 ? Math.max(0, addedStart - 1) : addedStart - 1,
6366
+ deletedAlign: addedCount > 0 || addedStart === 0 ? "above" : "below"
6367
+ };
6368
+ hunks.push(current);
6369
+ continue;
6370
+ }
6371
+ if (!current || line.startsWith("\")) continue;
6372
+ if (line.startsWith("-")) current.deleted.push(line.slice(1));
6373
+ }
6374
+ return hunks;
6375
+ }
6376
+ function patchArguments(comparison, change) {
6377
+ const args = patchArgs(comparison, change);
6378
+ const separator = args.indexOf("--");
6379
+ args.splice(separator, 0, "--unified=0");
6380
+ return args;
6381
+ }
6382
+ function commitUri(comparison, relativePath) {
6383
+ return import_coc11.Uri.from({
6384
+ scheme: COMMIT_DOCUMENT_SCHEME,
6385
+ authority: comparison.commit.sha,
6386
+ path: `/${relativePath}`
6387
+ });
6388
+ }
6389
+ var CommitDocumentProvider = class {
6390
+ constructor(git, virtualTextSrcId) {
6391
+ this.git = git;
6392
+ this.virtualTextSrcId = virtualTextSrcId;
6393
+ this.resources = /* @__PURE__ */ new Map();
6394
+ this.disposables = [];
6395
+ import_coc11.workspace.onDidCloseTextDocument((document) => {
6396
+ if (import_coc11.Uri.parse(document.uri).scheme === COMMIT_DOCUMENT_SCHEME) this.resources.delete(document.uri);
6397
+ }, null, this.disposables);
6398
+ }
6399
+ async provideTextDocumentContent(uri, token) {
6400
+ var _a;
6401
+ const resource = this.resources.get(uri.toString());
6402
+ if (!resource) throw new Error(`Unknown coc-git commit document: ${uri.toString()}`);
6403
+ await this.load(resource, token);
6404
+ import_coc11.workspace.nvim.pauseNotification();
6405
+ import_coc11.workspace.nvim.command("setlocal buftype=nofile bufhidden=wipe noswapfile readonly", true);
6406
+ import_coc11.workspace.nvim.command("filetype detect", true);
6407
+ import_coc11.workspace.nvim.resumeNotification(true);
6408
+ return (_a = resource.content) != null ? _a : "";
6409
+ }
6410
+ async open(root, comparison, change, targetWinId, line) {
6411
+ const uri = commitUri(comparison, change.path);
6412
+ const resource = { uri, root, comparison, change };
6413
+ this.resources.set(uri.toString(), resource);
6414
+ const moved = await import_coc11.workspace.nvim.call("win_gotoid", [targetWinId]);
6415
+ if (!moved) await import_coc11.workspace.nvim.command("new");
6416
+ await import_coc11.workspace.openResource(uri.toString());
6417
+ const document = import_coc11.workspace.getDocument(uri.toString());
6418
+ if (document) {
6419
+ await this.load(resource);
6420
+ await this.finalizeDocument(document, resource);
6421
+ if (line != null) await import_coc11.workspace.nvim.call("cursor", [Math.max(1, Math.min(line, contentLineCount(resource.content))), 1]);
6422
+ }
6423
+ }
6424
+ async nextChunk() {
6425
+ return await this.navigate(true);
6426
+ }
6427
+ async prevChunk() {
6428
+ return await this.navigate(false);
6429
+ }
6430
+ async load(resource, token) {
6431
+ if (resource.content !== void 0 && resource.hunks) return;
6432
+ const options = token ? { cancellationToken: token } : void 0;
6433
+ const object = `${resource.comparison.commit.sha}:${resource.change.path}`;
6434
+ const [content, patch] = await Promise.all([
6435
+ this.git.exec(resource.root, ["cat-file", "-p", object], options),
6436
+ this.git.exec(resource.root, patchArguments(resource.comparison, resource.change), options)
6437
+ ]);
6438
+ if (token == null ? void 0 : token.isCancellationRequested) return;
6439
+ resource.content = content.stdout.replace(/\r?\n$/, "");
6440
+ resource.hunks = parseCommitDocumentPatch(patch.stdout);
6441
+ }
6442
+ async finalizeDocument(document, resource) {
6443
+ var _a;
6444
+ await this.load(resource);
6445
+ const buffer = document.buffer;
6446
+ await buffer.setOption("modifiable", false);
6447
+ this.decorate(buffer, (_a = resource.hunks) != null ? _a : []);
6448
+ }
6449
+ decorate(buffer, hunks) {
6450
+ buffer.clearNamespace(this.virtualTextSrcId);
6451
+ const highlights = [];
6452
+ for (const hunk of hunks) {
6453
+ for (let line = hunk.addedStart; line < hunk.addedStart + hunk.addedCount; line++) {
6454
+ highlights.push({ hlGroup: "CocGitCommitAdd", lnum: line - 1, colStart: 0, colEnd: -1 });
6455
+ }
6456
+ for (const deleted of hunk.deleted) {
6457
+ buffer.setVirtualText(this.virtualTextSrcId, hunk.deletedLine, [[deleted || " ", "CocGitCommitDelete"]], {
6458
+ text_align: hunk.deletedAlign,
6459
+ hl_mode: "replace"
6460
+ });
6461
+ }
6462
+ }
6463
+ buffer.updateHighlights("coc-git-commit-add", highlights, { priority: 4096 });
6464
+ }
6465
+ async navigate(forward) {
6466
+ var _a;
6467
+ const bufnr = await import_coc11.workspace.nvim.call("bufnr", ["%"]);
6468
+ const document = import_coc11.workspace.getDocument(bufnr);
6469
+ if (!document || import_coc11.Uri.parse(document.uri).scheme !== COMMIT_DOCUMENT_SCHEME) return false;
6470
+ const resource = this.resources.get(document.uri);
6471
+ if (!resource) return true;
6472
+ await this.load(resource);
6473
+ const hunks = (_a = resource.hunks) != null ? _a : [];
6474
+ if (!hunks.length) return true;
6475
+ const line = await import_coc11.workspace.nvim.call("line", ["."]);
6476
+ const ordered = forward ? hunks : hunks.slice().reverse();
6477
+ const target = ordered.find((hunk) => forward ? hunk.start > line : hunk.end < line);
6478
+ if (target) {
6479
+ await import_coc11.window.moveTo({ line: target.start - 1, character: 0 });
6480
+ } else if (await import_coc11.workspace.nvim.getOption("wrapscan")) {
6481
+ const wrapped = forward ? hunks[0] : hunks[hunks.length - 1];
6482
+ await import_coc11.window.moveTo({ line: wrapped.start - 1, character: 0 });
6483
+ }
6484
+ return true;
6485
+ }
6486
+ dispose() {
6487
+ (0, import_coc11.disposeAll)(this.disposables);
6488
+ this.resources.clear();
6489
+ }
6490
+ };
6491
+
6136
6492
  // src/model/service.ts
6137
- var import_coc14 = require("coc.nvim");
6493
+ var import_coc15 = require("coc.nvim");
6138
6494
 
6139
6495
  // src/model/buffer.ts
6140
- var import_coc11 = require("coc.nvim");
6496
+ var import_coc12 = require("coc.nvim");
6141
6497
  var import_debounce2 = __toESM(require_debounce());
6142
6498
 
6143
6499
  // node_modules/timeago.js/esm/lang/en_US.js
@@ -6875,7 +7231,7 @@ var GitBuffer = class {
6875
7231
  this.gitStatus = "";
6876
7232
  this.foldEnabled = false;
6877
7233
  this._disposed = false;
6878
- this.mutex = new import_coc11.Mutex();
7234
+ this.mutex = new import_coc12.Mutex();
6879
7235
  this.conflictCheckNeeded = hasConflicts;
6880
7236
  this.refresh = (0, import_debounce2.default)(() => {
6881
7237
  this._refresh().catch((e) => {
@@ -6926,7 +7282,7 @@ var GitBuffer = class {
6926
7282
  });
6927
7283
  }
6928
7284
  async chunkUndo() {
6929
- let line = await import_coc11.workspace.nvim.call("line", ".");
7285
+ let line = await import_coc12.workspace.nvim.call("line", ".");
6930
7286
  let diff = this.getChunk(line);
6931
7287
  if (!diff) return;
6932
7288
  let { start, lines, changeType } = diff;
@@ -6945,10 +7301,10 @@ var GitBuffer = class {
6945
7301
  }
6946
7302
  async chunkStage() {
6947
7303
  let relpath = toUnixSlash(this.relpath);
6948
- let line = await import_coc11.workspace.nvim.call("line", ".");
7304
+ let line = await import_coc12.workspace.nvim.call("line", ".");
6949
7305
  let diff = this.getChunk(line);
6950
7306
  if (!diff) {
6951
- import_coc11.window.showErrorMessage("Not positioned in git chunk");
7307
+ import_coc12.window.showErrorMessage("Not positioned in git chunk");
6952
7308
  return;
6953
7309
  }
6954
7310
  let head;
@@ -6980,7 +7336,7 @@ var GitBuffer = class {
6980
7336
  }
6981
7337
  async chunkUnstage() {
6982
7338
  var _a;
6983
- let { nvim } = import_coc11.workspace;
7339
+ let { nvim } = import_coc12.workspace;
6984
7340
  const { diffs } = this;
6985
7341
  let line = await nvim.call("line", ".");
6986
7342
  let adjust = 0;
@@ -6988,7 +7344,7 @@ var GitBuffer = class {
6988
7344
  for (let diff of diffs) {
6989
7345
  if (diff.end >= line) {
6990
7346
  if (diff.start <= line && diff.changeType != "delete" /* Delete */) {
6991
- import_coc11.window.showErrorMessage(`Current line contains unstaged change.`);
7347
+ import_coc12.window.showErrorMessage(`Current line contains unstaged change.`);
6992
7348
  invalid = true;
6993
7349
  }
6994
7350
  break;
@@ -7001,12 +7357,12 @@ var GitBuffer = class {
7001
7357
  let stagedDiff = await this.repo.getStagedChunks(this.relpath);
7002
7358
  let chunks = (_a = Object.values(stagedDiff)[0]) != null ? _a : [];
7003
7359
  if (!chunks.length) {
7004
- import_coc11.window.showErrorMessage(`Staged chunk not found`);
7360
+ import_coc12.window.showErrorMessage(`Staged chunk not found`);
7005
7361
  return;
7006
7362
  }
7007
7363
  let chunk = chunks.find((o) => chunkContainsLine(o, line));
7008
7364
  if (!chunk) {
7009
- import_coc11.window.showErrorMessage(`Unable to find staged chunk on current line`);
7365
+ import_coc12.window.showErrorMessage(`Unable to find staged chunk on current line`);
7010
7366
  return;
7011
7367
  }
7012
7368
  this.channel.appendLine(`[Info] resolved chunk ${JSON.stringify(chunk, null, 2)}`);
@@ -7017,7 +7373,7 @@ var GitBuffer = class {
7017
7373
  this.invalidateStagedCache();
7018
7374
  this.refresh();
7019
7375
  } catch (e) {
7020
- import_coc11.window.showErrorMessage(`Unable to apply patch: ${e.message}`);
7376
+ import_coc12.window.showErrorMessage(`Unable to apply patch: ${e.message}`);
7021
7377
  this.channel.appendLine(`[Error] ${e.message}`);
7022
7378
  }
7023
7379
  }
@@ -7027,17 +7383,17 @@ var GitBuffer = class {
7027
7383
  return;
7028
7384
  }
7029
7385
  const { diffs } = this;
7030
- let { nvim } = import_coc11.workspace;
7386
+ let { nvim } = import_coc12.workspace;
7031
7387
  if (!diffs || diffs.length == 0) return;
7032
7388
  let line = await nvim.call("line", ".");
7033
7389
  for (let diff of diffs) {
7034
7390
  if (diff.start > line) {
7035
- await import_coc11.window.moveTo({ line: Math.max(diff.start - 1, 0), character: 0 });
7391
+ await import_coc12.window.moveTo({ line: Math.max(diff.start - 1, 0), character: 0 });
7036
7392
  return;
7037
7393
  }
7038
7394
  }
7039
7395
  if (await nvim.getOption("wrapscan")) {
7040
- await import_coc11.window.moveTo({ line: Math.max(diffs[0].start - 1, 0), character: 0 });
7396
+ await import_coc12.window.moveTo({ line: Math.max(diffs[0].start - 1, 0), character: 0 });
7041
7397
  }
7042
7398
  }
7043
7399
  async prevChunk() {
@@ -7045,18 +7401,18 @@ var GitBuffer = class {
7045
7401
  await this.moveToPreviousChunk();
7046
7402
  return;
7047
7403
  }
7048
- const { nvim } = import_coc11.workspace;
7404
+ const { nvim } = import_coc12.workspace;
7049
7405
  let { diffs } = this;
7050
7406
  let line = await nvim.call("line", ".");
7051
7407
  if (!diffs || diffs.length == 0) return;
7052
7408
  for (let diff of diffs.slice().reverse()) {
7053
7409
  if (diff.end < line) {
7054
- await import_coc11.window.moveTo({ line: Math.max(diff.start - 1, 0), character: 0 });
7410
+ await import_coc12.window.moveTo({ line: Math.max(diff.start - 1, 0), character: 0 });
7055
7411
  return;
7056
7412
  }
7057
7413
  }
7058
7414
  if (await nvim.getOption("wrapscan")) {
7059
- await import_coc11.window.moveTo({ line: Math.max(diffs[diffs.length - 1].start - 1, 0), character: 0 });
7415
+ await import_coc12.window.moveTo({ line: Math.max(diffs[diffs.length - 1].start - 1, 0), character: 0 });
7060
7416
  }
7061
7417
  }
7062
7418
  getNavigationChunks() {
@@ -7086,36 +7442,36 @@ var GitBuffer = class {
7086
7442
  }
7087
7443
  async moveToNextChunk() {
7088
7444
  const chunks = this.getNavigationChunks();
7089
- const { nvim } = import_coc11.workspace;
7445
+ const { nvim } = import_coc12.workspace;
7090
7446
  if (chunks.length === 0) return;
7091
7447
  const line = await nvim.call("line", ".");
7092
7448
  for (const chunk of chunks) {
7093
7449
  if (chunk.start > line) {
7094
- await import_coc11.window.moveTo({ line: Math.max(chunk.start - 1, 0), character: 0 });
7450
+ await import_coc12.window.moveTo({ line: Math.max(chunk.start - 1, 0), character: 0 });
7095
7451
  return;
7096
7452
  }
7097
7453
  }
7098
7454
  if (await nvim.getOption("wrapscan")) {
7099
- await import_coc11.window.moveTo({ line: Math.max(chunks[0].start - 1, 0), character: 0 });
7455
+ await import_coc12.window.moveTo({ line: Math.max(chunks[0].start - 1, 0), character: 0 });
7100
7456
  }
7101
7457
  }
7102
7458
  async moveToPreviousChunk() {
7103
7459
  const chunks = this.getNavigationChunks();
7104
- const { nvim } = import_coc11.workspace;
7460
+ const { nvim } = import_coc12.workspace;
7105
7461
  if (chunks.length === 0) return;
7106
7462
  const line = await nvim.call("line", ".");
7107
7463
  for (const chunk of chunks.slice().reverse()) {
7108
7464
  if (chunk.end < line) {
7109
- await import_coc11.window.moveTo({ line: Math.max(chunk.start - 1, 0), character: 0 });
7465
+ await import_coc12.window.moveTo({ line: Math.max(chunk.start - 1, 0), character: 0 });
7110
7466
  return;
7111
7467
  }
7112
7468
  }
7113
7469
  if (await nvim.getOption("wrapscan")) {
7114
- await import_coc11.window.moveTo({ line: Math.max(chunks[chunks.length - 1].start - 1, 0), character: 0 });
7470
+ await import_coc12.window.moveTo({ line: Math.max(chunks[chunks.length - 1].start - 1, 0), character: 0 });
7115
7471
  }
7116
7472
  }
7117
7473
  async chunkInfo() {
7118
- let line = await import_coc11.workspace.nvim.call("line", ".");
7474
+ let line = await import_coc12.workspace.nvim.call("line", ".");
7119
7475
  let diff = this.getChunk(line);
7120
7476
  if (diff) {
7121
7477
  let content = diff.head + "\n" + diff.lines.join("\n");
@@ -7150,7 +7506,7 @@ var GitBuffer = class {
7150
7506
  }
7151
7507
  async showBlameInfo(lnum) {
7152
7508
  if (this._disposed) return;
7153
- let { nvim } = import_coc11.workspace;
7509
+ let { nvim } = import_coc12.workspace;
7154
7510
  let { virtualTextSrcId, addGBlameToBufferVar, addGBlameToVirtualText } = this.config;
7155
7511
  if (!this.showBlame) return;
7156
7512
  let infos = this.blameInfo;
@@ -7189,9 +7545,9 @@ var GitBuffer = class {
7189
7545
  async showBlameDoc(lnum) {
7190
7546
  let indexed = await this.repo.isIndexed(this.relpath);
7191
7547
  if (!indexed) {
7192
- import_coc11.window.showWarningMessage("File not indexed");
7548
+ import_coc12.window.showWarningMessage("File not indexed");
7193
7549
  } else if (await this.repo.isShallow()) {
7194
- import_coc11.window.showWarningMessage("Shallow repository, blame not available");
7550
+ import_coc12.window.showWarningMessage("Shallow repository, blame not available");
7195
7551
  } else {
7196
7552
  let infos = await this.getBlameInfo([lnum, lnum]);
7197
7553
  let info = infos.find((o) => lnum >= o.startLnum && lnum <= o.endLnum);
@@ -7202,12 +7558,12 @@ var GitBuffer = class {
7202
7558
  blameText.push(`${info.sha.substring(0, 7)}`);
7203
7559
  await this.showDoc(blameText.join("\n\n"), "text");
7204
7560
  } else {
7205
- import_coc11.window.showWarningMessage("Not committed yet");
7561
+ import_coc12.window.showWarningMessage("Not committed yet");
7206
7562
  }
7207
7563
  }
7208
7564
  }
7209
7565
  async diffDocument(force = false) {
7210
- let { nvim } = import_coc11.workspace;
7566
+ let { nvim } = import_coc12.workspace;
7211
7567
  let revision = this.config.diffRevision;
7212
7568
  const { bufnr } = this.doc;
7213
7569
  let content = this.doc.content;
@@ -7290,7 +7646,7 @@ var GitBuffer = class {
7290
7646
  updateGutters() {
7291
7647
  if (this._disposed) return;
7292
7648
  if (!this.config.enableGutters) return;
7293
- let { nvim } = import_coc11.workspace;
7649
+ let { nvim } = import_coc12.workspace;
7294
7650
  let { bufnr } = this.doc;
7295
7651
  let { signPriority, stagedSignPriority } = this.config;
7296
7652
  let signs = this.currentSigns;
@@ -7371,10 +7727,10 @@ var GitBuffer = class {
7371
7727
  async diffCached() {
7372
7728
  let res = await this.repo.safeRun(["diff", "--cached"]);
7373
7729
  if (!res.trim()) {
7374
- import_coc11.window.showWarningMessage("Empty diff");
7730
+ import_coc12.window.showWarningMessage("Empty diff");
7375
7731
  return;
7376
7732
  }
7377
- let { nvim } = import_coc11.workspace;
7733
+ let { nvim } = import_coc12.workspace;
7378
7734
  nvim.pauseNotification();
7379
7735
  nvim.command(`keepalt above new +setl\\ previewwindow`, true);
7380
7736
  nvim.call("append", [0, res.split(/\r?\n/)], true);
@@ -7385,44 +7741,44 @@ var GitBuffer = class {
7385
7741
  await nvim.resumeNotification();
7386
7742
  }
7387
7743
  async nextConflict() {
7388
- let { nvim } = import_coc11.workspace;
7744
+ let { nvim } = import_coc12.workspace;
7389
7745
  if (!this.conflicts.length) {
7390
- import_coc11.window.showWarningMessage("No conflicts detected");
7746
+ import_coc12.window.showWarningMessage("No conflicts detected");
7391
7747
  return;
7392
7748
  }
7393
7749
  let line = await nvim.call("line", ".");
7394
7750
  for (let conflict of this.conflicts) {
7395
7751
  if (conflict.start > line) {
7396
- await import_coc11.window.moveTo({ line: Math.max(conflict.start - 1, 0), character: 0 });
7752
+ await import_coc12.window.moveTo({ line: Math.max(conflict.start - 1, 0), character: 0 });
7397
7753
  return;
7398
7754
  }
7399
7755
  }
7400
7756
  if (await nvim.getOption("wrapscan")) {
7401
- await import_coc11.window.moveTo({ line: Math.max(this.conflicts[0].start - 1, 0), character: 0 });
7757
+ await import_coc12.window.moveTo({ line: Math.max(this.conflicts[0].start - 1, 0), character: 0 });
7402
7758
  }
7403
7759
  }
7404
7760
  async prevConflict() {
7405
- let { nvim } = import_coc11.workspace;
7761
+ let { nvim } = import_coc12.workspace;
7406
7762
  if (!this.conflicts.length) {
7407
- import_coc11.window.showWarningMessage("No conflicts detected", "warning");
7763
+ import_coc12.window.showWarningMessage("No conflicts detected", "warning");
7408
7764
  return;
7409
7765
  }
7410
7766
  let line = await nvim.call("line", ".");
7411
7767
  let conflict = getPreviousConflict(this.conflicts, line);
7412
7768
  if (conflict) {
7413
- await import_coc11.window.moveTo({ line: Math.max(conflict.start - 1, 0), character: 0 });
7769
+ await import_coc12.window.moveTo({ line: Math.max(conflict.start - 1, 0), character: 0 });
7414
7770
  return;
7415
7771
  }
7416
7772
  if (await nvim.getOption("wrapscan")) {
7417
7773
  conflict = this.conflicts[this.conflicts.length - 1];
7418
- await import_coc11.window.moveTo({ line: Math.max(conflict.start - 1, 0), character: 0 });
7774
+ await import_coc12.window.moveTo({ line: Math.max(conflict.start - 1, 0), character: 0 });
7419
7775
  }
7420
7776
  }
7421
7777
  async conflictKeepPart(part) {
7422
- const { nvim } = import_coc11.workspace;
7778
+ const { nvim } = import_coc12.workspace;
7423
7779
  let conflicts = this.conflicts;
7424
7780
  if (!conflicts || conflicts.length == 0) {
7425
- import_coc11.window.showWarningMessage("No conflicts detected");
7781
+ import_coc12.window.showWarningMessage("No conflicts detected");
7426
7782
  return;
7427
7783
  }
7428
7784
  let line = await nvim.call("line", ".");
@@ -7446,11 +7802,11 @@ var GitBuffer = class {
7446
7802
  }
7447
7803
  }
7448
7804
  }
7449
- import_coc11.window.showWarningMessage("Not positioned on a conflict");
7805
+ import_coc12.window.showWarningMessage("Not positioned on a conflict");
7450
7806
  }
7451
7807
  async browser(action = "open", range, permalink = false) {
7452
- let { nvim } = import_coc11.workspace;
7453
- let config = import_coc11.workspace.getConfiguration("git");
7808
+ let { nvim } = import_coc12.workspace;
7809
+ let config = import_coc12.workspace.getConfiguration("git");
7454
7810
  let head = (await this.repo.safeRun(["rev-parse", "HEAD"])).trim();
7455
7811
  let branch = config.get("browserBranchName", "").trim();
7456
7812
  if (!branch.length) {
@@ -7469,7 +7825,7 @@ var GitBuffer = class {
7469
7825
  }
7470
7826
  let output = await this.repo.safeRun(["remote"]);
7471
7827
  if (!output.trim()) {
7472
- import_coc11.window.showWarningMessage(`No remote found`);
7828
+ import_coc12.window.showWarningMessage(`No remote found`);
7473
7829
  return;
7474
7830
  }
7475
7831
  let names = output.trim().split(/\r?\n/);
@@ -7478,7 +7834,7 @@ var GitBuffer = class {
7478
7834
  if (names.includes(browserRemoteName)) {
7479
7835
  names = [browserRemoteName];
7480
7836
  } else {
7481
- import_coc11.window.showWarningMessage("Configured git.browserRemoteName missing from remote list");
7837
+ import_coc12.window.showWarningMessage("Configured git.browserRemoteName missing from remote list");
7482
7838
  return;
7483
7839
  }
7484
7840
  }
@@ -7505,46 +7861,52 @@ var GitBuffer = class {
7505
7861
  }
7506
7862
  if (urls.length == 1) {
7507
7863
  if (action == "open") {
7508
- await import_coc11.workspace.openResource(urls[0]);
7864
+ await import_coc12.workspace.openResource(urls[0]);
7509
7865
  } else {
7510
7866
  nvim.call("setreg", ["+", urls[0]], true);
7511
- import_coc11.window.showInformationMessage("Copied url to clipboard");
7867
+ import_coc12.window.showInformationMessage("Copied url to clipboard");
7512
7868
  }
7513
7869
  } else if (urls.length > 1) {
7514
- let url = await import_coc11.window.showQuickPick(urls, { canPickMany: false, title: "Pick remote url" });
7870
+ let url = await import_coc12.window.showQuickPick(urls, { canPickMany: false, title: "Pick remote url" });
7515
7871
  if (url) {
7516
7872
  if (action == "open") {
7517
- await import_coc11.workspace.openResource(url);
7873
+ await import_coc12.workspace.openResource(url);
7518
7874
  } else {
7519
7875
  nvim.call("setreg", ["+", url], true);
7520
7876
  nvim.call("setreg", ["*", url], true);
7521
- import_coc11.window.showInformationMessage("Copied url to clipboard");
7877
+ import_coc12.window.showInformationMessage("Copied url to clipboard");
7522
7878
  }
7523
7879
  }
7524
7880
  }
7525
7881
  }
7526
- // show commit of current line in split window
7527
- async showCommit(useFloating = false) {
7528
- var _a;
7882
+ async getCurrentCommit() {
7529
7883
  let indexed = await this.repo.isIndexed(this.relpath);
7530
7884
  if (!indexed) {
7531
- import_coc11.window.showWarningMessage(`"${this.relpath}" not indexed.`);
7532
- return;
7885
+ import_coc12.window.showWarningMessage(`"${this.relpath}" not indexed.`);
7886
+ return void 0;
7533
7887
  }
7534
- let nvim = import_coc11.workspace.nvim;
7888
+ let nvim = import_coc12.workspace.nvim;
7535
7889
  let line = await nvim.eval('line(".")');
7536
7890
  let args = ["--no-pager", "blame", "-w", "--porcelain", "--root", `-L${line},${line}`, "--", this.relpath];
7537
7891
  let res = await this.repo.exec(args);
7538
7892
  let output = res.stdout.trim();
7539
- if (!output.length) return;
7893
+ if (!output.length) return void 0;
7540
7894
  let match = output.match(/^(\S+)\s+(\d+)/);
7541
- if (!match) return;
7895
+ if (!match) return void 0;
7542
7896
  let commit = match[1];
7543
- let commitLine = Number(match[2]);
7544
7897
  if (/^0+$/.test(commit)) {
7545
- import_coc11.window.showWarningMessage("not committed yet!");
7546
- return;
7898
+ import_coc12.window.showWarningMessage("not committed yet!");
7899
+ return void 0;
7547
7900
  }
7901
+ return { sha: commit, line: Number(match[2]) };
7902
+ }
7903
+ // show commit of current line in split window
7904
+ async showCommit(useFloating = false) {
7905
+ var _a;
7906
+ let current = await this.getCurrentCommit();
7907
+ if (!current) return;
7908
+ let { sha: commit, line: commitLine } = current;
7909
+ let nvim = import_coc12.workspace.nvim;
7548
7910
  if (!useFloating) useFloating = this.config.showCommitInFloating;
7549
7911
  if (useFloating) {
7550
7912
  let content = await this.repo.safeRun(["--no-pager", "show", commit]);
@@ -7575,15 +7937,15 @@ var GitBuffer = class {
7575
7937
  }
7576
7938
  }
7577
7939
  async toggleFold() {
7578
- let { nvim } = import_coc11.workspace;
7940
+ let { nvim } = import_coc12.workspace;
7579
7941
  let buf = this.doc.buffer;
7580
7942
  let win = await nvim.window;
7581
7943
  let bufnr = buf.id;
7582
- let doc = import_coc11.workspace.getDocument(bufnr);
7944
+ let doc = import_coc12.workspace.getDocument(bufnr);
7583
7945
  if (!doc) return;
7584
7946
  let infos = this.currentSigns;
7585
7947
  if (!infos || infos.length == 0) {
7586
- import_coc11.window.showWarningMessage("No changes");
7948
+ import_coc12.window.showWarningMessage("No changes");
7587
7949
  return;
7588
7950
  }
7589
7951
  let changedLines = new Set(infos.map((o) => o.line));
@@ -7649,7 +8011,7 @@ var GitBuffer = class {
7649
8011
  }
7650
8012
  async toggleGutters(enabled) {
7651
8013
  this.config.enableGutters = enabled;
7652
- let { nvim } = import_coc11.workspace;
8014
+ let { nvim } = import_coc12.workspace;
7653
8015
  if (!enabled) {
7654
8016
  nvim.call("sign_unplace", [signGroup, { buffer: this.doc.bufnr }], true);
7655
8017
  nvim.redrawVim();
@@ -7751,18 +8113,18 @@ var GitBuffer = class {
7751
8113
  let currentHlGroup = this.config.conflict.currentHlGroup;
7752
8114
  let incomingHlGroup = this.config.conflict.incomingHlGroup;
7753
8115
  let commonHlGroup = this.config.conflict.commonHlGroup;
7754
- let { nvim } = import_coc11.workspace;
8116
+ let { nvim } = import_coc12.workspace;
7755
8117
  nvim.pauseNotification();
7756
8118
  buffer.clearNamespace(this.config.conflictSrcId, 0, -1);
7757
8119
  const srcId = this.config.conflictSrcId;
7758
8120
  conflicts.map((conflict) => {
7759
8121
  let currEnd = conflict.common ? conflict.common - 1 : conflict.sep - 1;
7760
- let currRange = import_coc11.Range.create(import_coc11.Position.create(conflict.start - 1, 0), import_coc11.Position.create(currEnd, 0));
7761
- let incomingRange = import_coc11.Range.create(import_coc11.Position.create(conflict.sep, 0), import_coc11.Position.create(conflict.end, 0));
8122
+ let currRange = import_coc12.Range.create(import_coc12.Position.create(conflict.start - 1, 0), import_coc12.Position.create(currEnd, 0));
8123
+ let incomingRange = import_coc12.Range.create(import_coc12.Position.create(conflict.sep, 0), import_coc12.Position.create(conflict.end, 0));
7762
8124
  buffer.highlightRanges(srcId, currentHlGroup, [currRange]);
7763
8125
  buffer.highlightRanges(srcId, incomingHlGroup, [incomingRange]);
7764
8126
  if (conflict.common) {
7765
- let range = import_coc11.Range.create(import_coc11.Position.create(conflict.common - 1, 0), import_coc11.Position.create(conflict.sep - 1, 0));
8127
+ let range = import_coc12.Range.create(import_coc12.Position.create(conflict.common - 1, 0), import_coc12.Position.create(conflict.sep - 1, 0));
7766
8128
  buffer.highlightRanges(srcId, commonHlGroup, [range]);
7767
8129
  }
7768
8130
  });
@@ -7774,14 +8136,14 @@ var GitBuffer = class {
7774
8136
  await this.floatFactory.show(docs, this.config.floatConfig);
7775
8137
  } else {
7776
8138
  const lines = content.split("\n");
7777
- import_coc11.workspace.nvim.call("coc#ui#preview_info", [lines, filetype], true);
8139
+ import_coc12.workspace.nvim.call("coc#ui#preview_info", [lines, filetype], true);
7778
8140
  }
7779
8141
  }
7780
8142
  setBufferStatus(status) {
7781
8143
  let exists = this.gitStatus;
7782
8144
  if (exists == status) return;
7783
8145
  this.gitStatus = status;
7784
- let { nvim } = import_coc11.workspace;
8146
+ let { nvim } = import_coc12.workspace;
7785
8147
  let buffer = nvim.createBuffer(this.doc.bufnr);
7786
8148
  nvim.pauseNotification();
7787
8149
  buffer.setVar("coc_git_status", status, true);
@@ -7822,7 +8184,7 @@ var GitBuffer = class {
7822
8184
  dispose() {
7823
8185
  if (this._disposed) return;
7824
8186
  this._disposed = true;
7825
- let { nvim } = import_coc11.workspace;
8187
+ let { nvim } = import_coc12.workspace;
7826
8188
  let { bufnr } = this.doc;
7827
8189
  let buffer = nvim.createBuffer(bufnr);
7828
8190
  nvim.pauseNotification();
@@ -7841,20 +8203,20 @@ var GitBuffer = class {
7841
8203
  this.foldEnabled = false;
7842
8204
  }
7843
8205
  };
7844
- function plus(val, count, max) {
7845
- if (!count) return val;
7846
- val = val + count;
8206
+ function plus(val, count2, max) {
8207
+ if (!count2) return val;
8208
+ val = val + count2;
7847
8209
  return Math.min(max, val);
7848
8210
  }
7849
- function minus(val, count, min) {
7850
- if (!count) return val;
7851
- val = val - count;
8211
+ function minus(val, count2, min) {
8212
+ if (!count2) return val;
8213
+ val = val - count2;
7852
8214
  return Math.max(min, val);
7853
8215
  }
7854
8216
 
7855
8217
  // src/model/git.ts
7856
8218
  var cp = __toESM(require("child_process"));
7857
- var import_coc12 = require("coc.nvim");
8219
+ var import_coc13 = require("coc.nvim");
7858
8220
  var import_iconv_lite = __toESM(require_lib());
7859
8221
  var import_path6 = __toESM(require("path"));
7860
8222
  var Git = class {
@@ -7942,11 +8304,11 @@ async function exec2(child, cancellationToken) {
7942
8304
  const disposables = [];
7943
8305
  const once = (ee, name, fn) => {
7944
8306
  ee.once(name, fn);
7945
- disposables.push(import_coc12.Disposable.create(() => ee.removeListener(name, fn)));
8307
+ disposables.push(import_coc13.Disposable.create(() => ee.removeListener(name, fn)));
7946
8308
  };
7947
8309
  const on = (ee, name, fn) => {
7948
8310
  ee.on(name, fn);
7949
- disposables.push(import_coc12.Disposable.create(() => ee.removeListener(name, fn)));
8311
+ disposables.push(import_coc13.Disposable.create(() => ee.removeListener(name, fn)));
7950
8312
  };
7951
8313
  let result = Promise.all([
7952
8314
  new Promise((c, e) => {
@@ -7981,12 +8343,12 @@ async function exec2(child, cancellationToken) {
7981
8343
  const [exitCode, stdout, stderr] = await result;
7982
8344
  return { exitCode, stdout, stderr };
7983
8345
  } finally {
7984
- (0, import_coc12.disposeAll)(disposables);
8346
+ (0, import_coc13.disposeAll)(disposables);
7985
8347
  }
7986
8348
  }
7987
8349
 
7988
8350
  // src/model/resolver.ts
7989
- var import_coc13 = require("coc.nvim");
8351
+ var import_coc14 = require("coc.nvim");
7990
8352
  var import_fs3 = __toESM(require("fs"));
7991
8353
  var import_path7 = __toESM(require("path"));
7992
8354
  var import_util7 = require("util");
@@ -7997,7 +8359,7 @@ async function getRealPath(fullpath) {
7997
8359
  } catch (e) {
7998
8360
  if (e.message.includes("ENOENT")) {
7999
8361
  try {
8000
- resolved = await import_coc13.workspace.nvim.call("expand", [fullpath]);
8362
+ resolved = await import_coc14.workspace.nvim.call("expand", [fullpath]);
8001
8363
  } catch (e2) {
8002
8364
  }
8003
8365
  }
@@ -8036,7 +8398,7 @@ var Resolver = class {
8036
8398
  if (doc.buftype != "" || doc.schema != "file") {
8037
8399
  return null;
8038
8400
  }
8039
- let fullpath = await getRealPath(import_coc13.Uri.parse(uri).fsPath);
8401
+ let fullpath = await getRealPath(import_coc14.Uri.parse(uri).fsPath);
8040
8402
  if (process.platform == "win32") {
8041
8403
  fullpath = import_path7.default.win32.normalize(fullpath);
8042
8404
  }
@@ -8067,11 +8429,11 @@ var Resolver = class {
8067
8429
  return root;
8068
8430
  }
8069
8431
  async resolveRootFromCwd() {
8070
- let parts = import_coc13.workspace.cwd.split(import_path7.default.sep);
8432
+ let parts = import_coc14.workspace.cwd.split(import_path7.default.sep);
8071
8433
  let idx = parts.indexOf(".git");
8072
8434
  if (idx !== -1) return parts.slice(0, idx).join(import_path7.default.sep);
8073
8435
  try {
8074
- return await this.git.getRepositoryRoot(import_coc13.workspace.cwd);
8436
+ return await this.git.getRepositoryRoot(import_coc14.workspace.cwd);
8075
8437
  } catch (e) {
8076
8438
  }
8077
8439
  return null;
@@ -8086,11 +8448,11 @@ var Resolver = class {
8086
8448
  var GitService = class {
8087
8449
  constructor(gitInfo) {
8088
8450
  this.repos = /* @__PURE__ */ new Map();
8089
- const outputChannel = this.outputChannel = import_coc14.window.createOutputChannel("git");
8451
+ const outputChannel = this.outputChannel = import_coc15.window.createOutputChannel("git");
8090
8452
  this._git = new git_default(gitInfo, outputChannel);
8091
8453
  this._resolver = new Resolver(this._git, outputChannel);
8092
- if (typeof import_coc14.window.createFloatFactory === "function") {
8093
- this.floatFactory = import_coc14.window.createFloatFactory({ modes: ["n"] });
8454
+ if (typeof import_coc15.window.createFloatFactory === "function") {
8455
+ this.floatFactory = import_coc15.window.createFloatFactory({ modes: ["n"] });
8094
8456
  }
8095
8457
  }
8096
8458
  getRepoFromRoot(root) {
@@ -8116,13 +8478,13 @@ var GitService = class {
8116
8478
  return new GitBuffer(doc, config, relpath, repo, this.git, this.outputChannel, this.floatFactory, hasConflicts);
8117
8479
  }
8118
8480
  async getCurrentRepo() {
8119
- let editor = import_coc14.window.activeTextEditor;
8481
+ let editor = import_coc15.window.activeTextEditor;
8120
8482
  let root;
8121
8483
  if (editor) {
8122
8484
  root = await this.resolver.resolveGitRoot(editor.document);
8123
8485
  } else {
8124
- let cwd = import_coc14.workspace.cwd;
8125
- root = await this.resolver.resolveGitRoot({ uri: import_coc14.Uri.file(cwd).toString(), schema: "file", buftype: "" });
8486
+ let cwd = import_coc15.workspace.cwd;
8487
+ root = await this.resolver.resolveGitRoot({ uri: import_coc15.Uri.file(cwd).toString(), schema: "file", buftype: "" });
8126
8488
  }
8127
8489
  if (root == null) return void 0;
8128
8490
  return this.getRepoFromRoot(root);
@@ -8146,7 +8508,7 @@ var GitService = class {
8146
8508
  };
8147
8509
 
8148
8510
  // src/source.ts
8149
- var import_coc15 = require("coc.nvim");
8511
+ var import_coc16 = require("coc.nvim");
8150
8512
  var import_safe5 = __toESM(require_safe());
8151
8513
  var import_url2 = require("url");
8152
8514
  function byteSlice(content, start, end) {
@@ -8156,7 +8518,7 @@ function byteSlice(content, start, end) {
8156
8518
  var issuesMap = /* @__PURE__ */ new Map();
8157
8519
  function issuesFiletypes() {
8158
8520
  var _a;
8159
- return (_a = import_coc15.workspace.getConfiguration().get("coc.source.issues.filetypes")) != null ? _a : [];
8521
+ return (_a = import_coc16.workspace.getConfiguration().get("coc.source.issues.filetypes")) != null ? _a : [];
8160
8522
  }
8161
8523
  function getOrganizationNameAndRepoNameFromGitHubRemoteUrl(remoteUrl) {
8162
8524
  try {
@@ -8196,7 +8558,7 @@ function renderWord(issue, issueFormat) {
8196
8558
  function addSource(context, service) {
8197
8559
  let { subscriptions, logger } = context;
8198
8560
  const { resolver } = service;
8199
- let statusItem = import_coc15.window.createStatusBarItem(0, { progress: true });
8561
+ let statusItem = import_coc16.window.createStatusBarItem(0, { progress: true });
8200
8562
  subscriptions.push(statusItem, { dispose: () => issuesMap.clear() });
8201
8563
  statusItem.text = "loading issues";
8202
8564
  let statusItemCounter = 0;
@@ -8242,7 +8604,7 @@ function addSource(context, service) {
8242
8604
  while (true) {
8243
8605
  const pageUri = `${uri}&page=${pageIndex}`;
8244
8606
  pageIndex++;
8245
- let info = await (0, import_coc15.fetch)(pageUri, { headers: { "Private-Token": token } });
8607
+ let info = await (0, import_coc16.fetch)(pageUri, { headers: { "Private-Token": token } });
8246
8608
  if (!info.length) {
8247
8609
  break;
8248
8610
  }
@@ -8279,7 +8641,7 @@ function addSource(context, service) {
8279
8641
  let page_uri = `${uri}&page=${page_idx}`;
8280
8642
  page_idx++;
8281
8643
  try {
8282
- let info = await (0, import_coc15.fetch)(page_uri, { headers });
8644
+ let info = await (0, import_coc16.fetch)(page_uri, { headers });
8283
8645
  if (info.length == 0) {
8284
8646
  break;
8285
8647
  }
@@ -8304,7 +8666,7 @@ function addSource(context, service) {
8304
8666
  return issues;
8305
8667
  }
8306
8668
  async function loadIssues(root) {
8307
- let config = import_coc15.workspace.getConfiguration("git", root);
8669
+ let config = import_coc16.workspace.getConfiguration("git", root);
8308
8670
  const repo = service.getRepoFromRoot(root);
8309
8671
  const issueSources = (await repo.safeRun(["config", "--get", "coc-git.issuesources"]) || "").trim();
8310
8672
  if (issueSources) {
@@ -8348,24 +8710,24 @@ function addSource(context, service) {
8348
8710
  var _a;
8349
8711
  if (root) {
8350
8712
  let issues = await loadIssues(root);
8351
- if (((_a = import_coc15.workspace.getDocument(doc.bufnr)) == null ? void 0 : _a.uri) === doc.uri) {
8713
+ if (((_a = import_coc16.workspace.getDocument(doc.bufnr)) == null ? void 0 : _a.uri) === doc.uri) {
8352
8714
  issuesMap.set(doc.bufnr, issues);
8353
8715
  }
8354
8716
  }
8355
8717
  }).catch(onError);
8356
8718
  };
8357
- for (let doc of import_coc15.workspace.documents) {
8719
+ for (let doc of import_coc16.workspace.documents) {
8358
8720
  if (issuesFiletypes().includes(doc.filetype)) {
8359
8721
  loadIssuesFromDocument(doc);
8360
8722
  }
8361
8723
  }
8362
- import_coc15.workspace.onDidOpenTextDocument(async (e) => {
8724
+ import_coc16.workspace.onDidOpenTextDocument(async (e) => {
8363
8725
  if (issuesFiletypes().includes(e.languageId)) {
8364
- let doc = import_coc15.workspace.getDocument(e.uri);
8726
+ let doc = import_coc16.workspace.getDocument(e.uri);
8365
8727
  loadIssuesFromDocument(doc);
8366
8728
  }
8367
8729
  }, null, subscriptions);
8368
- subscriptions.push(import_coc15.workspace.registerAutocmd({
8730
+ subscriptions.push(import_coc16.workspace.registerAutocmd({
8369
8731
  event: "BufUnload",
8370
8732
  arglist: ["+expand('<abuf>')"],
8371
8733
  callback: (bufnr) => {
@@ -8377,7 +8739,7 @@ function addSource(context, service) {
8377
8739
  async doComplete(opt) {
8378
8740
  let pre = byteSlice(opt.line, 0, opt.colnr - 1);
8379
8741
  if (pre && pre.endsWith("#")) {
8380
- const config = import_coc15.workspace.getConfiguration("git");
8742
+ const config = import_coc16.workspace.getConfiguration("git");
8381
8743
  const issueFormat = config.get("issueFormat", "#%i");
8382
8744
  let issues = issuesMap.get(opt.bufnr);
8383
8745
  if (!issues || issues.length == 0) return null;
@@ -8402,14 +8764,14 @@ function addSource(context, service) {
8402
8764
  };
8403
8765
  }
8404
8766
  };
8405
- subscriptions.push(import_coc15.sources.createSource(source));
8767
+ subscriptions.push(import_coc16.sources.createSource(source));
8406
8768
  let list = {
8407
8769
  name: "issues",
8408
8770
  actions: [{
8409
8771
  name: "open",
8410
8772
  execute: async (item) => {
8411
8773
  let { url } = item.data;
8412
- await import_coc15.workspace.openResource(url);
8774
+ await import_coc16.workspace.openResource(url);
8413
8775
  },
8414
8776
  multiple: false
8415
8777
  }, {
@@ -8419,7 +8781,7 @@ function addSource(context, service) {
8419
8781
  let { body, id } = item.data;
8420
8782
  let lines = (body || "").split(/\r?\n/);
8421
8783
  let mod = context2.options.position == "top" ? "below" : "above";
8422
- let { nvim } = import_coc15.workspace;
8784
+ let { nvim } = import_coc16.workspace;
8423
8785
  nvim.pauseNotification();
8424
8786
  nvim.command("pclose", true);
8425
8787
  nvim.command(`${mod} ${lines.length}sp +setl\\ previewwindow [issue ${id}]`, true);
@@ -8438,7 +8800,7 @@ function addSource(context, service) {
8438
8800
  description: "issues on github/gitlab",
8439
8801
  loadItems: async (context2) => {
8440
8802
  let buf = await context2.window.buffer;
8441
- let root = await resolver.resolveGitRoot(import_coc15.workspace.getDocument(buf.id));
8803
+ let root = await resolver.resolveGitRoot(import_coc16.workspace.getDocument(buf.id));
8442
8804
  if (!root) return [];
8443
8805
  let issues = await loadIssues(root);
8444
8806
  return issues.map((o) => {
@@ -8449,134 +8811,673 @@ function addSource(context, service) {
8449
8811
  });
8450
8812
  }
8451
8813
  };
8452
- subscriptions.push(import_coc15.listManager.registerList(list));
8814
+ subscriptions.push(import_coc16.listManager.registerList(list));
8453
8815
  }
8454
8816
 
8817
+ // src/tree/commitFiles.ts
8818
+ var import_fs4 = __toESM(require("fs"));
8819
+ var import_path8 = __toESM(require("path"));
8820
+ var import_coc17 = require("coc.nvim");
8821
+ function emptyAggregate() {
8822
+ return { fileCount: 0, additions: 0, deletions: 0, binaryCount: 0 };
8823
+ }
8824
+ function addAggregate(target, source) {
8825
+ target.fileCount += source.fileCount;
8826
+ target.additions += source.additions;
8827
+ target.deletions += source.deletions;
8828
+ target.binaryCount += source.binaryCount;
8829
+ }
8830
+ function addFileAggregate(target, change) {
8831
+ var _a, _b;
8832
+ target.fileCount++;
8833
+ if (change.binary) {
8834
+ target.binaryCount++;
8835
+ } else {
8836
+ target.additions += (_a = change.additions) != null ? _a : 0;
8837
+ target.deletions += (_b = change.deletions) != null ? _b : 0;
8838
+ }
8839
+ }
8840
+ function treeKey(comparison) {
8841
+ var _a;
8842
+ return `${comparison.commit.sha}\0${(_a = comparison.baseSha) != null ? _a : "root"}`;
8843
+ }
8844
+ function compareNodes(left, right) {
8845
+ if (left.kind === "directory" && right.kind !== "directory") return -1;
8846
+ if (left.kind !== "directory" && right.kind === "directory") return 1;
8847
+ return left.relativePath.localeCompare(right.relativePath);
8848
+ }
8849
+ function buildCommitTree(comparison) {
8850
+ const key = treeKey(comparison);
8851
+ const root = {
8852
+ ...emptyAggregate(),
8853
+ kind: "root",
8854
+ id: `${key}\0root`,
8855
+ name: comparison.commit.subject,
8856
+ relativePath: "",
8857
+ parent: void 0,
8858
+ comparison,
8859
+ children: []
8860
+ };
8861
+ const directories = /* @__PURE__ */ new Map();
8862
+ const ensureDirectory = (segments) => {
8863
+ if (!segments.length) return root;
8864
+ const relativePath = segments.join("/");
8865
+ const existing = directories.get(relativePath);
8866
+ if (existing) return existing;
8867
+ const parent = ensureDirectory(segments.slice(0, -1));
8868
+ const directory = {
8869
+ ...emptyAggregate(),
8870
+ kind: "directory",
8871
+ id: `${key}\0directory\0${relativePath}`,
8872
+ name: segments[segments.length - 1],
8873
+ relativePath,
8874
+ parent,
8875
+ children: []
8876
+ };
8877
+ directories.set(relativePath, directory);
8878
+ parent.children.push(directory);
8879
+ return directory;
8880
+ };
8881
+ for (const change of comparison.changes) {
8882
+ const segments = change.path.split("/");
8883
+ const name = segments.pop();
8884
+ if (!name) throw new Error(`Invalid empty Git path in ${comparison.commit.shortSha}`);
8885
+ const parent = ensureDirectory(segments);
8886
+ const file = {
8887
+ kind: "file",
8888
+ id: `${key}\0file\0${change.path}`,
8889
+ name,
8890
+ relativePath: change.path,
8891
+ parent,
8892
+ change,
8893
+ comparison
8894
+ };
8895
+ parent.children.push(file);
8896
+ }
8897
+ const aggregate = (node) => {
8898
+ const own = emptyAggregate();
8899
+ for (const child of node.children) {
8900
+ if (child.kind === "file") addFileAggregate(own, child.change);
8901
+ else {
8902
+ aggregate(child);
8903
+ addAggregate(own, child);
8904
+ }
8905
+ }
8906
+ node.fileCount = own.fileCount;
8907
+ node.additions = own.additions;
8908
+ node.deletions = own.deletions;
8909
+ node.binaryCount = own.binaryCount;
8910
+ node.children.sort(compareNodes);
8911
+ };
8912
+ aggregate(root);
8913
+ return root;
8914
+ }
8915
+ function escapeDisplay(value) {
8916
+ return value.replace(/\r/g, "\\r").replace(/\n/g, "\\n").replace(/\t/g, "\\t");
8917
+ }
8918
+ function countDescription(node) {
8919
+ const binary = node.binaryCount ? ` \xB7 ${node.binaryCount} binary` : "";
8920
+ return `${node.fileCount} file${node.fileCount === 1 ? "" : "s"} \xB7 +${node.additions} -${node.deletions}${binary}`;
8921
+ }
8922
+ function comparisonDescription(comparison) {
8923
+ var _a;
8924
+ const parent = comparison.baseSha ? `parent ${((_a = comparison.parentIndex) != null ? _a : 0) + 1}/${comparison.commit.parents.length}` : "root";
8925
+ return `${comparison.commit.shortSha} \xB7 ${parent}`;
8926
+ }
8927
+ function statusIcon(status) {
8928
+ if (status === "A") return { text: "+", hlGroup: "DiffAdd" };
8929
+ if (status === "M") return { text: "~", hlGroup: "DiffChange" };
8930
+ if (status === "D") return { text: "-", hlGroup: "DiffDelete" };
8931
+ if (status === "R") return { text: "R", hlGroup: "DiffChange" };
8932
+ if (status === "C") return { text: "C", hlGroup: "DiffAdd" };
8933
+ return { text: status, hlGroup: "WarningMsg" };
8934
+ }
8935
+ function fileDescription(change) {
8936
+ var _a, _b, _c;
8937
+ const status = change.status === "R" || change.status === "C" ? `${change.status}${(_a = change.score) != null ? _a : ""}` : change.status;
8938
+ if (change.binary) return `${status} \xB7 binary`;
8939
+ const stats = `+${(_b = change.additions) != null ? _b : 0} -${(_c = change.deletions) != null ? _c : 0}`;
8940
+ if (change.oldPath) return `${status} \xB7 ${escapeDisplay(change.oldPath)} \u2192 ${escapeDisplay(change.path)} \xB7 ${stats}`;
8941
+ return `${status} \xB7 ${stats}`;
8942
+ }
8943
+ function fileTooltip(change) {
8944
+ var _a;
8945
+ const current = `new path: ${escapeDisplay(change.path)}`;
8946
+ const old = change.oldPath ? `
8947
+ old path: ${escapeDisplay(change.oldPath)}
8948
+ similarity: ${(_a = change.score) != null ? _a : 0}%` : "";
8949
+ return `${current}${old}`;
8950
+ }
8951
+ function nodeCommand(node, title) {
8952
+ return {
8953
+ command: "git.commitFiles.toggle",
8954
+ title,
8955
+ arguments: [node]
8956
+ };
8957
+ }
8958
+ var CommitFilesProvider = class {
8959
+ constructor(comparison, actions) {
8960
+ this.actions = actions;
8961
+ this.emitter = new import_coc17.Emitter();
8962
+ this.onDidChangeTreeData = this.emitter.event;
8963
+ this.root = buildCommitTree(comparison);
8964
+ }
8965
+ setComparison(comparison) {
8966
+ this.root = buildCommitTree(comparison);
8967
+ this.emitter.fire(void 0);
8968
+ }
8969
+ get comparison() {
8970
+ return this.root.comparison;
8971
+ }
8972
+ getTreeItem(element) {
8973
+ if (element.kind === "root") {
8974
+ const item2 = new import_coc17.TreeItem(`${escapeDisplay(element.comparison.commit.shortSha)} ${escapeDisplay(element.name)}`, element.children.length ? import_coc17.TreeItemCollapsibleState.Expanded : import_coc17.TreeItemCollapsibleState.None);
8975
+ item2.id = element.id;
8976
+ item2.description = countDescription(element);
8977
+ item2.tooltip = `${element.comparison.commit.sha}
8978
+ ${element.comparison.commit.author} \xB7 ${element.comparison.commit.authoredAt}`;
8979
+ item2.command = {
8980
+ command: "git.commitFiles.invoke",
8981
+ title: "Show commit",
8982
+ arguments: [element]
8983
+ };
8984
+ return item2;
8985
+ }
8986
+ if (element.kind === "directory") {
8987
+ const item2 = new import_coc17.TreeItem(escapeDisplay(element.name), element.children.length ? import_coc17.TreeItemCollapsibleState.Collapsed : import_coc17.TreeItemCollapsibleState.None);
8988
+ item2.id = element.id;
8989
+ item2.description = countDescription(element);
8990
+ item2.tooltip = escapeDisplay(element.relativePath);
8991
+ item2.command = nodeCommand(element, "Toggle directory");
8992
+ return item2;
8993
+ }
8994
+ const item = new import_coc17.TreeItem(escapeDisplay(element.name), import_coc17.TreeItemCollapsibleState.None);
8995
+ item.id = element.id;
8996
+ item.icon = statusIcon(element.change.status);
8997
+ item.description = fileDescription(element.change);
8998
+ item.tooltip = fileTooltip(element.change);
8999
+ item.command = {
9000
+ command: "git.commitFiles.invoke",
9001
+ title: "Show code",
9002
+ arguments: [element]
9003
+ };
9004
+ return item;
9005
+ }
9006
+ getChildren(element) {
9007
+ if (!element) return [this.root];
9008
+ return element.kind === "file" ? [] : element.children;
9009
+ }
9010
+ getParent(element) {
9011
+ return element.parent;
9012
+ }
9013
+ findFile(relativePath) {
9014
+ const pending = [...this.root.children];
9015
+ while (pending.length) {
9016
+ const node = pending.pop();
9017
+ if (node.kind === "file") {
9018
+ if (node.relativePath === relativePath) return node;
9019
+ } else {
9020
+ pending.push(...node.children);
9021
+ }
9022
+ }
9023
+ return void 0;
9024
+ }
9025
+ resolveActions(_item, element) {
9026
+ if (element.kind === "root") {
9027
+ const result2 = [
9028
+ { title: "Show commit", handler: (item) => this.actions.showCommit(item) },
9029
+ { title: "Copy commit hash", handler: (item) => this.actions.copyCommitHash(item) }
9030
+ ];
9031
+ if (element.comparison.commit.parents.length > 1) {
9032
+ result2.push({ title: "Select parent\u2026", handler: (item) => this.actions.selectParent(item) });
9033
+ }
9034
+ return result2;
9035
+ }
9036
+ if (element.kind === "directory") {
9037
+ return [{ title: "Copy directory path", handler: (item) => this.actions.copyDirectoryPath(item) }];
9038
+ }
9039
+ const result = [
9040
+ { title: "Show code", handler: (item) => this.actions.showCode(item) }
9041
+ ];
9042
+ result.push(
9043
+ { title: "Copy relative path", handler: (item) => this.actions.copyRelativePath(item) },
9044
+ { title: "Open working tree file", handler: (item) => this.actions.openWorkingTree(item) }
9045
+ );
9046
+ if (element.change.status !== "D") result.push({ title: "Open after version", handler: (item) => this.actions.openVersion(item, false) });
9047
+ if (element.change.status !== "A") result.push({ title: "Open before version", handler: (item) => this.actions.openVersion(item, true) });
9048
+ return result;
9049
+ }
9050
+ dispose() {
9051
+ this.emitter.dispose();
9052
+ }
9053
+ };
9054
+ function parseTreeEntry2(output) {
9055
+ if (!output) return void 0;
9056
+ const end = output.indexOf("\0");
9057
+ const record = end < 0 ? output : output.slice(0, end);
9058
+ const tab = record.indexOf(" ");
9059
+ if (tab < 0) throw new Error("Invalid Git tree entry");
9060
+ const fields = record.slice(0, tab).split(" ");
9061
+ if (fields.length !== 3 || !fields[0] || !fields[1] || !fields[2]) throw new Error("Invalid Git tree entry");
9062
+ return { mode: fields[0], type: fields[1], oid: fields[2], path: record.slice(tab + 1) };
9063
+ }
9064
+ async function showScratch(nvim, targetWinId, name, lines, filetype = "git", line = 1) {
9065
+ const moved = await nvim.call("win_gotoid", [targetWinId]);
9066
+ if (!moved) await nvim.command("new");
9067
+ else await nvim.command("enew");
9068
+ const escapedName = await nvim.call("fnameescape", [name]);
9069
+ const content = lines.length ? lines : [""];
9070
+ nvim.pauseNotification();
9071
+ nvim.command("setlocal buftype=nofile bufhidden=wipe noswapfile nobuflisted modifiable", true);
9072
+ nvim.call("setline", [1, content], true);
9073
+ nvim.command(`file ${escapedName}`, true);
9074
+ if (filetype === "git") nvim.command("setlocal filetype=git", true);
9075
+ else nvim.command("filetype detect", true);
9076
+ nvim.command("setlocal nomodifiable readonly", true);
9077
+ nvim.call("cursor", [Math.max(1, Math.min(line, content.length)), 1], true);
9078
+ await nvim.resumeNotification();
9079
+ }
9080
+ var CommitFilesController = class {
9081
+ constructor(manager) {
9082
+ this.manager = manager;
9083
+ }
9084
+ async invoke(node) {
9085
+ if (!node || typeof node !== "object") return;
9086
+ const element = node;
9087
+ if (element.kind === "root") await this.showCommit(element);
9088
+ else if (element.kind === "file") await this.showCode(element);
9089
+ }
9090
+ async toggle(node) {
9091
+ if (!node || typeof node !== "object") return;
9092
+ const element = node;
9093
+ if (element.kind !== "root" && element.kind !== "directory") return;
9094
+ 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")`]);
9098
+ }
9099
+ async open(revision, requestedRoot, options = {}) {
9100
+ var _a;
9101
+ const value = revision === void 0 ? await import_coc17.window.requestInput("Git commit revision", "HEAD") : revision;
9102
+ if (!value || !value.trim()) return;
9103
+ let root = requestedRoot;
9104
+ if (!root) root = await this.manager.resolveGitRootFromBufferOrCwd(await import_coc17.workspace.nvim.call("bufnr", ["%"]));
9105
+ if (!root) {
9106
+ import_coc17.window.showWarningMessage("Can't resolve git repository for current buffer or cwd.");
9107
+ return;
9108
+ }
9109
+ try {
9110
+ root = await this.manager.git.getRepositoryRoot(root);
9111
+ } catch (_e) {
9112
+ import_coc17.window.showWarningMessage("Can't resolve git repository for current buffer or cwd.");
9113
+ return;
9114
+ }
9115
+ let commit;
9116
+ try {
9117
+ commit = await resolveCommit(this.manager.git, root, value.trim());
9118
+ } catch (_e) {
9119
+ import_coc17.window.showErrorMessage(`Invalid Git commit: ${value.trim()}`);
9120
+ return;
9121
+ }
9122
+ let comparison;
9123
+ try {
9124
+ comparison = await loadComparisonForCommit(this.manager.git, root, commit);
9125
+ } catch (e) {
9126
+ import_coc17.window.showErrorMessage(`Failed to load commit ${commit.shortSha}: ${e.message}`);
9127
+ return;
9128
+ }
9129
+ const targetWinId = await import_coc17.workspace.nvim.call("win_getid");
9130
+ const targetBufnr = await import_coc17.workspace.nvim.call("bufnr", ["%"]);
9131
+ this.disposeSession();
9132
+ const provider = new CommitFilesProvider(comparison, this.actions);
9133
+ const view = import_coc17.window.createTreeView("git.commitFiles", {
9134
+ treeDataProvider: provider,
9135
+ enableFilter: true,
9136
+ winfixwidth: true,
9137
+ bufhidden: "wipe",
9138
+ canSelectMany: false,
9139
+ autoWidth: true
9140
+ });
9141
+ view.title = "Commit Files";
9142
+ view.description = comparisonDescription(comparison);
9143
+ this.session = { root, comparison, provider, view, targetWinId, cache: /* @__PURE__ */ new Map([[(_a = comparison.baseSha) != null ? _a : "root", comparison]]) };
9144
+ try {
9145
+ await view.show(import_coc17.workspace.getConfiguration("git").get("commitFiles.splitCommand", "belowright 40vs"));
9146
+ const currentFile = this.currentFileNode(provider, root, targetBufnr);
9147
+ if (currentFile) {
9148
+ await view.reveal(currentFile, { focus: true });
9149
+ if (options.showCurrentFile) await this.showCode(currentFile, options.line);
9150
+ }
9151
+ view.onDidChangeVisibility((event) => {
9152
+ var _a2;
9153
+ if (!event.visible && ((_a2 = this.session) == null ? void 0 : _a2.view) === view) this.disposeSession();
9154
+ });
9155
+ } catch (e) {
9156
+ this.disposeSession();
9157
+ import_coc17.window.showErrorMessage(`Failed to open Commit Files: ${e.message}`);
9158
+ }
9159
+ }
9160
+ get actions() {
9161
+ return {
9162
+ showCommit: (node) => this.showCommit(node),
9163
+ copyCommitHash: (node) => this.copy(node.comparison.commit.sha),
9164
+ selectParent: (node) => this.selectParent(node),
9165
+ copyDirectoryPath: (node) => this.copy(node.relativePath),
9166
+ showCode: (node) => this.showCode(node),
9167
+ openVersion: (node, before) => this.openVersion(node, before),
9168
+ openWorkingTree: (node) => this.openWorkingTree(node),
9169
+ copyRelativePath: (node) => this.copy(node.change.oldPath && node.change.status === "D" ? node.change.oldPath : node.change.path)
9170
+ };
9171
+ }
9172
+ currentFileNode(provider, root, bufnr) {
9173
+ const buffer = this.manager.getBuffer(bufnr);
9174
+ if (!buffer) return void 0;
9175
+ const absolute = import_path8.default.resolve(buffer.repo.root, buffer.relpath);
9176
+ const relative = import_path8.default.relative(root, absolute);
9177
+ if (!relative || relative === ".." || relative.startsWith(`..${import_path8.default.sep}`) || import_path8.default.isAbsolute(relative)) return void 0;
9178
+ return provider.findFile(relative.split(import_path8.default.sep).join("/"));
9179
+ }
9180
+ async copy(value) {
9181
+ await import_coc17.workspace.nvim.call("setreg", ["+", value]);
9182
+ }
9183
+ async showCommit(node) {
9184
+ const session = this.session;
9185
+ if (!session) return;
9186
+ try {
9187
+ const content = await this.manager.git.exec(session.root, ["--no-pager", "show", "--no-ext-diff", "--no-color", node.comparison.commit.sha]);
9188
+ await showScratch(import_coc17.workspace.nvim, session.targetWinId, `[commit ${node.comparison.commit.shortSha}]`, content.stdout.replace(/\r?\n$/, "").split(/\r?\n/));
9189
+ } catch (e) {
9190
+ import_coc17.window.showErrorMessage(`Failed to show commit ${node.comparison.commit.shortSha}: ${e.message}`);
9191
+ }
9192
+ }
9193
+ async showCode(node, line) {
9194
+ const session = this.session;
9195
+ if (!session) return;
9196
+ if (node.change.status === "D") {
9197
+ await this.openVersion(node, true, line);
9198
+ return;
9199
+ }
9200
+ if (node.change.binary) {
9201
+ await this.openVersion(node, false);
9202
+ return;
9203
+ }
9204
+ try {
9205
+ await import_coc17.commands.executeCommand("git.commitFiles.openDocument", session.root, node.comparison, node.change, session.targetWinId, line);
9206
+ } catch (e) {
9207
+ import_coc17.window.showErrorMessage(`Failed to show code for ${node.comparison.commit.shortSha}: ${e.message}`);
9208
+ }
9209
+ }
9210
+ async openVersion(node, before, line) {
9211
+ var _a;
9212
+ const session = this.session;
9213
+ if (!session) return;
9214
+ const comparison = node.comparison;
9215
+ const revision = before ? comparison.baseSha : comparison.commit.sha;
9216
+ const relativePath = before ? (_a = node.change.oldPath) != null ? _a : node.change.path : node.change.path;
9217
+ if (!revision) return;
9218
+ try {
9219
+ const entry = parseTreeEntry2((await this.manager.git.exec(session.root, ["ls-tree", "-z", revision, "--", relativePath])).stdout);
9220
+ if (!entry) {
9221
+ import_coc17.window.showWarningMessage(`Git path not found: ${escapeDisplay(relativePath)}`);
9222
+ return;
9223
+ }
9224
+ if (node.change.binary || entry.type !== "blob") {
9225
+ const size = entry.type === "blob" ? (await this.manager.git.exec(session.root, ["cat-file", "-s", entry.oid])).stdout.trim() : "n/a";
9226
+ await showScratch(import_coc17.workspace.nvim, session.targetWinId, `[version ${comparison.commit.shortSha} ${relativePath}]`, [
9227
+ `revision: ${revision}`,
9228
+ `path: ${escapeDisplay(relativePath)}`,
9229
+ `mode: ${entry.mode}`,
9230
+ `type: ${entry.type}`,
9231
+ `object: ${entry.oid}`,
9232
+ `size: ${size}`
9233
+ ]);
9234
+ return;
9235
+ }
9236
+ const content = await this.manager.git.exec(session.root, ["cat-file", "-p", entry.oid]);
9237
+ await showScratch(import_coc17.workspace.nvim, session.targetWinId, `[version ${comparison.commit.shortSha} ${relativePath}]`, content.stdout.replace(/\r?\n$/, "").split(/\r?\n/), "detect", line);
9238
+ } catch (e) {
9239
+ import_coc17.window.showErrorMessage(`Failed to open version for ${comparison.commit.shortSha}: ${e.message}`);
9240
+ }
9241
+ }
9242
+ async openWorkingTree(node) {
9243
+ const session = this.session;
9244
+ if (!session) return;
9245
+ const relativePath = node.change.status === "D" && node.change.oldPath ? node.change.oldPath : node.change.path;
9246
+ const absolute = import_path8.default.resolve(session.root, ...relativePath.split("/"));
9247
+ const relative = import_path8.default.relative(session.root, absolute);
9248
+ if (relative.startsWith(`..${import_path8.default.sep}`) || import_path8.default.isAbsolute(relative)) {
9249
+ import_coc17.window.showWarningMessage(`Working tree path is outside repository: ${escapeDisplay(relativePath)}`);
9250
+ return;
9251
+ }
9252
+ let stat;
9253
+ try {
9254
+ stat = await import_fs4.default.promises.stat(absolute);
9255
+ } catch (_e) {
9256
+ import_coc17.window.showWarningMessage(`Working tree file not found: ${escapeDisplay(relativePath)}`);
9257
+ return;
9258
+ }
9259
+ if (!stat.isFile()) {
9260
+ import_coc17.window.showWarningMessage(`Working tree path is not a file: ${escapeDisplay(relativePath)}`);
9261
+ return;
9262
+ }
9263
+ const moved = await import_coc17.workspace.nvim.call("win_gotoid", [session.targetWinId]);
9264
+ if (!moved) await import_coc17.workspace.nvim.command("new");
9265
+ try {
9266
+ await import_coc17.workspace.openResource(import_coc17.Uri.file(absolute).toString());
9267
+ } catch (e) {
9268
+ import_coc17.window.showErrorMessage(`Failed to open working tree file for ${node.comparison.commit.shortSha}: ${e.message}`);
9269
+ }
9270
+ }
9271
+ async selectParent(node) {
9272
+ var _a, _b, _c;
9273
+ const session = this.session;
9274
+ if (!session || node.comparison.commit.parents.length < 2) return;
9275
+ const choices = node.comparison.commit.parents.map((sha, index) => `${index + 1}/${node.comparison.commit.parents.length} ${sha.slice(0, 12)}`);
9276
+ const selected = await import_coc17.window.showQuickPick(choices, { placeHolder: "Select parent commit" });
9277
+ if (!selected) return;
9278
+ const parentIndex = choices.indexOf(selected);
9279
+ if (parentIndex < 0) return;
9280
+ const parentSha = node.comparison.commit.parents[parentIndex];
9281
+ (_a = session.token) == null ? void 0 : _a.cancel();
9282
+ (_b = session.token) == null ? void 0 : _b.dispose();
9283
+ const token = new import_coc17.CancellationTokenSource();
9284
+ session.token = token;
9285
+ try {
9286
+ await assertParentAvailable(this.manager.git, session.root, parentSha, token.token);
9287
+ } catch (e) {
9288
+ if (!token.token.isCancellationRequested) {
9289
+ import_coc17.window.showErrorMessage(`Parent commit is not available in this shallow repository: ${parentSha.slice(0, 12)}`);
9290
+ }
9291
+ token.dispose();
9292
+ if (session.token === token) session.token = void 0;
9293
+ return;
9294
+ }
9295
+ try {
9296
+ const key = parentSha;
9297
+ let comparison = session.cache.get(key);
9298
+ if (!comparison) {
9299
+ comparison = await loadComparisonForCommit(this.manager.git, session.root, node.comparison.commit, parentIndex, token.token);
9300
+ session.cache.set(key, comparison);
9301
+ }
9302
+ if (token.token.isCancellationRequested || this.session !== session) return;
9303
+ session.comparison = comparison;
9304
+ session.provider.setComparison(comparison);
9305
+ session.view.description = comparisonDescription(comparison);
9306
+ } catch (e) {
9307
+ if (!token.token.isCancellationRequested) {
9308
+ const message = (_c = e == null ? void 0 : e.message) != null ? _c : "";
9309
+ import_coc17.window.showErrorMessage(`Failed to load parent ${parentSha.slice(0, 12)} for ${node.comparison.commit.shortSha}: ${message}`);
9310
+ }
9311
+ } finally {
9312
+ token.dispose();
9313
+ if (session.token === token) session.token = void 0;
9314
+ }
9315
+ }
9316
+ disposeSession() {
9317
+ var _a, _b;
9318
+ const session = this.session;
9319
+ if (!session) return;
9320
+ this.session = void 0;
9321
+ (_a = session.token) == null ? void 0 : _a.cancel();
9322
+ (_b = session.token) == null ? void 0 : _b.dispose();
9323
+ session.provider.dispose();
9324
+ session.view.dispose();
9325
+ }
9326
+ dispose() {
9327
+ this.disposeSession();
9328
+ }
9329
+ };
9330
+
8455
9331
  // src/index.ts
8456
9332
  async function activate(context) {
8457
9333
  var _a;
8458
- const config = import_coc16.workspace.getConfiguration("git");
9334
+ const config = import_coc18.workspace.getConfiguration("git");
8459
9335
  const { subscriptions } = context;
8460
9336
  let gitInfo;
8461
9337
  try {
8462
9338
  let pathHint = config.get("command", "git");
8463
- gitInfo = await findGit(pathHint, (path8) => context.logger.info(`Looking for git in: ${path8}`));
9339
+ gitInfo = await findGit(pathHint, (path9) => context.logger.info(`Looking for git in: ${path9}`));
8464
9340
  } catch (e) {
8465
- import_coc16.window.showErrorMessage("git command required for coc-git");
9341
+ import_coc18.window.showErrorMessage("git command required for coc-git");
8466
9342
  return;
8467
9343
  }
8468
- const virtualTextSrcId = await import_coc16.workspace.nvim.createNamespace("coc-git-virtual");
8469
- const conflictSrcId = await import_coc16.workspace.nvim.createNamespace("coc-git-conflicts");
8470
- const { nvim } = import_coc16.workspace;
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;
8471
9348
  const service = new GitService(gitInfo);
8472
9349
  const manager = new DocumentManager(nvim, service, virtualTextSrcId, conflictSrcId);
8473
9350
  subscriptions.push(manager);
9351
+ const commitDocuments = new CommitDocumentProvider(service.git, commitDocumentSrcId);
9352
+ subscriptions.push(commitDocuments);
9353
+ subscriptions.push(import_coc18.workspace.registerTextDocumentContentProvider(COMMIT_DOCUMENT_SCHEME, commitDocuments));
9354
+ nvim.command("highlight default link CocGitCommitAdd DiffAdd", true);
9355
+ nvim.command("highlight default link CocGitCommitDelete DiffDelete", true);
9356
+ const commitFiles = new CommitFilesController(manager);
9357
+ subscriptions.push(commitFiles);
8474
9358
  addSource(context, service);
8475
- subscriptions.push(import_coc16.commands.registerCommand("git.refresh", () => {
9359
+ subscriptions.push(import_coc18.commands.registerCommand("git.refresh", () => {
8476
9360
  manager.refresh();
8477
9361
  }));
8478
- subscriptions.push(import_coc16.workspace.registerKeymap(["n"], "git-nextchunk", async () => {
8479
- await manager.nextChunk();
9362
+ subscriptions.push(import_coc18.workspace.registerKeymap(["n"], "git-nextchunk", async () => {
9363
+ if (!await commitDocuments.nextChunk()) await manager.nextChunk();
8480
9364
  }, { sync: false }));
8481
- subscriptions.push(import_coc16.workspace.registerKeymap(["n"], "git-prevchunk", async () => {
8482
- await manager.prevChunk();
9365
+ subscriptions.push(import_coc18.workspace.registerKeymap(["n"], "git-prevchunk", async () => {
9366
+ if (!await commitDocuments.prevChunk()) await manager.prevChunk();
8483
9367
  }, { sync: false }));
8484
- subscriptions.push(import_coc16.workspace.registerKeymap(["n"], "git-nextconflict", async () => {
9368
+ subscriptions.push(import_coc18.workspace.registerKeymap(["n"], "git-nextconflict", async () => {
8485
9369
  await manager.nextConflict();
8486
9370
  }, { sync: false }));
8487
- subscriptions.push(import_coc16.workspace.registerKeymap(["n"], "git-prevconflict", async () => {
9371
+ subscriptions.push(import_coc18.workspace.registerKeymap(["n"], "git-prevconflict", async () => {
8488
9372
  await manager.prevConflict();
8489
9373
  }, { sync: false }));
8490
- subscriptions.push(import_coc16.workspace.registerKeymap(["n"], "git-keepcurrent", async () => {
9374
+ subscriptions.push(import_coc18.workspace.registerKeymap(["n"], "git-keepcurrent", async () => {
8491
9375
  await manager.keepCurrent();
8492
9376
  }, { sync: false }));
8493
- subscriptions.push(import_coc16.workspace.registerKeymap(["n"], "git-keepincoming", async () => {
9377
+ subscriptions.push(import_coc18.workspace.registerKeymap(["n"], "git-keepincoming", async () => {
8494
9378
  await manager.keepIncoming();
8495
9379
  }, { sync: false }));
8496
- subscriptions.push(import_coc16.workspace.registerKeymap(["n"], "git-keepboth", async () => {
9380
+ subscriptions.push(import_coc18.workspace.registerKeymap(["n"], "git-keepboth", async () => {
8497
9381
  await manager.keepBoth();
8498
9382
  }, { sync: false }));
8499
- subscriptions.push(import_coc16.workspace.registerKeymap(["n"], "git-chunkinfo", async () => {
9383
+ subscriptions.push(import_coc18.workspace.registerKeymap(["n"], "git-chunkinfo", async () => {
8500
9384
  await manager.chunkInfo();
8501
9385
  }, { sync: false }));
8502
- subscriptions.push(import_coc16.workspace.registerKeymap(["n"], "git-commit", async () => {
9386
+ subscriptions.push(import_coc18.workspace.registerKeymap(["n"], "git-commit", async () => {
8503
9387
  await manager.showCommit();
8504
9388
  }, { sync: false }));
8505
- subscriptions.push(import_coc16.workspace.registerKeymap(["n"], "git-showblamedoc", async () => {
9389
+ subscriptions.push(import_coc18.workspace.registerKeymap(["n"], "git-showblamedoc", async () => {
8506
9390
  await manager.showBlameDoc();
8507
9391
  }, { sync: false }));
8508
- subscriptions.push(import_coc16.commands.registerCommand("git.nextChunk", async () => {
8509
- await manager.nextChunk();
9392
+ subscriptions.push(import_coc18.commands.registerCommand("git.nextChunk", async () => {
9393
+ if (!await commitDocuments.nextChunk()) await manager.nextChunk();
8510
9394
  }));
8511
- subscriptions.push(import_coc16.commands.registerCommand("git.prevChunk", async () => {
8512
- await manager.prevChunk();
9395
+ subscriptions.push(import_coc18.commands.registerCommand("git.prevChunk", async () => {
9396
+ if (!await commitDocuments.prevChunk()) await manager.prevChunk();
8513
9397
  }));
8514
- subscriptions.push(import_coc16.commands.registerCommand("git.keepCurrent", async () => {
9398
+ subscriptions.push(import_coc18.commands.registerCommand("git.keepCurrent", async () => {
8515
9399
  await manager.keepCurrent();
8516
9400
  }));
8517
- subscriptions.push(import_coc16.commands.registerCommand("git.keepIncoming", async () => {
9401
+ subscriptions.push(import_coc18.commands.registerCommand("git.keepIncoming", async () => {
8518
9402
  await manager.keepIncoming();
8519
9403
  }));
8520
- subscriptions.push(import_coc16.commands.registerCommand("git.keepBoth", async () => {
9404
+ subscriptions.push(import_coc18.commands.registerCommand("git.keepBoth", async () => {
8521
9405
  await manager.keepBoth();
8522
9406
  }));
8523
- subscriptions.push(import_coc16.commands.registerCommand("git.chunkInfo", async () => {
9407
+ subscriptions.push(import_coc18.commands.registerCommand("git.chunkInfo", async () => {
8524
9408
  await manager.chunkInfo();
8525
9409
  }));
8526
- subscriptions.push(import_coc16.commands.registerCommand("git.allChunkInfo", async () => {
9410
+ subscriptions.push(import_coc18.commands.registerCommand("git.allChunkInfo", async () => {
8527
9411
  return await manager.allChunkInfo();
8528
9412
  }));
8529
- subscriptions.push(import_coc16.commands.registerCommand("git.chunkStage", async () => {
9413
+ subscriptions.push(import_coc18.commands.registerCommand("git.chunkStage", async () => {
8530
9414
  await manager.chunkStage();
8531
9415
  }));
8532
- subscriptions.push(import_coc16.commands.registerCommand("git.chunkUnstage", async () => {
9416
+ subscriptions.push(import_coc18.commands.registerCommand("git.chunkUnstage", async () => {
8533
9417
  await manager.chunkUnstage();
8534
9418
  }));
8535
- subscriptions.push(import_coc16.commands.registerCommand("git.chunkUndo", async () => {
9419
+ subscriptions.push(import_coc18.commands.registerCommand("git.chunkUndo", async () => {
8536
9420
  await manager.chunkUndo();
8537
9421
  }));
8538
- subscriptions.push(import_coc16.commands.registerCommand("git.showCommit", async () => {
9422
+ subscriptions.push(import_coc18.commands.registerCommand("git.showCommit", async () => {
8539
9423
  await manager.showCommit();
8540
9424
  }));
8541
- subscriptions.push(import_coc16.commands.registerCommand("git.browserOpen", async () => {
9425
+ subscriptions.push(import_coc18.commands.registerCommand("git.commitFiles.open", async (revision, root) => {
9426
+ await commitFiles.open(revision, root);
9427
+ }, void 0, true));
9428
+ subscriptions.push(import_coc18.commands.registerCommand("git.showCommitTree", async () => {
9429
+ const current = await manager.getCurrentCommit();
9430
+ if (current) await commitFiles.open(current.sha, current.root, { showCurrentFile: true, line: current.line });
9431
+ }));
9432
+ subscriptions.push(import_coc18.commands.registerCommand("git.commitFiles.invoke", async (node) => {
9433
+ await commitFiles.invoke(node);
9434
+ }, void 0, true));
9435
+ subscriptions.push(import_coc18.commands.registerCommand("git.commitFiles.toggle", async (node) => {
9436
+ await commitFiles.toggle(node);
9437
+ }, void 0, true));
9438
+ subscriptions.push(import_coc18.commands.registerCommand("git.commitFiles.openDocument", async (root, comparison, change, targetWinId, line) => {
9439
+ targetWinId = targetWinId != null ? targetWinId : await nvim.call("win_getid");
9440
+ await commitDocuments.open(root, comparison, change, targetWinId, line);
9441
+ }, void 0, true));
9442
+ subscriptions.push(import_coc18.commands.registerCommand("git.browserOpen", async () => {
8542
9443
  await manager.browser();
8543
9444
  }));
8544
- subscriptions.push(import_coc16.commands.registerCommand("git.copyUrl", async (...args) => {
9445
+ subscriptions.push(import_coc18.commands.registerCommand("git.copyUrl", async (...args) => {
8545
9446
  await manager.browser("copy", args);
8546
9447
  }));
8547
- subscriptions.push(import_coc16.commands.registerCommand("git.copyPermalink", async (...args) => {
9448
+ subscriptions.push(import_coc18.commands.registerCommand("git.copyPermalink", async (...args) => {
8548
9449
  await manager.browser("copy", args, true);
8549
9450
  }));
8550
- subscriptions.push(import_coc16.commands.registerCommand("git.push", async (...args) => {
9451
+ subscriptions.push(import_coc18.commands.registerCommand("git.push", async (...args) => {
8551
9452
  await manager.push(args);
8552
9453
  }));
8553
- subscriptions.push(import_coc16.commands.registerCommand("git.diffCached", async () => {
9454
+ subscriptions.push(import_coc18.commands.registerCommand("git.diffCached", async () => {
8554
9455
  await manager.diffCached();
8555
9456
  }));
8556
- subscriptions.push(import_coc16.commands.registerCommand("git.toggleGutters", async () => {
9457
+ subscriptions.push(import_coc18.commands.registerCommand("git.toggleGutters", async () => {
8557
9458
  await manager.toggleGutters();
8558
9459
  }));
8559
- subscriptions.push(import_coc16.commands.registerCommand("git.foldUnchanged", async () => {
9460
+ subscriptions.push(import_coc18.commands.registerCommand("git.foldUnchanged", async () => {
8560
9461
  await manager.toggleFold();
8561
9462
  }));
8562
- subscriptions.push(import_coc16.commands.registerCommand("git.showBlameDoc", async () => {
9463
+ subscriptions.push(import_coc18.commands.registerCommand("git.showBlameDoc", async () => {
8563
9464
  await manager.showBlameDoc();
8564
9465
  }));
8565
- subscriptions.push(import_coc16.listManager.registerList(new GStatus(nvim, manager)));
8566
- subscriptions.push(import_coc16.listManager.registerList(new Branches(nvim, manager)));
8567
- subscriptions.push(import_coc16.listManager.registerList(new Commits(nvim, manager)));
8568
- subscriptions.push(import_coc16.listManager.registerList(new Bcommits(nvim, manager)));
8569
- subscriptions.push(import_coc16.listManager.registerList(new Gfiles(nvim, manager)));
8570
- subscriptions.push(import_coc16.listManager.registerList(new GChunks(nvim, manager)));
8571
- subscriptions.push(import_coc16.listManager.registerList(new GChanges(nvim, manager)));
8572
- subscriptions.push(import_coc16.languages.registerCompletionItemProvider("semantic-commit", "Commit", (_a = config.get("semanticCommit.filetypes")) != null ? _a : [], {
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 : [], {
8573
9474
  provideCompletionItems: async (document, position) => {
8574
9475
  if (position.line !== 0) {
8575
9476
  return [];
8576
9477
  }
8577
9478
  const text = document.getText(
8578
- import_coc16.Range.create(
8579
- import_coc16.Position.create(position.line, 0),
9479
+ import_coc18.Range.create(
9480
+ import_coc18.Position.create(position.line, 0),
8580
9481
  position
8581
9482
  )
8582
9483
  );
@@ -8586,10 +9487,10 @@ async function activate(context) {
8586
9487
  return DEFAULT_TYPES.map((o) => {
8587
9488
  return {
8588
9489
  label: o.value,
8589
- kind: import_coc16.CompletionItemKind.Snippet,
9490
+ kind: import_coc18.CompletionItemKind.Snippet,
8590
9491
  documentation: { kind: "plaintext", value: o.name },
8591
9492
  // detail: o.name,
8592
- insertTextFormat: import_coc16.InsertTextFormat.Snippet,
9493
+ insertTextFormat: import_coc18.InsertTextFormat.Snippet,
8593
9494
  // tslint:disable-next-line: no-invalid-template-strings
8594
9495
  insertText: o.value + text2 + "\n\n"
8595
9496
  };
@@ -8598,12 +9499,12 @@ async function activate(context) {
8598
9499
  return [];
8599
9500
  }
8600
9501
  }));
8601
- subscriptions.push(import_coc16.workspace.registerKeymap(["o", "x"], "git-chunk-inner", async () => {
9502
+ subscriptions.push(import_coc18.workspace.registerKeymap(["o", "x"], "git-chunk-inner", async () => {
8602
9503
  let diff = await manager.getCurrentChunk();
8603
9504
  if (!diff) return;
8604
9505
  await nvim.command(`normal! ${diff.start}GV${diff.end}G`);
8605
9506
  }, { sync: true, silent: true }));
8606
- subscriptions.push(import_coc16.workspace.registerKeymap(["o", "x"], "git-chunk-outer", async () => {
9507
+ subscriptions.push(import_coc18.workspace.registerKeymap(["o", "x"], "git-chunk-outer", async () => {
8607
9508
  let diff = await manager.getCurrentChunk();
8608
9509
  if (!diff) return;
8609
9510
  let total = await nvim.call("line", ["$"]);