coc-git 2.7.9 → 2.7.11
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/AGENTS.md +61 -0
- package/LICENCE +19 -0
- package/Readme.md +58 -13
- package/history.md +13 -1
- package/lib/index.js +1599 -267
- package/package.json +21 -1
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
|
|
699
|
-
function checkPathExt(
|
|
698
|
+
var fs6 = require("fs");
|
|
699
|
+
function checkPathExt(path10, options) {
|
|
700
700
|
var pathext = options.pathExt !== void 0 ? options.pathExt : process.env.PATHEXT;
|
|
701
701
|
if (!pathext) {
|
|
702
702
|
return true;
|
|
@@ -707,25 +707,25 @@ var require_windows = __commonJS({
|
|
|
707
707
|
}
|
|
708
708
|
for (var i = 0; i < pathext.length; i++) {
|
|
709
709
|
var p = pathext[i].toLowerCase();
|
|
710
|
-
if (p &&
|
|
710
|
+
if (p && path10.substr(-p.length).toLowerCase() === p) {
|
|
711
711
|
return true;
|
|
712
712
|
}
|
|
713
713
|
}
|
|
714
714
|
return false;
|
|
715
715
|
}
|
|
716
|
-
function checkStat(stat,
|
|
716
|
+
function checkStat(stat, path10, options) {
|
|
717
717
|
if (!stat.isSymbolicLink() && !stat.isFile()) {
|
|
718
718
|
return false;
|
|
719
719
|
}
|
|
720
|
-
return checkPathExt(
|
|
720
|
+
return checkPathExt(path10, options);
|
|
721
721
|
}
|
|
722
|
-
function isexe(
|
|
723
|
-
|
|
724
|
-
cb(er, er ? false : checkStat(stat,
|
|
722
|
+
function isexe(path10, options, cb) {
|
|
723
|
+
fs6.stat(path10, function(er, stat) {
|
|
724
|
+
cb(er, er ? false : checkStat(stat, path10, options));
|
|
725
725
|
});
|
|
726
726
|
}
|
|
727
|
-
function sync(
|
|
728
|
-
return checkStat(
|
|
727
|
+
function sync(path10, options) {
|
|
728
|
+
return checkStat(fs6.statSync(path10), path10, options);
|
|
729
729
|
}
|
|
730
730
|
}
|
|
731
731
|
});
|
|
@@ -735,14 +735,14 @@ var require_mode = __commonJS({
|
|
|
735
735
|
"node_modules/isexe/mode.js"(exports2, module2) {
|
|
736
736
|
module2.exports = isexe;
|
|
737
737
|
isexe.sync = sync;
|
|
738
|
-
var
|
|
739
|
-
function isexe(
|
|
740
|
-
|
|
738
|
+
var fs6 = require("fs");
|
|
739
|
+
function isexe(path10, options, cb) {
|
|
740
|
+
fs6.stat(path10, function(er, stat) {
|
|
741
741
|
cb(er, er ? false : checkStat(stat, options));
|
|
742
742
|
});
|
|
743
743
|
}
|
|
744
|
-
function sync(
|
|
745
|
-
return checkStat(
|
|
744
|
+
function sync(path10, options) {
|
|
745
|
+
return checkStat(fs6.statSync(path10), options);
|
|
746
746
|
}
|
|
747
747
|
function checkStat(stat, options) {
|
|
748
748
|
return stat.isFile() && checkMode(stat, options);
|
|
@@ -766,7 +766,7 @@ var require_mode = __commonJS({
|
|
|
766
766
|
// node_modules/isexe/index.js
|
|
767
767
|
var require_isexe = __commonJS({
|
|
768
768
|
"node_modules/isexe/index.js"(exports2, module2) {
|
|
769
|
-
var
|
|
769
|
+
var fs6 = require("fs");
|
|
770
770
|
var core;
|
|
771
771
|
if (process.platform === "win32" || global.TESTING_WINDOWS) {
|
|
772
772
|
core = require_windows();
|
|
@@ -775,7 +775,7 @@ var require_isexe = __commonJS({
|
|
|
775
775
|
}
|
|
776
776
|
module2.exports = isexe;
|
|
777
777
|
isexe.sync = sync;
|
|
778
|
-
function isexe(
|
|
778
|
+
function isexe(path10, options, cb) {
|
|
779
779
|
if (typeof options === "function") {
|
|
780
780
|
cb = options;
|
|
781
781
|
options = {};
|
|
@@ -785,7 +785,7 @@ var require_isexe = __commonJS({
|
|
|
785
785
|
throw new TypeError("callback not provided");
|
|
786
786
|
}
|
|
787
787
|
return new Promise(function(resolve, reject) {
|
|
788
|
-
isexe(
|
|
788
|
+
isexe(path10, options || {}, function(er, is) {
|
|
789
789
|
if (er) {
|
|
790
790
|
reject(er);
|
|
791
791
|
} else {
|
|
@@ -794,7 +794,7 @@ var require_isexe = __commonJS({
|
|
|
794
794
|
});
|
|
795
795
|
});
|
|
796
796
|
}
|
|
797
|
-
core(
|
|
797
|
+
core(path10, options || {}, function(er, is) {
|
|
798
798
|
if (er) {
|
|
799
799
|
if (er.code === "EACCES" || options && options.ignoreErrors) {
|
|
800
800
|
er = null;
|
|
@@ -804,9 +804,9 @@ var require_isexe = __commonJS({
|
|
|
804
804
|
cb(er, is);
|
|
805
805
|
});
|
|
806
806
|
}
|
|
807
|
-
function sync(
|
|
807
|
+
function sync(path10, options) {
|
|
808
808
|
try {
|
|
809
|
-
return core.sync(
|
|
809
|
+
return core.sync(path10, options || {});
|
|
810
810
|
} catch (er) {
|
|
811
811
|
if (options && options.ignoreErrors || er.code === "EACCES") {
|
|
812
812
|
return false;
|
|
@@ -822,7 +822,7 @@ var require_isexe = __commonJS({
|
|
|
822
822
|
var require_which = __commonJS({
|
|
823
823
|
"node_modules/which/which.js"(exports2, module2) {
|
|
824
824
|
var isWindows = process.platform === "win32" || process.env.OSTYPE === "cygwin" || process.env.OSTYPE === "msys";
|
|
825
|
-
var
|
|
825
|
+
var path10 = require("path");
|
|
826
826
|
var COLON = isWindows ? ";" : ":";
|
|
827
827
|
var isexe = require_isexe();
|
|
828
828
|
var getNotFoundError = (cmd) => Object.assign(new Error(`not found: ${cmd}`), { code: "ENOENT" });
|
|
@@ -860,7 +860,7 @@ var require_which = __commonJS({
|
|
|
860
860
|
return opt.all && found.length ? resolve(found) : reject(getNotFoundError(cmd));
|
|
861
861
|
const ppRaw = pathEnv[i];
|
|
862
862
|
const pathPart = /^".*"$/.test(ppRaw) ? ppRaw.slice(1, -1) : ppRaw;
|
|
863
|
-
const pCmd =
|
|
863
|
+
const pCmd = path10.join(pathPart, cmd);
|
|
864
864
|
const p = !pathPart && /^\.[\\\/]/.test(cmd) ? cmd.slice(0, 2) + pCmd : pCmd;
|
|
865
865
|
resolve(subStep(p, i, 0));
|
|
866
866
|
});
|
|
@@ -887,7 +887,7 @@ var require_which = __commonJS({
|
|
|
887
887
|
for (let i = 0; i < pathEnv.length; i++) {
|
|
888
888
|
const ppRaw = pathEnv[i];
|
|
889
889
|
const pathPart = /^".*"$/.test(ppRaw) ? ppRaw.slice(1, -1) : ppRaw;
|
|
890
|
-
const pCmd =
|
|
890
|
+
const pCmd = path10.join(pathPart, cmd);
|
|
891
891
|
const p = !pathPart && /^\.[\\\/]/.test(cmd) ? cmd.slice(0, 2) + pCmd : pCmd;
|
|
892
892
|
for (let j = 0; j < pathExt.length; j++) {
|
|
893
893
|
const cur = p + pathExt[j];
|
|
@@ -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
|
|
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
|
|
984
|
-
if (!
|
|
983
|
+
for (key in Buffer3) {
|
|
984
|
+
if (!Buffer3.hasOwnProperty(key)) continue;
|
|
985
985
|
if (key === "allocUnsafe" || key === "allocUnsafeSlow") continue;
|
|
986
|
-
Safer[key] =
|
|
986
|
+
Safer[key] = Buffer3[key];
|
|
987
987
|
}
|
|
988
|
-
safer.Buffer.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
|
|
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 =
|
|
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
|
|
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 (
|
|
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 (!
|
|
1124
|
-
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
|
|
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
|
|
1147
|
+
return Buffer3.from(str, "base64");
|
|
1148
1148
|
};
|
|
1149
1149
|
InternalEncoderBase64.prototype.end = function() {
|
|
1150
|
-
return
|
|
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 =
|
|
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
|
|
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 =
|
|
1256
|
-
var dst =
|
|
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 =
|
|
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 =
|
|
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
|
|
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 =
|
|
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 =
|
|
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
|
|
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
|
|
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(
|
|
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(
|
|
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(
|
|
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 =
|
|
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 =
|
|
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 =
|
|
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(
|
|
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(
|
|
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(
|
|
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
|
|
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 =
|
|
1805
|
-
var encodeBuf =
|
|
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 =
|
|
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 =
|
|
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
|
|
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 =
|
|
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 =
|
|
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 =
|
|
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
|
|
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,
|
|
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 (!
|
|
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
|
|
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 ?
|
|
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 =
|
|
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
|
|
4540
|
+
var import_coc19 = require("coc.nvim");
|
|
4541
4541
|
|
|
4542
4542
|
// src/constants.ts
|
|
4543
4543
|
var DEFAULT_TYPES = [
|
|
@@ -4673,12 +4673,12 @@ var Bcommits = class extends import_coc.BasicList {
|
|
|
4673
4673
|
}, { tabPersist: true });
|
|
4674
4674
|
this.addAction("view", async (item, context) => {
|
|
4675
4675
|
let { commit, root, file } = item.data;
|
|
4676
|
-
let { window:
|
|
4676
|
+
let { window: window13 } = context;
|
|
4677
4677
|
let content = (await this.manager.git.exec(root, ["show", `${commit}:${file}`])).stdout;
|
|
4678
4678
|
let lines = content.replace(/\n$/, "").split("\n");
|
|
4679
4679
|
let name = await nvim.call("fnameescape", [`(${commit}) ${file}`]);
|
|
4680
4680
|
nvim.pauseNotification();
|
|
4681
|
-
nvim.call("win_gotoid", [
|
|
4681
|
+
nvim.call("win_gotoid", [window13.id], true);
|
|
4682
4682
|
nvim.command(`tabe ${name}`, true);
|
|
4683
4683
|
nvim.call("append", [0, lines], true);
|
|
4684
4684
|
nvim.command("normal! Gdd", true);
|
|
@@ -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}`;
|
|
@@ -5159,6 +5169,21 @@ var import_safe2 = __toESM(require_safe());
|
|
|
5159
5169
|
var import_fs = __toESM(require("fs"));
|
|
5160
5170
|
var import_path3 = __toESM(require("path"));
|
|
5161
5171
|
|
|
5172
|
+
// src/model/statusEntry.ts
|
|
5173
|
+
function parseStatusEntries(output) {
|
|
5174
|
+
const result = [];
|
|
5175
|
+
const entries = output.split("\0");
|
|
5176
|
+
for (let i = 0; i < entries.length; i++) {
|
|
5177
|
+
const line = entries[i];
|
|
5178
|
+
if (!line) continue;
|
|
5179
|
+
result.push({ index: line[0], tree: line[1], relative: line.slice(3) });
|
|
5180
|
+
if (line[0] === "R" || line[0] === "C" || line[1] === "R" || line[1] === "C") {
|
|
5181
|
+
i++;
|
|
5182
|
+
}
|
|
5183
|
+
}
|
|
5184
|
+
return result;
|
|
5185
|
+
}
|
|
5186
|
+
|
|
5162
5187
|
// src/util.ts
|
|
5163
5188
|
var import_child_process = require("child_process");
|
|
5164
5189
|
var import_coc5 = require("coc.nvim");
|
|
@@ -5325,20 +5350,20 @@ function findSystemGitWin32(base, onLookup) {
|
|
|
5325
5350
|
return findSpecificGit(import_path2.default.join(base, "Git", "cmd", "git.exe"), onLookup);
|
|
5326
5351
|
}
|
|
5327
5352
|
function findGitWin32InPath(onLookup) {
|
|
5328
|
-
const whichPromise = new Promise((c, e) => (0, import_which.default)("git.exe", (err,
|
|
5329
|
-
return whichPromise.then((
|
|
5353
|
+
const whichPromise = new Promise((c, e) => (0, import_which.default)("git.exe", (err, path10) => err ? e(err) : c(path10)));
|
|
5354
|
+
return whichPromise.then((path10) => findSpecificGit(path10, onLookup));
|
|
5330
5355
|
}
|
|
5331
5356
|
function findGitWin32(onLookup) {
|
|
5332
5357
|
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
5358
|
}
|
|
5334
|
-
function findSpecificGit(
|
|
5359
|
+
function findSpecificGit(path10, onLookup) {
|
|
5335
5360
|
return new Promise((c, e) => {
|
|
5336
|
-
onLookup(
|
|
5361
|
+
onLookup(path10);
|
|
5337
5362
|
const buffers = [];
|
|
5338
|
-
const child = (0, import_child_process.spawn)(
|
|
5363
|
+
const child = (0, import_child_process.spawn)(path10, ["--version"]);
|
|
5339
5364
|
child.stdout.on("data", (b) => buffers.push(b));
|
|
5340
5365
|
child.on("error", cpErrorHandler(e));
|
|
5341
|
-
child.on("exit", (code) => code ? e(new Error("Not found")) : c({ path:
|
|
5366
|
+
child.on("exit", (code) => code ? e(new Error("Not found")) : c({ path: path10, version: parseVersion(Buffer.concat(buffers).toString("utf8").trim()) }));
|
|
5342
5367
|
});
|
|
5343
5368
|
}
|
|
5344
5369
|
function cpErrorHandler(cb) {
|
|
@@ -5355,9 +5380,9 @@ function findGitDarwin(onLookup) {
|
|
|
5355
5380
|
if (err) {
|
|
5356
5381
|
return e("git not found");
|
|
5357
5382
|
}
|
|
5358
|
-
const
|
|
5359
|
-
if (
|
|
5360
|
-
findSpecificGit(
|
|
5383
|
+
const path10 = gitPathBuffer.toString().replace(/^\s+|\s+$/g, "");
|
|
5384
|
+
if (path10 !== "/usr/bin/git") {
|
|
5385
|
+
findSpecificGit(path10, onLookup).then(c, e);
|
|
5361
5386
|
return;
|
|
5362
5387
|
}
|
|
5363
5388
|
(0, import_child_process.exec)("xcode-select -p", (err2) => {
|
|
@@ -5365,7 +5390,7 @@ function findGitDarwin(onLookup) {
|
|
|
5365
5390
|
e("git not found");
|
|
5366
5391
|
return;
|
|
5367
5392
|
}
|
|
5368
|
-
findSpecificGit(
|
|
5393
|
+
findSpecificGit(path10, onLookup).then(c, e);
|
|
5369
5394
|
});
|
|
5370
5395
|
});
|
|
5371
5396
|
});
|
|
@@ -5406,19 +5431,6 @@ var STATUS_MAP = {
|
|
|
5406
5431
|
"?": import_safe2.default.gray("?"),
|
|
5407
5432
|
"!": import_safe2.default.gray("!")
|
|
5408
5433
|
};
|
|
5409
|
-
function parseStatusEntries(output) {
|
|
5410
|
-
let result = [];
|
|
5411
|
-
let entries = output.split("\0");
|
|
5412
|
-
for (let i = 0; i < entries.length; i++) {
|
|
5413
|
-
let line = entries[i];
|
|
5414
|
-
if (!line) continue;
|
|
5415
|
-
result.push({ index: line[0], tree: line[1], relative: line.slice(3) });
|
|
5416
|
-
if (line[0] === "R" || line[0] === "C" || line[1] === "R" || line[1] === "C") {
|
|
5417
|
-
i++;
|
|
5418
|
-
}
|
|
5419
|
-
}
|
|
5420
|
-
return result;
|
|
5421
|
-
}
|
|
5422
5434
|
var GStatus = class extends import_coc6.BasicList {
|
|
5423
5435
|
constructor(nvim, manager) {
|
|
5424
5436
|
super();
|
|
@@ -6056,6 +6068,13 @@ var DocumentManager = class {
|
|
|
6056
6068
|
let buf = await this.buffer;
|
|
6057
6069
|
if (buf) await buf.showCommit();
|
|
6058
6070
|
}
|
|
6071
|
+
async getCurrentCommit() {
|
|
6072
|
+
let buf = await this.buffer;
|
|
6073
|
+
if (!buf) return void 0;
|
|
6074
|
+
let current = await buf.getCurrentCommit();
|
|
6075
|
+
if (!current) return void 0;
|
|
6076
|
+
return { sha: current.sha, root: buf.repo.root, line: current.line };
|
|
6077
|
+
}
|
|
6059
6078
|
async showBlameDoc() {
|
|
6060
6079
|
let buf = await this.buffer;
|
|
6061
6080
|
let line = await this.nvim.call("line", ".");
|
|
@@ -6119,8 +6138,10 @@ var DocumentManager = class {
|
|
|
6119
6138
|
import_coc10.window.showWarningMessage(`not belongs to git repository.`);
|
|
6120
6139
|
return null;
|
|
6121
6140
|
}
|
|
6122
|
-
|
|
6123
|
-
|
|
6141
|
+
return this.getDiffAllForRoot(root, category);
|
|
6142
|
+
}
|
|
6143
|
+
async getDiffAllForRoot(root, category) {
|
|
6144
|
+
return this.service.getRepoFromRoot(root).getDiffAll(category);
|
|
6124
6145
|
}
|
|
6125
6146
|
dispose() {
|
|
6126
6147
|
(0, import_coc10.disposeAll)(this.disposables);
|
|
@@ -6133,11 +6154,381 @@ var DocumentManager = class {
|
|
|
6133
6154
|
}
|
|
6134
6155
|
};
|
|
6135
6156
|
|
|
6157
|
+
// src/model/commitDocument.ts
|
|
6158
|
+
var import_coc11 = require("coc.nvim");
|
|
6159
|
+
|
|
6160
|
+
// src/model/commit.ts
|
|
6161
|
+
function parserError(kind, detail) {
|
|
6162
|
+
return new Error(`Invalid Git ${kind} output: ${detail}`);
|
|
6163
|
+
}
|
|
6164
|
+
function parseNameStatus(output) {
|
|
6165
|
+
if (!output) return [];
|
|
6166
|
+
const fields = output.endsWith("\0") ? output.slice(0, -1).split("\0") : output.split("\0");
|
|
6167
|
+
const result = [];
|
|
6168
|
+
let index = 0;
|
|
6169
|
+
while (index < fields.length) {
|
|
6170
|
+
const token = fields[index++];
|
|
6171
|
+
const match = token.match(/^([ACDMRTUXB])([0-9]+)?$/);
|
|
6172
|
+
if (!match) throw parserError("name-status", `invalid status token ${JSON.stringify(token)}`);
|
|
6173
|
+
const status = match[1];
|
|
6174
|
+
const scoreText = match[2];
|
|
6175
|
+
if ((status === "R" || status === "C") && !scoreText) {
|
|
6176
|
+
throw parserError("name-status", `missing similarity score for ${status}`);
|
|
6177
|
+
}
|
|
6178
|
+
if (scoreText && status !== "R" && status !== "C") {
|
|
6179
|
+
throw parserError("name-status", `score on ${status} record`);
|
|
6180
|
+
}
|
|
6181
|
+
const score = scoreText ? Number(scoreText) : void 0;
|
|
6182
|
+
if (score !== void 0 && (!Number.isSafeInteger(score) || score < 0 || score > 100)) {
|
|
6183
|
+
throw parserError("name-status", `invalid score ${scoreText}`);
|
|
6184
|
+
}
|
|
6185
|
+
if (status === "R" || status === "C") {
|
|
6186
|
+
const oldPath = fields[index++];
|
|
6187
|
+
const path10 = fields[index++];
|
|
6188
|
+
if (!oldPath || !path10) throw parserError("name-status", "missing rename/copy path");
|
|
6189
|
+
result.push({ status, score, oldPath, path: path10 });
|
|
6190
|
+
} else {
|
|
6191
|
+
const path10 = fields[index++];
|
|
6192
|
+
if (!path10) throw parserError("name-status", "missing path");
|
|
6193
|
+
result.push({ status, path: path10 });
|
|
6194
|
+
}
|
|
6195
|
+
}
|
|
6196
|
+
return result;
|
|
6197
|
+
}
|
|
6198
|
+
function parseNumstat(output) {
|
|
6199
|
+
if (!output) return [];
|
|
6200
|
+
const fields = output.endsWith("\0") ? output.slice(0, -1).split("\0") : output.split("\0");
|
|
6201
|
+
const result = [];
|
|
6202
|
+
let index = 0;
|
|
6203
|
+
while (index < fields.length) {
|
|
6204
|
+
const record = fields[index++];
|
|
6205
|
+
const firstTab = record.indexOf(" ");
|
|
6206
|
+
const secondTab = firstTab < 0 ? -1 : record.indexOf(" ", firstTab + 1);
|
|
6207
|
+
if (firstTab < 0 || secondTab < 0) {
|
|
6208
|
+
throw parserError("numstat", `missing tab separators in ${JSON.stringify(record)}`);
|
|
6209
|
+
}
|
|
6210
|
+
const additionsText = record.slice(0, firstTab);
|
|
6211
|
+
const deletionsText = record.slice(firstTab + 1, secondTab);
|
|
6212
|
+
const path10 = record.slice(secondTab + 1);
|
|
6213
|
+
const binary = additionsText === "-" || deletionsText === "-";
|
|
6214
|
+
if (binary && (additionsText !== "-" || deletionsText !== "-")) {
|
|
6215
|
+
throw parserError("numstat", "only binary records may contain -");
|
|
6216
|
+
}
|
|
6217
|
+
if (!binary && (!/^\d+$/.test(additionsText) || !/^\d+$/.test(deletionsText))) {
|
|
6218
|
+
throw parserError("numstat", `invalid line counts in ${JSON.stringify(record)}`);
|
|
6219
|
+
}
|
|
6220
|
+
if (path10) {
|
|
6221
|
+
result.push({
|
|
6222
|
+
path: path10,
|
|
6223
|
+
additions: binary ? void 0 : Number(additionsText),
|
|
6224
|
+
deletions: binary ? void 0 : Number(deletionsText),
|
|
6225
|
+
binary
|
|
6226
|
+
});
|
|
6227
|
+
continue;
|
|
6228
|
+
}
|
|
6229
|
+
const oldPath = fields[index++];
|
|
6230
|
+
const newPath = fields[index++];
|
|
6231
|
+
if (!oldPath || !newPath) throw parserError("numstat", "missing rename/copy path");
|
|
6232
|
+
result.push({
|
|
6233
|
+
oldPath,
|
|
6234
|
+
path: newPath,
|
|
6235
|
+
additions: binary ? void 0 : Number(additionsText),
|
|
6236
|
+
deletions: binary ? void 0 : Number(deletionsText),
|
|
6237
|
+
binary
|
|
6238
|
+
});
|
|
6239
|
+
}
|
|
6240
|
+
return result;
|
|
6241
|
+
}
|
|
6242
|
+
function mergeChanges(statusOutput, numstatOutput) {
|
|
6243
|
+
var _a, _b;
|
|
6244
|
+
const statuses = parseNameStatus(statusOutput);
|
|
6245
|
+
const stats = parseNumstat(numstatOutput);
|
|
6246
|
+
const statusMap = /* @__PURE__ */ new Map();
|
|
6247
|
+
for (const status of statuses) {
|
|
6248
|
+
const key = `${(_a = status.oldPath) != null ? _a : ""}\0${status.path}`;
|
|
6249
|
+
if (statusMap.has(key)) throw parserError("diff", `duplicate status key ${JSON.stringify(key)}`);
|
|
6250
|
+
statusMap.set(key, status);
|
|
6251
|
+
}
|
|
6252
|
+
const result = [];
|
|
6253
|
+
const statKeys = /* @__PURE__ */ new Set();
|
|
6254
|
+
for (const stat of stats) {
|
|
6255
|
+
const key = `${(_b = stat.oldPath) != null ? _b : ""}\0${stat.path}`;
|
|
6256
|
+
if (statKeys.has(key)) throw parserError("diff", `duplicate numstat key ${JSON.stringify(key)}`);
|
|
6257
|
+
statKeys.add(key);
|
|
6258
|
+
const status = statusMap.get(key);
|
|
6259
|
+
if (!status) throw parserError("diff", `numstat without name-status for ${JSON.stringify(key)}`);
|
|
6260
|
+
result.push({
|
|
6261
|
+
status: status.status,
|
|
6262
|
+
score: status.score,
|
|
6263
|
+
path: status.path,
|
|
6264
|
+
oldPath: status.oldPath,
|
|
6265
|
+
additions: stat.additions,
|
|
6266
|
+
deletions: stat.deletions,
|
|
6267
|
+
binary: stat.binary
|
|
6268
|
+
});
|
|
6269
|
+
statusMap.delete(key);
|
|
6270
|
+
}
|
|
6271
|
+
if (statusMap.size) {
|
|
6272
|
+
const key = statusMap.keys().next().value;
|
|
6273
|
+
throw parserError("diff", `name-status without numstat for ${JSON.stringify(key)}`);
|
|
6274
|
+
}
|
|
6275
|
+
return result;
|
|
6276
|
+
}
|
|
6277
|
+
function metadataFromOutput(output, revision) {
|
|
6278
|
+
const fields = output.split("\0");
|
|
6279
|
+
if (fields.length !== 6) {
|
|
6280
|
+
throw parserError("commit metadata", `expected 6 fields for ${JSON.stringify(revision)}`);
|
|
6281
|
+
}
|
|
6282
|
+
const [sha, shortSha, parentText, author, authoredAt, subject] = fields;
|
|
6283
|
+
if (!sha || !shortSha) throw parserError("commit metadata", `missing SHA for ${JSON.stringify(revision)}`);
|
|
6284
|
+
return {
|
|
6285
|
+
sha,
|
|
6286
|
+
shortSha,
|
|
6287
|
+
parents: parentText ? parentText.split(" ") : [],
|
|
6288
|
+
author,
|
|
6289
|
+
authoredAt,
|
|
6290
|
+
subject
|
|
6291
|
+
};
|
|
6292
|
+
}
|
|
6293
|
+
async function resolveCommit(git, root, revision, token) {
|
|
6294
|
+
const verified = await git.exec(root, ["rev-parse", "--verify", "--end-of-options", `${revision}^{commit}`], {
|
|
6295
|
+
cancellationToken: token
|
|
6296
|
+
});
|
|
6297
|
+
const sha = verified.stdout.trim();
|
|
6298
|
+
if (!sha) throw new Error(`Invalid Git commit: ${revision}`);
|
|
6299
|
+
const metadata = await git.exec(root, ["show", "-s", "--no-patch", "--format=%H%x00%h%x00%P%x00%an%x00%aI%x00%s", sha], {
|
|
6300
|
+
cancellationToken: token
|
|
6301
|
+
});
|
|
6302
|
+
return metadataFromOutput(metadata.stdout, revision);
|
|
6303
|
+
}
|
|
6304
|
+
function comparisonArgs(commitSha, baseSha, initial, kind) {
|
|
6305
|
+
if (initial) {
|
|
6306
|
+
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, "--"];
|
|
6307
|
+
}
|
|
6308
|
+
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, "--"];
|
|
6309
|
+
}
|
|
6310
|
+
async function runComparison(git, root, commit, baseSha, token) {
|
|
6311
|
+
const initial = !baseSha;
|
|
6312
|
+
const options = { cancellationToken: token };
|
|
6313
|
+
const [status, numstat] = await Promise.all([
|
|
6314
|
+
git.exec(root, comparisonArgs(commit.sha, baseSha, initial, "name-status"), options),
|
|
6315
|
+
git.exec(root, comparisonArgs(commit.sha, baseSha, initial, "numstat"), options)
|
|
6316
|
+
]);
|
|
6317
|
+
return mergeChanges(status.stdout, numstat.stdout);
|
|
6318
|
+
}
|
|
6319
|
+
async function loadComparisonForCommit(git, root, commit, parentIndex = 0, token) {
|
|
6320
|
+
let baseSha;
|
|
6321
|
+
if (commit.parents.length) {
|
|
6322
|
+
if (!Number.isInteger(parentIndex) || parentIndex < 0 || parentIndex >= commit.parents.length) {
|
|
6323
|
+
throw new Error(`Invalid parent index ${parentIndex} for ${commit.shortSha}`);
|
|
6324
|
+
}
|
|
6325
|
+
baseSha = commit.parents[parentIndex];
|
|
6326
|
+
}
|
|
6327
|
+
const changes = await runComparison(git, root, commit, baseSha, token);
|
|
6328
|
+
return {
|
|
6329
|
+
commit,
|
|
6330
|
+
baseSha,
|
|
6331
|
+
parentIndex: baseSha ? parentIndex : void 0,
|
|
6332
|
+
changes
|
|
6333
|
+
};
|
|
6334
|
+
}
|
|
6335
|
+
async function assertParentAvailable(git, root, parentSha, token) {
|
|
6336
|
+
await git.exec(root, ["cat-file", "-e", `${parentSha}^{commit}`], { cancellationToken: token });
|
|
6337
|
+
}
|
|
6338
|
+
function patchArgs(comparison, change) {
|
|
6339
|
+
const paths = change.oldPath ? [change.oldPath, change.path] : [change.path];
|
|
6340
|
+
if (comparison.baseSha) {
|
|
6341
|
+
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];
|
|
6342
|
+
}
|
|
6343
|
+
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];
|
|
6344
|
+
}
|
|
6345
|
+
|
|
6346
|
+
// src/model/commitDocument.ts
|
|
6347
|
+
var COMMIT_DOCUMENT_SCHEME = "coc-git";
|
|
6348
|
+
function count(value) {
|
|
6349
|
+
return value === void 0 ? 1 : Number(value);
|
|
6350
|
+
}
|
|
6351
|
+
function contentLineCount(content) {
|
|
6352
|
+
return content ? content.split("\n").length : 1;
|
|
6353
|
+
}
|
|
6354
|
+
function parseCommitDocumentPatch(output) {
|
|
6355
|
+
const hunks = [];
|
|
6356
|
+
let current;
|
|
6357
|
+
for (const line of output.split(/\r?\n/)) {
|
|
6358
|
+
const match = line.match(/^@@ -(\d+)(?:,(\d+))? \+(\d+)(?:,(\d+))? @@/);
|
|
6359
|
+
if (match) {
|
|
6360
|
+
const addedStart = Number(match[3]);
|
|
6361
|
+
const addedCount = count(match[4]);
|
|
6362
|
+
const start = Math.max(1, addedStart);
|
|
6363
|
+
current = {
|
|
6364
|
+
start,
|
|
6365
|
+
end: addedCount > 0 ? addedStart + addedCount - 1 : start,
|
|
6366
|
+
addedStart,
|
|
6367
|
+
addedCount,
|
|
6368
|
+
deleted: [],
|
|
6369
|
+
deletedLine: addedCount > 0 || addedStart === 0 ? Math.max(0, addedStart - 1) : addedStart - 1,
|
|
6370
|
+
deletedAlign: addedCount > 0 || addedStart === 0 ? "above" : "below"
|
|
6371
|
+
};
|
|
6372
|
+
hunks.push(current);
|
|
6373
|
+
continue;
|
|
6374
|
+
}
|
|
6375
|
+
if (!current || line.startsWith("\")) continue;
|
|
6376
|
+
if (line.startsWith("-")) current.deleted.push(line.slice(1));
|
|
6377
|
+
}
|
|
6378
|
+
return hunks;
|
|
6379
|
+
}
|
|
6380
|
+
function patchArguments(comparison, change) {
|
|
6381
|
+
const args = patchArgs(comparison, change);
|
|
6382
|
+
const separator = args.indexOf("--");
|
|
6383
|
+
args.splice(separator, 0, "--unified=0");
|
|
6384
|
+
return args;
|
|
6385
|
+
}
|
|
6386
|
+
function commitUri(comparison, relativePath) {
|
|
6387
|
+
return revisionUri(comparison.commit.sha, relativePath);
|
|
6388
|
+
}
|
|
6389
|
+
function revisionUri(revision, relativePath) {
|
|
6390
|
+
return import_coc11.Uri.from({
|
|
6391
|
+
scheme: COMMIT_DOCUMENT_SCHEME,
|
|
6392
|
+
authority: revision,
|
|
6393
|
+
path: `/${relativePath}`
|
|
6394
|
+
});
|
|
6395
|
+
}
|
|
6396
|
+
var CommitDocumentProvider = class {
|
|
6397
|
+
constructor(git, virtualTextSrcId) {
|
|
6398
|
+
this.git = git;
|
|
6399
|
+
this.virtualTextSrcId = virtualTextSrcId;
|
|
6400
|
+
this.resources = /* @__PURE__ */ new Map();
|
|
6401
|
+
this.disposables = [];
|
|
6402
|
+
import_coc11.workspace.onDidCloseTextDocument((document) => {
|
|
6403
|
+
if (import_coc11.Uri.parse(document.uri).scheme === COMMIT_DOCUMENT_SCHEME) this.resources.delete(document.uri);
|
|
6404
|
+
}, null, this.disposables);
|
|
6405
|
+
}
|
|
6406
|
+
async provideTextDocumentContent(uri, token) {
|
|
6407
|
+
var _a;
|
|
6408
|
+
const resource = this.resources.get(uri.toString());
|
|
6409
|
+
if (!resource) throw new Error(`Unknown coc-git commit document: ${uri.toString()}`);
|
|
6410
|
+
await this.load(resource, token);
|
|
6411
|
+
import_coc11.workspace.nvim.pauseNotification();
|
|
6412
|
+
import_coc11.workspace.nvim.command("setlocal buftype=nofile bufhidden=wipe noswapfile readonly", true);
|
|
6413
|
+
import_coc11.workspace.nvim.command("filetype detect", true);
|
|
6414
|
+
import_coc11.workspace.nvim.resumeNotification(true);
|
|
6415
|
+
return (_a = resource.content) != null ? _a : "";
|
|
6416
|
+
}
|
|
6417
|
+
async open(root, comparison, change, targetWinId, line) {
|
|
6418
|
+
const uri = commitUri(comparison, change.path);
|
|
6419
|
+
const resource = { kind: "comparison", uri, root, comparison, change };
|
|
6420
|
+
await this.openResource(resource, targetWinId, line);
|
|
6421
|
+
}
|
|
6422
|
+
async openRevision(root, revision, relativePath, targetWinId, line) {
|
|
6423
|
+
const result = await this.git.exec(root, ["rev-parse", "--verify", "--end-of-options", `${revision}^{commit}`]);
|
|
6424
|
+
const sha = result.stdout.trim();
|
|
6425
|
+
if (!sha) throw new Error(`Invalid Git revision: ${revision}`);
|
|
6426
|
+
const object = `${sha}:${relativePath}`;
|
|
6427
|
+
const type = (await this.git.exec(root, ["cat-file", "-t", object])).stdout.trim();
|
|
6428
|
+
if (type !== "blob") throw new Error(`Git path is not a file: ${relativePath}`);
|
|
6429
|
+
const resource = {
|
|
6430
|
+
kind: "revision",
|
|
6431
|
+
uri: revisionUri(sha, relativePath),
|
|
6432
|
+
root,
|
|
6433
|
+
revision: sha,
|
|
6434
|
+
relativePath
|
|
6435
|
+
};
|
|
6436
|
+
await this.openResource(resource, targetWinId, line);
|
|
6437
|
+
}
|
|
6438
|
+
async openResource(resource, targetWinId, line) {
|
|
6439
|
+
const { uri } = resource;
|
|
6440
|
+
this.resources.set(uri.toString(), resource);
|
|
6441
|
+
const moved = await import_coc11.workspace.nvim.call("win_gotoid", [targetWinId]);
|
|
6442
|
+
if (!moved) await import_coc11.workspace.nvim.command("new");
|
|
6443
|
+
await import_coc11.workspace.openResource(uri.toString());
|
|
6444
|
+
const document = import_coc11.workspace.getDocument(uri.toString());
|
|
6445
|
+
if (document) {
|
|
6446
|
+
await this.load(resource);
|
|
6447
|
+
await this.finalizeDocument(document, resource);
|
|
6448
|
+
if (line != null) await import_coc11.workspace.nvim.call("cursor", [Math.max(1, Math.min(line, contentLineCount(resource.content))), 1]);
|
|
6449
|
+
}
|
|
6450
|
+
}
|
|
6451
|
+
async nextChunk() {
|
|
6452
|
+
return await this.navigate(true);
|
|
6453
|
+
}
|
|
6454
|
+
async prevChunk() {
|
|
6455
|
+
return await this.navigate(false);
|
|
6456
|
+
}
|
|
6457
|
+
async load(resource, token) {
|
|
6458
|
+
if (resource.content !== void 0 && resource.hunks) return;
|
|
6459
|
+
const options = token ? { cancellationToken: token } : void 0;
|
|
6460
|
+
if (resource.kind === "revision") {
|
|
6461
|
+
const object2 = `${resource.revision}:${resource.relativePath}`;
|
|
6462
|
+
const content2 = await this.git.exec(resource.root, ["cat-file", "-p", object2], options);
|
|
6463
|
+
if (token == null ? void 0 : token.isCancellationRequested) return;
|
|
6464
|
+
resource.content = content2.stdout.replace(/\r?\n$/, "");
|
|
6465
|
+
resource.hunks = [];
|
|
6466
|
+
return;
|
|
6467
|
+
}
|
|
6468
|
+
const object = `${resource.comparison.commit.sha}:${resource.change.path}`;
|
|
6469
|
+
const [content, patch] = await Promise.all([
|
|
6470
|
+
this.git.exec(resource.root, ["cat-file", "-p", object], options),
|
|
6471
|
+
this.git.exec(resource.root, patchArguments(resource.comparison, resource.change), options)
|
|
6472
|
+
]);
|
|
6473
|
+
if (token == null ? void 0 : token.isCancellationRequested) return;
|
|
6474
|
+
resource.content = content.stdout.replace(/\r?\n$/, "");
|
|
6475
|
+
resource.hunks = parseCommitDocumentPatch(patch.stdout);
|
|
6476
|
+
}
|
|
6477
|
+
async finalizeDocument(document, resource) {
|
|
6478
|
+
var _a;
|
|
6479
|
+
await this.load(resource);
|
|
6480
|
+
const buffer = document.buffer;
|
|
6481
|
+
await buffer.setOption("modifiable", false);
|
|
6482
|
+
this.decorate(buffer, (_a = resource.hunks) != null ? _a : []);
|
|
6483
|
+
}
|
|
6484
|
+
decorate(buffer, hunks) {
|
|
6485
|
+
buffer.clearNamespace(this.virtualTextSrcId);
|
|
6486
|
+
const highlights = [];
|
|
6487
|
+
for (const hunk of hunks) {
|
|
6488
|
+
for (let line = hunk.addedStart; line < hunk.addedStart + hunk.addedCount; line++) {
|
|
6489
|
+
highlights.push({ hlGroup: "CocGitCommitAdd", lnum: line - 1, colStart: 0, colEnd: -1 });
|
|
6490
|
+
}
|
|
6491
|
+
for (const deleted of hunk.deleted) {
|
|
6492
|
+
buffer.setVirtualText(this.virtualTextSrcId, hunk.deletedLine, [[deleted || " ", "CocGitCommitDelete"]], {
|
|
6493
|
+
text_align: hunk.deletedAlign,
|
|
6494
|
+
hl_mode: "replace"
|
|
6495
|
+
});
|
|
6496
|
+
}
|
|
6497
|
+
}
|
|
6498
|
+
buffer.updateHighlights("coc-git-commit-add", highlights, { priority: 4096 });
|
|
6499
|
+
}
|
|
6500
|
+
async navigate(forward) {
|
|
6501
|
+
var _a;
|
|
6502
|
+
const bufnr = await import_coc11.workspace.nvim.call("bufnr", ["%"]);
|
|
6503
|
+
const document = import_coc11.workspace.getDocument(bufnr);
|
|
6504
|
+
if (!document || import_coc11.Uri.parse(document.uri).scheme !== COMMIT_DOCUMENT_SCHEME) return false;
|
|
6505
|
+
const resource = this.resources.get(document.uri);
|
|
6506
|
+
if (!resource) return true;
|
|
6507
|
+
await this.load(resource);
|
|
6508
|
+
const hunks = (_a = resource.hunks) != null ? _a : [];
|
|
6509
|
+
if (!hunks.length) return true;
|
|
6510
|
+
const line = await import_coc11.workspace.nvim.call("line", ["."]);
|
|
6511
|
+
const ordered = forward ? hunks : hunks.slice().reverse();
|
|
6512
|
+
const target = ordered.find((hunk) => forward ? hunk.start > line : hunk.end < line);
|
|
6513
|
+
if (target) {
|
|
6514
|
+
await import_coc11.window.moveTo({ line: target.start - 1, character: 0 });
|
|
6515
|
+
} else if (await import_coc11.workspace.nvim.getOption("wrapscan")) {
|
|
6516
|
+
const wrapped = forward ? hunks[0] : hunks[hunks.length - 1];
|
|
6517
|
+
await import_coc11.window.moveTo({ line: wrapped.start - 1, character: 0 });
|
|
6518
|
+
}
|
|
6519
|
+
return true;
|
|
6520
|
+
}
|
|
6521
|
+
dispose() {
|
|
6522
|
+
(0, import_coc11.disposeAll)(this.disposables);
|
|
6523
|
+
this.resources.clear();
|
|
6524
|
+
}
|
|
6525
|
+
};
|
|
6526
|
+
|
|
6136
6527
|
// src/model/service.ts
|
|
6137
|
-
var
|
|
6528
|
+
var import_coc15 = require("coc.nvim");
|
|
6138
6529
|
|
|
6139
6530
|
// src/model/buffer.ts
|
|
6140
|
-
var
|
|
6531
|
+
var import_coc12 = require("coc.nvim");
|
|
6141
6532
|
var import_debounce2 = __toESM(require_debounce());
|
|
6142
6533
|
|
|
6143
6534
|
// node_modules/timeago.js/esm/lang/en_US.js
|
|
@@ -6875,7 +7266,7 @@ var GitBuffer = class {
|
|
|
6875
7266
|
this.gitStatus = "";
|
|
6876
7267
|
this.foldEnabled = false;
|
|
6877
7268
|
this._disposed = false;
|
|
6878
|
-
this.mutex = new
|
|
7269
|
+
this.mutex = new import_coc12.Mutex();
|
|
6879
7270
|
this.conflictCheckNeeded = hasConflicts;
|
|
6880
7271
|
this.refresh = (0, import_debounce2.default)(() => {
|
|
6881
7272
|
this._refresh().catch((e) => {
|
|
@@ -6926,7 +7317,7 @@ var GitBuffer = class {
|
|
|
6926
7317
|
});
|
|
6927
7318
|
}
|
|
6928
7319
|
async chunkUndo() {
|
|
6929
|
-
let line = await
|
|
7320
|
+
let line = await import_coc12.workspace.nvim.call("line", ".");
|
|
6930
7321
|
let diff = this.getChunk(line);
|
|
6931
7322
|
if (!diff) return;
|
|
6932
7323
|
let { start, lines, changeType } = diff;
|
|
@@ -6945,10 +7336,10 @@ var GitBuffer = class {
|
|
|
6945
7336
|
}
|
|
6946
7337
|
async chunkStage() {
|
|
6947
7338
|
let relpath = toUnixSlash(this.relpath);
|
|
6948
|
-
let line = await
|
|
7339
|
+
let line = await import_coc12.workspace.nvim.call("line", ".");
|
|
6949
7340
|
let diff = this.getChunk(line);
|
|
6950
7341
|
if (!diff) {
|
|
6951
|
-
|
|
7342
|
+
import_coc12.window.showErrorMessage("Not positioned in git chunk");
|
|
6952
7343
|
return;
|
|
6953
7344
|
}
|
|
6954
7345
|
let head;
|
|
@@ -6980,7 +7371,7 @@ var GitBuffer = class {
|
|
|
6980
7371
|
}
|
|
6981
7372
|
async chunkUnstage() {
|
|
6982
7373
|
var _a;
|
|
6983
|
-
let { nvim } =
|
|
7374
|
+
let { nvim } = import_coc12.workspace;
|
|
6984
7375
|
const { diffs } = this;
|
|
6985
7376
|
let line = await nvim.call("line", ".");
|
|
6986
7377
|
let adjust = 0;
|
|
@@ -6988,7 +7379,7 @@ var GitBuffer = class {
|
|
|
6988
7379
|
for (let diff of diffs) {
|
|
6989
7380
|
if (diff.end >= line) {
|
|
6990
7381
|
if (diff.start <= line && diff.changeType != "delete" /* Delete */) {
|
|
6991
|
-
|
|
7382
|
+
import_coc12.window.showErrorMessage(`Current line contains unstaged change.`);
|
|
6992
7383
|
invalid = true;
|
|
6993
7384
|
}
|
|
6994
7385
|
break;
|
|
@@ -7001,12 +7392,12 @@ var GitBuffer = class {
|
|
|
7001
7392
|
let stagedDiff = await this.repo.getStagedChunks(this.relpath);
|
|
7002
7393
|
let chunks = (_a = Object.values(stagedDiff)[0]) != null ? _a : [];
|
|
7003
7394
|
if (!chunks.length) {
|
|
7004
|
-
|
|
7395
|
+
import_coc12.window.showErrorMessage(`Staged chunk not found`);
|
|
7005
7396
|
return;
|
|
7006
7397
|
}
|
|
7007
7398
|
let chunk = chunks.find((o) => chunkContainsLine(o, line));
|
|
7008
7399
|
if (!chunk) {
|
|
7009
|
-
|
|
7400
|
+
import_coc12.window.showErrorMessage(`Unable to find staged chunk on current line`);
|
|
7010
7401
|
return;
|
|
7011
7402
|
}
|
|
7012
7403
|
this.channel.appendLine(`[Info] resolved chunk ${JSON.stringify(chunk, null, 2)}`);
|
|
@@ -7017,7 +7408,7 @@ var GitBuffer = class {
|
|
|
7017
7408
|
this.invalidateStagedCache();
|
|
7018
7409
|
this.refresh();
|
|
7019
7410
|
} catch (e) {
|
|
7020
|
-
|
|
7411
|
+
import_coc12.window.showErrorMessage(`Unable to apply patch: ${e.message}`);
|
|
7021
7412
|
this.channel.appendLine(`[Error] ${e.message}`);
|
|
7022
7413
|
}
|
|
7023
7414
|
}
|
|
@@ -7027,17 +7418,17 @@ var GitBuffer = class {
|
|
|
7027
7418
|
return;
|
|
7028
7419
|
}
|
|
7029
7420
|
const { diffs } = this;
|
|
7030
|
-
let { nvim } =
|
|
7421
|
+
let { nvim } = import_coc12.workspace;
|
|
7031
7422
|
if (!diffs || diffs.length == 0) return;
|
|
7032
7423
|
let line = await nvim.call("line", ".");
|
|
7033
7424
|
for (let diff of diffs) {
|
|
7034
7425
|
if (diff.start > line) {
|
|
7035
|
-
await
|
|
7426
|
+
await import_coc12.window.moveTo({ line: Math.max(diff.start - 1, 0), character: 0 });
|
|
7036
7427
|
return;
|
|
7037
7428
|
}
|
|
7038
7429
|
}
|
|
7039
7430
|
if (await nvim.getOption("wrapscan")) {
|
|
7040
|
-
await
|
|
7431
|
+
await import_coc12.window.moveTo({ line: Math.max(diffs[0].start - 1, 0), character: 0 });
|
|
7041
7432
|
}
|
|
7042
7433
|
}
|
|
7043
7434
|
async prevChunk() {
|
|
@@ -7045,18 +7436,18 @@ var GitBuffer = class {
|
|
|
7045
7436
|
await this.moveToPreviousChunk();
|
|
7046
7437
|
return;
|
|
7047
7438
|
}
|
|
7048
|
-
const { nvim } =
|
|
7439
|
+
const { nvim } = import_coc12.workspace;
|
|
7049
7440
|
let { diffs } = this;
|
|
7050
7441
|
let line = await nvim.call("line", ".");
|
|
7051
7442
|
if (!diffs || diffs.length == 0) return;
|
|
7052
7443
|
for (let diff of diffs.slice().reverse()) {
|
|
7053
7444
|
if (diff.end < line) {
|
|
7054
|
-
await
|
|
7445
|
+
await import_coc12.window.moveTo({ line: Math.max(diff.start - 1, 0), character: 0 });
|
|
7055
7446
|
return;
|
|
7056
7447
|
}
|
|
7057
7448
|
}
|
|
7058
7449
|
if (await nvim.getOption("wrapscan")) {
|
|
7059
|
-
await
|
|
7450
|
+
await import_coc12.window.moveTo({ line: Math.max(diffs[diffs.length - 1].start - 1, 0), character: 0 });
|
|
7060
7451
|
}
|
|
7061
7452
|
}
|
|
7062
7453
|
getNavigationChunks() {
|
|
@@ -7086,36 +7477,36 @@ var GitBuffer = class {
|
|
|
7086
7477
|
}
|
|
7087
7478
|
async moveToNextChunk() {
|
|
7088
7479
|
const chunks = this.getNavigationChunks();
|
|
7089
|
-
const { nvim } =
|
|
7480
|
+
const { nvim } = import_coc12.workspace;
|
|
7090
7481
|
if (chunks.length === 0) return;
|
|
7091
7482
|
const line = await nvim.call("line", ".");
|
|
7092
7483
|
for (const chunk of chunks) {
|
|
7093
7484
|
if (chunk.start > line) {
|
|
7094
|
-
await
|
|
7485
|
+
await import_coc12.window.moveTo({ line: Math.max(chunk.start - 1, 0), character: 0 });
|
|
7095
7486
|
return;
|
|
7096
7487
|
}
|
|
7097
7488
|
}
|
|
7098
7489
|
if (await nvim.getOption("wrapscan")) {
|
|
7099
|
-
await
|
|
7490
|
+
await import_coc12.window.moveTo({ line: Math.max(chunks[0].start - 1, 0), character: 0 });
|
|
7100
7491
|
}
|
|
7101
7492
|
}
|
|
7102
7493
|
async moveToPreviousChunk() {
|
|
7103
7494
|
const chunks = this.getNavigationChunks();
|
|
7104
|
-
const { nvim } =
|
|
7495
|
+
const { nvim } = import_coc12.workspace;
|
|
7105
7496
|
if (chunks.length === 0) return;
|
|
7106
7497
|
const line = await nvim.call("line", ".");
|
|
7107
7498
|
for (const chunk of chunks.slice().reverse()) {
|
|
7108
7499
|
if (chunk.end < line) {
|
|
7109
|
-
await
|
|
7500
|
+
await import_coc12.window.moveTo({ line: Math.max(chunk.start - 1, 0), character: 0 });
|
|
7110
7501
|
return;
|
|
7111
7502
|
}
|
|
7112
7503
|
}
|
|
7113
7504
|
if (await nvim.getOption("wrapscan")) {
|
|
7114
|
-
await
|
|
7505
|
+
await import_coc12.window.moveTo({ line: Math.max(chunks[chunks.length - 1].start - 1, 0), character: 0 });
|
|
7115
7506
|
}
|
|
7116
7507
|
}
|
|
7117
7508
|
async chunkInfo() {
|
|
7118
|
-
let line = await
|
|
7509
|
+
let line = await import_coc12.workspace.nvim.call("line", ".");
|
|
7119
7510
|
let diff = this.getChunk(line);
|
|
7120
7511
|
if (diff) {
|
|
7121
7512
|
let content = diff.head + "\n" + diff.lines.join("\n");
|
|
@@ -7150,7 +7541,7 @@ var GitBuffer = class {
|
|
|
7150
7541
|
}
|
|
7151
7542
|
async showBlameInfo(lnum) {
|
|
7152
7543
|
if (this._disposed) return;
|
|
7153
|
-
let { nvim } =
|
|
7544
|
+
let { nvim } = import_coc12.workspace;
|
|
7154
7545
|
let { virtualTextSrcId, addGBlameToBufferVar, addGBlameToVirtualText } = this.config;
|
|
7155
7546
|
if (!this.showBlame) return;
|
|
7156
7547
|
let infos = this.blameInfo;
|
|
@@ -7189,9 +7580,9 @@ var GitBuffer = class {
|
|
|
7189
7580
|
async showBlameDoc(lnum) {
|
|
7190
7581
|
let indexed = await this.repo.isIndexed(this.relpath);
|
|
7191
7582
|
if (!indexed) {
|
|
7192
|
-
|
|
7583
|
+
import_coc12.window.showWarningMessage("File not indexed");
|
|
7193
7584
|
} else if (await this.repo.isShallow()) {
|
|
7194
|
-
|
|
7585
|
+
import_coc12.window.showWarningMessage("Shallow repository, blame not available");
|
|
7195
7586
|
} else {
|
|
7196
7587
|
let infos = await this.getBlameInfo([lnum, lnum]);
|
|
7197
7588
|
let info = infos.find((o) => lnum >= o.startLnum && lnum <= o.endLnum);
|
|
@@ -7202,12 +7593,12 @@ var GitBuffer = class {
|
|
|
7202
7593
|
blameText.push(`${info.sha.substring(0, 7)}`);
|
|
7203
7594
|
await this.showDoc(blameText.join("\n\n"), "text");
|
|
7204
7595
|
} else {
|
|
7205
|
-
|
|
7596
|
+
import_coc12.window.showWarningMessage("Not committed yet");
|
|
7206
7597
|
}
|
|
7207
7598
|
}
|
|
7208
7599
|
}
|
|
7209
7600
|
async diffDocument(force = false) {
|
|
7210
|
-
let { nvim } =
|
|
7601
|
+
let { nvim } = import_coc12.workspace;
|
|
7211
7602
|
let revision = this.config.diffRevision;
|
|
7212
7603
|
const { bufnr } = this.doc;
|
|
7213
7604
|
let content = this.doc.content;
|
|
@@ -7290,7 +7681,7 @@ var GitBuffer = class {
|
|
|
7290
7681
|
updateGutters() {
|
|
7291
7682
|
if (this._disposed) return;
|
|
7292
7683
|
if (!this.config.enableGutters) return;
|
|
7293
|
-
let { nvim } =
|
|
7684
|
+
let { nvim } = import_coc12.workspace;
|
|
7294
7685
|
let { bufnr } = this.doc;
|
|
7295
7686
|
let { signPriority, stagedSignPriority } = this.config;
|
|
7296
7687
|
let signs = this.currentSigns;
|
|
@@ -7371,10 +7762,10 @@ var GitBuffer = class {
|
|
|
7371
7762
|
async diffCached() {
|
|
7372
7763
|
let res = await this.repo.safeRun(["diff", "--cached"]);
|
|
7373
7764
|
if (!res.trim()) {
|
|
7374
|
-
|
|
7765
|
+
import_coc12.window.showWarningMessage("Empty diff");
|
|
7375
7766
|
return;
|
|
7376
7767
|
}
|
|
7377
|
-
let { nvim } =
|
|
7768
|
+
let { nvim } = import_coc12.workspace;
|
|
7378
7769
|
nvim.pauseNotification();
|
|
7379
7770
|
nvim.command(`keepalt above new +setl\\ previewwindow`, true);
|
|
7380
7771
|
nvim.call("append", [0, res.split(/\r?\n/)], true);
|
|
@@ -7385,44 +7776,44 @@ var GitBuffer = class {
|
|
|
7385
7776
|
await nvim.resumeNotification();
|
|
7386
7777
|
}
|
|
7387
7778
|
async nextConflict() {
|
|
7388
|
-
let { nvim } =
|
|
7779
|
+
let { nvim } = import_coc12.workspace;
|
|
7389
7780
|
if (!this.conflicts.length) {
|
|
7390
|
-
|
|
7781
|
+
import_coc12.window.showWarningMessage("No conflicts detected");
|
|
7391
7782
|
return;
|
|
7392
7783
|
}
|
|
7393
7784
|
let line = await nvim.call("line", ".");
|
|
7394
7785
|
for (let conflict of this.conflicts) {
|
|
7395
7786
|
if (conflict.start > line) {
|
|
7396
|
-
await
|
|
7787
|
+
await import_coc12.window.moveTo({ line: Math.max(conflict.start - 1, 0), character: 0 });
|
|
7397
7788
|
return;
|
|
7398
7789
|
}
|
|
7399
7790
|
}
|
|
7400
7791
|
if (await nvim.getOption("wrapscan")) {
|
|
7401
|
-
await
|
|
7792
|
+
await import_coc12.window.moveTo({ line: Math.max(this.conflicts[0].start - 1, 0), character: 0 });
|
|
7402
7793
|
}
|
|
7403
7794
|
}
|
|
7404
7795
|
async prevConflict() {
|
|
7405
|
-
let { nvim } =
|
|
7796
|
+
let { nvim } = import_coc12.workspace;
|
|
7406
7797
|
if (!this.conflicts.length) {
|
|
7407
|
-
|
|
7798
|
+
import_coc12.window.showWarningMessage("No conflicts detected", "warning");
|
|
7408
7799
|
return;
|
|
7409
7800
|
}
|
|
7410
7801
|
let line = await nvim.call("line", ".");
|
|
7411
7802
|
let conflict = getPreviousConflict(this.conflicts, line);
|
|
7412
7803
|
if (conflict) {
|
|
7413
|
-
await
|
|
7804
|
+
await import_coc12.window.moveTo({ line: Math.max(conflict.start - 1, 0), character: 0 });
|
|
7414
7805
|
return;
|
|
7415
7806
|
}
|
|
7416
7807
|
if (await nvim.getOption("wrapscan")) {
|
|
7417
7808
|
conflict = this.conflicts[this.conflicts.length - 1];
|
|
7418
|
-
await
|
|
7809
|
+
await import_coc12.window.moveTo({ line: Math.max(conflict.start - 1, 0), character: 0 });
|
|
7419
7810
|
}
|
|
7420
7811
|
}
|
|
7421
7812
|
async conflictKeepPart(part) {
|
|
7422
|
-
const { nvim } =
|
|
7813
|
+
const { nvim } = import_coc12.workspace;
|
|
7423
7814
|
let conflicts = this.conflicts;
|
|
7424
7815
|
if (!conflicts || conflicts.length == 0) {
|
|
7425
|
-
|
|
7816
|
+
import_coc12.window.showWarningMessage("No conflicts detected");
|
|
7426
7817
|
return;
|
|
7427
7818
|
}
|
|
7428
7819
|
let line = await nvim.call("line", ".");
|
|
@@ -7446,11 +7837,11 @@ var GitBuffer = class {
|
|
|
7446
7837
|
}
|
|
7447
7838
|
}
|
|
7448
7839
|
}
|
|
7449
|
-
|
|
7840
|
+
import_coc12.window.showWarningMessage("Not positioned on a conflict");
|
|
7450
7841
|
}
|
|
7451
7842
|
async browser(action = "open", range, permalink = false) {
|
|
7452
|
-
let { nvim } =
|
|
7453
|
-
let config =
|
|
7843
|
+
let { nvim } = import_coc12.workspace;
|
|
7844
|
+
let config = import_coc12.workspace.getConfiguration("git");
|
|
7454
7845
|
let head = (await this.repo.safeRun(["rev-parse", "HEAD"])).trim();
|
|
7455
7846
|
let branch = config.get("browserBranchName", "").trim();
|
|
7456
7847
|
if (!branch.length) {
|
|
@@ -7469,7 +7860,7 @@ var GitBuffer = class {
|
|
|
7469
7860
|
}
|
|
7470
7861
|
let output = await this.repo.safeRun(["remote"]);
|
|
7471
7862
|
if (!output.trim()) {
|
|
7472
|
-
|
|
7863
|
+
import_coc12.window.showWarningMessage(`No remote found`);
|
|
7473
7864
|
return;
|
|
7474
7865
|
}
|
|
7475
7866
|
let names = output.trim().split(/\r?\n/);
|
|
@@ -7478,7 +7869,7 @@ var GitBuffer = class {
|
|
|
7478
7869
|
if (names.includes(browserRemoteName)) {
|
|
7479
7870
|
names = [browserRemoteName];
|
|
7480
7871
|
} else {
|
|
7481
|
-
|
|
7872
|
+
import_coc12.window.showWarningMessage("Configured git.browserRemoteName missing from remote list");
|
|
7482
7873
|
return;
|
|
7483
7874
|
}
|
|
7484
7875
|
}
|
|
@@ -7505,46 +7896,52 @@ var GitBuffer = class {
|
|
|
7505
7896
|
}
|
|
7506
7897
|
if (urls.length == 1) {
|
|
7507
7898
|
if (action == "open") {
|
|
7508
|
-
await
|
|
7899
|
+
await import_coc12.workspace.openResource(urls[0]);
|
|
7509
7900
|
} else {
|
|
7510
7901
|
nvim.call("setreg", ["+", urls[0]], true);
|
|
7511
|
-
|
|
7902
|
+
import_coc12.window.showInformationMessage("Copied url to clipboard");
|
|
7512
7903
|
}
|
|
7513
7904
|
} else if (urls.length > 1) {
|
|
7514
|
-
let url = await
|
|
7905
|
+
let url = await import_coc12.window.showQuickPick(urls, { canPickMany: false, title: "Pick remote url" });
|
|
7515
7906
|
if (url) {
|
|
7516
7907
|
if (action == "open") {
|
|
7517
|
-
await
|
|
7908
|
+
await import_coc12.workspace.openResource(url);
|
|
7518
7909
|
} else {
|
|
7519
7910
|
nvim.call("setreg", ["+", url], true);
|
|
7520
7911
|
nvim.call("setreg", ["*", url], true);
|
|
7521
|
-
|
|
7912
|
+
import_coc12.window.showInformationMessage("Copied url to clipboard");
|
|
7522
7913
|
}
|
|
7523
7914
|
}
|
|
7524
7915
|
}
|
|
7525
7916
|
}
|
|
7526
|
-
|
|
7527
|
-
async showCommit(useFloating = false) {
|
|
7528
|
-
var _a;
|
|
7917
|
+
async getCurrentCommit() {
|
|
7529
7918
|
let indexed = await this.repo.isIndexed(this.relpath);
|
|
7530
7919
|
if (!indexed) {
|
|
7531
|
-
|
|
7532
|
-
return;
|
|
7920
|
+
import_coc12.window.showWarningMessage(`"${this.relpath}" not indexed.`);
|
|
7921
|
+
return void 0;
|
|
7533
7922
|
}
|
|
7534
|
-
let nvim =
|
|
7923
|
+
let nvim = import_coc12.workspace.nvim;
|
|
7535
7924
|
let line = await nvim.eval('line(".")');
|
|
7536
7925
|
let args = ["--no-pager", "blame", "-w", "--porcelain", "--root", `-L${line},${line}`, "--", this.relpath];
|
|
7537
7926
|
let res = await this.repo.exec(args);
|
|
7538
7927
|
let output = res.stdout.trim();
|
|
7539
|
-
if (!output.length) return;
|
|
7928
|
+
if (!output.length) return void 0;
|
|
7540
7929
|
let match = output.match(/^(\S+)\s+(\d+)/);
|
|
7541
|
-
if (!match) return;
|
|
7930
|
+
if (!match) return void 0;
|
|
7542
7931
|
let commit = match[1];
|
|
7543
|
-
let commitLine = Number(match[2]);
|
|
7544
7932
|
if (/^0+$/.test(commit)) {
|
|
7545
|
-
|
|
7546
|
-
return;
|
|
7933
|
+
import_coc12.window.showWarningMessage("not committed yet!");
|
|
7934
|
+
return void 0;
|
|
7547
7935
|
}
|
|
7936
|
+
return { sha: commit, line: Number(match[2]) };
|
|
7937
|
+
}
|
|
7938
|
+
// show commit of current line in split window
|
|
7939
|
+
async showCommit(useFloating = false) {
|
|
7940
|
+
var _a;
|
|
7941
|
+
let current = await this.getCurrentCommit();
|
|
7942
|
+
if (!current) return;
|
|
7943
|
+
let { sha: commit, line: commitLine } = current;
|
|
7944
|
+
let nvim = import_coc12.workspace.nvim;
|
|
7548
7945
|
if (!useFloating) useFloating = this.config.showCommitInFloating;
|
|
7549
7946
|
if (useFloating) {
|
|
7550
7947
|
let content = await this.repo.safeRun(["--no-pager", "show", commit]);
|
|
@@ -7575,15 +7972,15 @@ var GitBuffer = class {
|
|
|
7575
7972
|
}
|
|
7576
7973
|
}
|
|
7577
7974
|
async toggleFold() {
|
|
7578
|
-
let { nvim } =
|
|
7975
|
+
let { nvim } = import_coc12.workspace;
|
|
7579
7976
|
let buf = this.doc.buffer;
|
|
7580
7977
|
let win = await nvim.window;
|
|
7581
7978
|
let bufnr = buf.id;
|
|
7582
|
-
let doc =
|
|
7979
|
+
let doc = import_coc12.workspace.getDocument(bufnr);
|
|
7583
7980
|
if (!doc) return;
|
|
7584
7981
|
let infos = this.currentSigns;
|
|
7585
7982
|
if (!infos || infos.length == 0) {
|
|
7586
|
-
|
|
7983
|
+
import_coc12.window.showWarningMessage("No changes");
|
|
7587
7984
|
return;
|
|
7588
7985
|
}
|
|
7589
7986
|
let changedLines = new Set(infos.map((o) => o.line));
|
|
@@ -7649,7 +8046,7 @@ var GitBuffer = class {
|
|
|
7649
8046
|
}
|
|
7650
8047
|
async toggleGutters(enabled) {
|
|
7651
8048
|
this.config.enableGutters = enabled;
|
|
7652
|
-
let { nvim } =
|
|
8049
|
+
let { nvim } = import_coc12.workspace;
|
|
7653
8050
|
if (!enabled) {
|
|
7654
8051
|
nvim.call("sign_unplace", [signGroup, { buffer: this.doc.bufnr }], true);
|
|
7655
8052
|
nvim.redrawVim();
|
|
@@ -7751,18 +8148,18 @@ var GitBuffer = class {
|
|
|
7751
8148
|
let currentHlGroup = this.config.conflict.currentHlGroup;
|
|
7752
8149
|
let incomingHlGroup = this.config.conflict.incomingHlGroup;
|
|
7753
8150
|
let commonHlGroup = this.config.conflict.commonHlGroup;
|
|
7754
|
-
let { nvim } =
|
|
8151
|
+
let { nvim } = import_coc12.workspace;
|
|
7755
8152
|
nvim.pauseNotification();
|
|
7756
8153
|
buffer.clearNamespace(this.config.conflictSrcId, 0, -1);
|
|
7757
8154
|
const srcId = this.config.conflictSrcId;
|
|
7758
8155
|
conflicts.map((conflict) => {
|
|
7759
8156
|
let currEnd = conflict.common ? conflict.common - 1 : conflict.sep - 1;
|
|
7760
|
-
let currRange =
|
|
7761
|
-
let incomingRange =
|
|
8157
|
+
let currRange = import_coc12.Range.create(import_coc12.Position.create(conflict.start - 1, 0), import_coc12.Position.create(currEnd, 0));
|
|
8158
|
+
let incomingRange = import_coc12.Range.create(import_coc12.Position.create(conflict.sep, 0), import_coc12.Position.create(conflict.end, 0));
|
|
7762
8159
|
buffer.highlightRanges(srcId, currentHlGroup, [currRange]);
|
|
7763
8160
|
buffer.highlightRanges(srcId, incomingHlGroup, [incomingRange]);
|
|
7764
8161
|
if (conflict.common) {
|
|
7765
|
-
let range =
|
|
8162
|
+
let range = import_coc12.Range.create(import_coc12.Position.create(conflict.common - 1, 0), import_coc12.Position.create(conflict.sep - 1, 0));
|
|
7766
8163
|
buffer.highlightRanges(srcId, commonHlGroup, [range]);
|
|
7767
8164
|
}
|
|
7768
8165
|
});
|
|
@@ -7774,14 +8171,14 @@ var GitBuffer = class {
|
|
|
7774
8171
|
await this.floatFactory.show(docs, this.config.floatConfig);
|
|
7775
8172
|
} else {
|
|
7776
8173
|
const lines = content.split("\n");
|
|
7777
|
-
|
|
8174
|
+
import_coc12.workspace.nvim.call("coc#ui#preview_info", [lines, filetype], true);
|
|
7778
8175
|
}
|
|
7779
8176
|
}
|
|
7780
8177
|
setBufferStatus(status) {
|
|
7781
8178
|
let exists = this.gitStatus;
|
|
7782
8179
|
if (exists == status) return;
|
|
7783
8180
|
this.gitStatus = status;
|
|
7784
|
-
let { nvim } =
|
|
8181
|
+
let { nvim } = import_coc12.workspace;
|
|
7785
8182
|
let buffer = nvim.createBuffer(this.doc.bufnr);
|
|
7786
8183
|
nvim.pauseNotification();
|
|
7787
8184
|
buffer.setVar("coc_git_status", status, true);
|
|
@@ -7822,7 +8219,7 @@ var GitBuffer = class {
|
|
|
7822
8219
|
dispose() {
|
|
7823
8220
|
if (this._disposed) return;
|
|
7824
8221
|
this._disposed = true;
|
|
7825
|
-
let { nvim } =
|
|
8222
|
+
let { nvim } = import_coc12.workspace;
|
|
7826
8223
|
let { bufnr } = this.doc;
|
|
7827
8224
|
let buffer = nvim.createBuffer(bufnr);
|
|
7828
8225
|
nvim.pauseNotification();
|
|
@@ -7841,20 +8238,20 @@ var GitBuffer = class {
|
|
|
7841
8238
|
this.foldEnabled = false;
|
|
7842
8239
|
}
|
|
7843
8240
|
};
|
|
7844
|
-
function plus(val,
|
|
7845
|
-
if (!
|
|
7846
|
-
val = val +
|
|
8241
|
+
function plus(val, count2, max) {
|
|
8242
|
+
if (!count2) return val;
|
|
8243
|
+
val = val + count2;
|
|
7847
8244
|
return Math.min(max, val);
|
|
7848
8245
|
}
|
|
7849
|
-
function minus(val,
|
|
7850
|
-
if (!
|
|
7851
|
-
val = val -
|
|
8246
|
+
function minus(val, count2, min) {
|
|
8247
|
+
if (!count2) return val;
|
|
8248
|
+
val = val - count2;
|
|
7852
8249
|
return Math.max(min, val);
|
|
7853
8250
|
}
|
|
7854
8251
|
|
|
7855
8252
|
// src/model/git.ts
|
|
7856
8253
|
var cp = __toESM(require("child_process"));
|
|
7857
|
-
var
|
|
8254
|
+
var import_coc13 = require("coc.nvim");
|
|
7858
8255
|
var import_iconv_lite = __toESM(require_lib());
|
|
7859
8256
|
var import_path6 = __toESM(require("path"));
|
|
7860
8257
|
var Git = class {
|
|
@@ -7942,11 +8339,11 @@ async function exec2(child, cancellationToken) {
|
|
|
7942
8339
|
const disposables = [];
|
|
7943
8340
|
const once = (ee, name, fn) => {
|
|
7944
8341
|
ee.once(name, fn);
|
|
7945
|
-
disposables.push(
|
|
8342
|
+
disposables.push(import_coc13.Disposable.create(() => ee.removeListener(name, fn)));
|
|
7946
8343
|
};
|
|
7947
8344
|
const on = (ee, name, fn) => {
|
|
7948
8345
|
ee.on(name, fn);
|
|
7949
|
-
disposables.push(
|
|
8346
|
+
disposables.push(import_coc13.Disposable.create(() => ee.removeListener(name, fn)));
|
|
7950
8347
|
};
|
|
7951
8348
|
let result = Promise.all([
|
|
7952
8349
|
new Promise((c, e) => {
|
|
@@ -7981,12 +8378,12 @@ async function exec2(child, cancellationToken) {
|
|
|
7981
8378
|
const [exitCode, stdout, stderr] = await result;
|
|
7982
8379
|
return { exitCode, stdout, stderr };
|
|
7983
8380
|
} finally {
|
|
7984
|
-
(0,
|
|
8381
|
+
(0, import_coc13.disposeAll)(disposables);
|
|
7985
8382
|
}
|
|
7986
8383
|
}
|
|
7987
8384
|
|
|
7988
8385
|
// src/model/resolver.ts
|
|
7989
|
-
var
|
|
8386
|
+
var import_coc14 = require("coc.nvim");
|
|
7990
8387
|
var import_fs3 = __toESM(require("fs"));
|
|
7991
8388
|
var import_path7 = __toESM(require("path"));
|
|
7992
8389
|
var import_util7 = require("util");
|
|
@@ -7997,7 +8394,7 @@ async function getRealPath(fullpath) {
|
|
|
7997
8394
|
} catch (e) {
|
|
7998
8395
|
if (e.message.includes("ENOENT")) {
|
|
7999
8396
|
try {
|
|
8000
|
-
resolved = await
|
|
8397
|
+
resolved = await import_coc14.workspace.nvim.call("expand", [fullpath]);
|
|
8001
8398
|
} catch (e2) {
|
|
8002
8399
|
}
|
|
8003
8400
|
}
|
|
@@ -8036,7 +8433,7 @@ var Resolver = class {
|
|
|
8036
8433
|
if (doc.buftype != "" || doc.schema != "file") {
|
|
8037
8434
|
return null;
|
|
8038
8435
|
}
|
|
8039
|
-
let fullpath = await getRealPath(
|
|
8436
|
+
let fullpath = await getRealPath(import_coc14.Uri.parse(uri).fsPath);
|
|
8040
8437
|
if (process.platform == "win32") {
|
|
8041
8438
|
fullpath = import_path7.default.win32.normalize(fullpath);
|
|
8042
8439
|
}
|
|
@@ -8067,11 +8464,11 @@ var Resolver = class {
|
|
|
8067
8464
|
return root;
|
|
8068
8465
|
}
|
|
8069
8466
|
async resolveRootFromCwd() {
|
|
8070
|
-
let parts =
|
|
8467
|
+
let parts = import_coc14.workspace.cwd.split(import_path7.default.sep);
|
|
8071
8468
|
let idx = parts.indexOf(".git");
|
|
8072
8469
|
if (idx !== -1) return parts.slice(0, idx).join(import_path7.default.sep);
|
|
8073
8470
|
try {
|
|
8074
|
-
return await this.git.getRepositoryRoot(
|
|
8471
|
+
return await this.git.getRepositoryRoot(import_coc14.workspace.cwd);
|
|
8075
8472
|
} catch (e) {
|
|
8076
8473
|
}
|
|
8077
8474
|
return null;
|
|
@@ -8086,11 +8483,11 @@ var Resolver = class {
|
|
|
8086
8483
|
var GitService = class {
|
|
8087
8484
|
constructor(gitInfo) {
|
|
8088
8485
|
this.repos = /* @__PURE__ */ new Map();
|
|
8089
|
-
const outputChannel = this.outputChannel =
|
|
8486
|
+
const outputChannel = this.outputChannel = import_coc15.window.createOutputChannel("git");
|
|
8090
8487
|
this._git = new git_default(gitInfo, outputChannel);
|
|
8091
8488
|
this._resolver = new Resolver(this._git, outputChannel);
|
|
8092
|
-
if (typeof
|
|
8093
|
-
this.floatFactory =
|
|
8489
|
+
if (typeof import_coc15.window.createFloatFactory === "function") {
|
|
8490
|
+
this.floatFactory = import_coc15.window.createFloatFactory({ modes: ["n"] });
|
|
8094
8491
|
}
|
|
8095
8492
|
}
|
|
8096
8493
|
getRepoFromRoot(root) {
|
|
@@ -8116,13 +8513,13 @@ var GitService = class {
|
|
|
8116
8513
|
return new GitBuffer(doc, config, relpath, repo, this.git, this.outputChannel, this.floatFactory, hasConflicts);
|
|
8117
8514
|
}
|
|
8118
8515
|
async getCurrentRepo() {
|
|
8119
|
-
let editor =
|
|
8516
|
+
let editor = import_coc15.window.activeTextEditor;
|
|
8120
8517
|
let root;
|
|
8121
8518
|
if (editor) {
|
|
8122
8519
|
root = await this.resolver.resolveGitRoot(editor.document);
|
|
8123
8520
|
} else {
|
|
8124
|
-
let cwd =
|
|
8125
|
-
root = await this.resolver.resolveGitRoot({ uri:
|
|
8521
|
+
let cwd = import_coc15.workspace.cwd;
|
|
8522
|
+
root = await this.resolver.resolveGitRoot({ uri: import_coc15.Uri.file(cwd).toString(), schema: "file", buftype: "" });
|
|
8126
8523
|
}
|
|
8127
8524
|
if (root == null) return void 0;
|
|
8128
8525
|
return this.getRepoFromRoot(root);
|
|
@@ -8146,7 +8543,7 @@ var GitService = class {
|
|
|
8146
8543
|
};
|
|
8147
8544
|
|
|
8148
8545
|
// src/source.ts
|
|
8149
|
-
var
|
|
8546
|
+
var import_coc16 = require("coc.nvim");
|
|
8150
8547
|
var import_safe5 = __toESM(require_safe());
|
|
8151
8548
|
var import_url2 = require("url");
|
|
8152
8549
|
function byteSlice(content, start, end) {
|
|
@@ -8156,7 +8553,7 @@ function byteSlice(content, start, end) {
|
|
|
8156
8553
|
var issuesMap = /* @__PURE__ */ new Map();
|
|
8157
8554
|
function issuesFiletypes() {
|
|
8158
8555
|
var _a;
|
|
8159
|
-
return (_a =
|
|
8556
|
+
return (_a = import_coc16.workspace.getConfiguration().get("coc.source.issues.filetypes")) != null ? _a : [];
|
|
8160
8557
|
}
|
|
8161
8558
|
function getOrganizationNameAndRepoNameFromGitHubRemoteUrl(remoteUrl) {
|
|
8162
8559
|
try {
|
|
@@ -8196,7 +8593,7 @@ function renderWord(issue, issueFormat) {
|
|
|
8196
8593
|
function addSource(context, service) {
|
|
8197
8594
|
let { subscriptions, logger } = context;
|
|
8198
8595
|
const { resolver } = service;
|
|
8199
|
-
let statusItem =
|
|
8596
|
+
let statusItem = import_coc16.window.createStatusBarItem(0, { progress: true });
|
|
8200
8597
|
subscriptions.push(statusItem, { dispose: () => issuesMap.clear() });
|
|
8201
8598
|
statusItem.text = "loading issues";
|
|
8202
8599
|
let statusItemCounter = 0;
|
|
@@ -8242,7 +8639,7 @@ function addSource(context, service) {
|
|
|
8242
8639
|
while (true) {
|
|
8243
8640
|
const pageUri = `${uri}&page=${pageIndex}`;
|
|
8244
8641
|
pageIndex++;
|
|
8245
|
-
let info = await (0,
|
|
8642
|
+
let info = await (0, import_coc16.fetch)(pageUri, { headers: { "Private-Token": token } });
|
|
8246
8643
|
if (!info.length) {
|
|
8247
8644
|
break;
|
|
8248
8645
|
}
|
|
@@ -8279,7 +8676,7 @@ function addSource(context, service) {
|
|
|
8279
8676
|
let page_uri = `${uri}&page=${page_idx}`;
|
|
8280
8677
|
page_idx++;
|
|
8281
8678
|
try {
|
|
8282
|
-
let info = await (0,
|
|
8679
|
+
let info = await (0, import_coc16.fetch)(page_uri, { headers });
|
|
8283
8680
|
if (info.length == 0) {
|
|
8284
8681
|
break;
|
|
8285
8682
|
}
|
|
@@ -8304,7 +8701,7 @@ function addSource(context, service) {
|
|
|
8304
8701
|
return issues;
|
|
8305
8702
|
}
|
|
8306
8703
|
async function loadIssues(root) {
|
|
8307
|
-
let config =
|
|
8704
|
+
let config = import_coc16.workspace.getConfiguration("git", root);
|
|
8308
8705
|
const repo = service.getRepoFromRoot(root);
|
|
8309
8706
|
const issueSources = (await repo.safeRun(["config", "--get", "coc-git.issuesources"]) || "").trim();
|
|
8310
8707
|
if (issueSources) {
|
|
@@ -8348,24 +8745,24 @@ function addSource(context, service) {
|
|
|
8348
8745
|
var _a;
|
|
8349
8746
|
if (root) {
|
|
8350
8747
|
let issues = await loadIssues(root);
|
|
8351
|
-
if (((_a =
|
|
8748
|
+
if (((_a = import_coc16.workspace.getDocument(doc.bufnr)) == null ? void 0 : _a.uri) === doc.uri) {
|
|
8352
8749
|
issuesMap.set(doc.bufnr, issues);
|
|
8353
8750
|
}
|
|
8354
8751
|
}
|
|
8355
8752
|
}).catch(onError);
|
|
8356
8753
|
};
|
|
8357
|
-
for (let doc of
|
|
8754
|
+
for (let doc of import_coc16.workspace.documents) {
|
|
8358
8755
|
if (issuesFiletypes().includes(doc.filetype)) {
|
|
8359
8756
|
loadIssuesFromDocument(doc);
|
|
8360
8757
|
}
|
|
8361
8758
|
}
|
|
8362
|
-
|
|
8759
|
+
import_coc16.workspace.onDidOpenTextDocument(async (e) => {
|
|
8363
8760
|
if (issuesFiletypes().includes(e.languageId)) {
|
|
8364
|
-
let doc =
|
|
8761
|
+
let doc = import_coc16.workspace.getDocument(e.uri);
|
|
8365
8762
|
loadIssuesFromDocument(doc);
|
|
8366
8763
|
}
|
|
8367
8764
|
}, null, subscriptions);
|
|
8368
|
-
subscriptions.push(
|
|
8765
|
+
subscriptions.push(import_coc16.workspace.registerAutocmd({
|
|
8369
8766
|
event: "BufUnload",
|
|
8370
8767
|
arglist: ["+expand('<abuf>')"],
|
|
8371
8768
|
callback: (bufnr) => {
|
|
@@ -8377,7 +8774,7 @@ function addSource(context, service) {
|
|
|
8377
8774
|
async doComplete(opt) {
|
|
8378
8775
|
let pre = byteSlice(opt.line, 0, opt.colnr - 1);
|
|
8379
8776
|
if (pre && pre.endsWith("#")) {
|
|
8380
|
-
const config =
|
|
8777
|
+
const config = import_coc16.workspace.getConfiguration("git");
|
|
8381
8778
|
const issueFormat = config.get("issueFormat", "#%i");
|
|
8382
8779
|
let issues = issuesMap.get(opt.bufnr);
|
|
8383
8780
|
if (!issues || issues.length == 0) return null;
|
|
@@ -8402,14 +8799,14 @@ function addSource(context, service) {
|
|
|
8402
8799
|
};
|
|
8403
8800
|
}
|
|
8404
8801
|
};
|
|
8405
|
-
subscriptions.push(
|
|
8802
|
+
subscriptions.push(import_coc16.sources.createSource(source));
|
|
8406
8803
|
let list = {
|
|
8407
8804
|
name: "issues",
|
|
8408
8805
|
actions: [{
|
|
8409
8806
|
name: "open",
|
|
8410
8807
|
execute: async (item) => {
|
|
8411
8808
|
let { url } = item.data;
|
|
8412
|
-
await
|
|
8809
|
+
await import_coc16.workspace.openResource(url);
|
|
8413
8810
|
},
|
|
8414
8811
|
multiple: false
|
|
8415
8812
|
}, {
|
|
@@ -8419,7 +8816,7 @@ function addSource(context, service) {
|
|
|
8419
8816
|
let { body, id } = item.data;
|
|
8420
8817
|
let lines = (body || "").split(/\r?\n/);
|
|
8421
8818
|
let mod = context2.options.position == "top" ? "below" : "above";
|
|
8422
|
-
let { nvim } =
|
|
8819
|
+
let { nvim } = import_coc16.workspace;
|
|
8423
8820
|
nvim.pauseNotification();
|
|
8424
8821
|
nvim.command("pclose", true);
|
|
8425
8822
|
nvim.command(`${mod} ${lines.length}sp +setl\\ previewwindow [issue ${id}]`, true);
|
|
@@ -8438,7 +8835,7 @@ function addSource(context, service) {
|
|
|
8438
8835
|
description: "issues on github/gitlab",
|
|
8439
8836
|
loadItems: async (context2) => {
|
|
8440
8837
|
let buf = await context2.window.buffer;
|
|
8441
|
-
let root = await resolver.resolveGitRoot(
|
|
8838
|
+
let root = await resolver.resolveGitRoot(import_coc16.workspace.getDocument(buf.id));
|
|
8442
8839
|
if (!root) return [];
|
|
8443
8840
|
let issues = await loadIssues(root);
|
|
8444
8841
|
return issues.map((o) => {
|
|
@@ -8449,134 +8846,1069 @@ function addSource(context, service) {
|
|
|
8449
8846
|
});
|
|
8450
8847
|
}
|
|
8451
8848
|
};
|
|
8452
|
-
subscriptions.push(
|
|
8849
|
+
subscriptions.push(import_coc16.listManager.registerList(list));
|
|
8850
|
+
}
|
|
8851
|
+
|
|
8852
|
+
// src/tree/commitFiles.ts
|
|
8853
|
+
var import_fs4 = __toESM(require("fs"));
|
|
8854
|
+
var import_path8 = __toESM(require("path"));
|
|
8855
|
+
var import_coc17 = require("coc.nvim");
|
|
8856
|
+
function emptyAggregate() {
|
|
8857
|
+
return { fileCount: 0, additions: 0, deletions: 0, binaryCount: 0 };
|
|
8858
|
+
}
|
|
8859
|
+
function addAggregate(target, source) {
|
|
8860
|
+
target.fileCount += source.fileCount;
|
|
8861
|
+
target.additions += source.additions;
|
|
8862
|
+
target.deletions += source.deletions;
|
|
8863
|
+
target.binaryCount += source.binaryCount;
|
|
8864
|
+
}
|
|
8865
|
+
function addFileAggregate(target, change) {
|
|
8866
|
+
var _a, _b;
|
|
8867
|
+
target.fileCount++;
|
|
8868
|
+
if (change.binary) {
|
|
8869
|
+
target.binaryCount++;
|
|
8870
|
+
} else {
|
|
8871
|
+
target.additions += (_a = change.additions) != null ? _a : 0;
|
|
8872
|
+
target.deletions += (_b = change.deletions) != null ? _b : 0;
|
|
8873
|
+
}
|
|
8874
|
+
}
|
|
8875
|
+
function treeKey(comparison) {
|
|
8876
|
+
var _a;
|
|
8877
|
+
return `${comparison.commit.sha}\0${(_a = comparison.baseSha) != null ? _a : "root"}`;
|
|
8878
|
+
}
|
|
8879
|
+
function compareNodes(left, right) {
|
|
8880
|
+
if (left.kind === "directory" && right.kind !== "directory") return -1;
|
|
8881
|
+
if (left.kind !== "directory" && right.kind === "directory") return 1;
|
|
8882
|
+
return left.relativePath.localeCompare(right.relativePath);
|
|
8883
|
+
}
|
|
8884
|
+
function buildCommitTree(comparison) {
|
|
8885
|
+
const key = treeKey(comparison);
|
|
8886
|
+
const root = {
|
|
8887
|
+
...emptyAggregate(),
|
|
8888
|
+
kind: "root",
|
|
8889
|
+
id: `${key}\0root`,
|
|
8890
|
+
name: comparison.commit.subject,
|
|
8891
|
+
relativePath: "",
|
|
8892
|
+
parent: void 0,
|
|
8893
|
+
comparison,
|
|
8894
|
+
children: []
|
|
8895
|
+
};
|
|
8896
|
+
const directories = /* @__PURE__ */ new Map();
|
|
8897
|
+
const ensureDirectory = (segments) => {
|
|
8898
|
+
if (!segments.length) return root;
|
|
8899
|
+
const relativePath = segments.join("/");
|
|
8900
|
+
const existing = directories.get(relativePath);
|
|
8901
|
+
if (existing) return existing;
|
|
8902
|
+
const parent = ensureDirectory(segments.slice(0, -1));
|
|
8903
|
+
const directory = {
|
|
8904
|
+
...emptyAggregate(),
|
|
8905
|
+
kind: "directory",
|
|
8906
|
+
id: `${key}\0directory\0${relativePath}`,
|
|
8907
|
+
name: segments[segments.length - 1],
|
|
8908
|
+
relativePath,
|
|
8909
|
+
parent,
|
|
8910
|
+
children: []
|
|
8911
|
+
};
|
|
8912
|
+
directories.set(relativePath, directory);
|
|
8913
|
+
parent.children.push(directory);
|
|
8914
|
+
return directory;
|
|
8915
|
+
};
|
|
8916
|
+
for (const change of comparison.changes) {
|
|
8917
|
+
const segments = change.path.split("/");
|
|
8918
|
+
const name = segments.pop();
|
|
8919
|
+
if (!name) throw new Error(`Invalid empty Git path in ${comparison.commit.shortSha}`);
|
|
8920
|
+
const parent = ensureDirectory(segments);
|
|
8921
|
+
const file = {
|
|
8922
|
+
kind: "file",
|
|
8923
|
+
id: `${key}\0file\0${change.path}`,
|
|
8924
|
+
name,
|
|
8925
|
+
relativePath: change.path,
|
|
8926
|
+
parent,
|
|
8927
|
+
change,
|
|
8928
|
+
comparison
|
|
8929
|
+
};
|
|
8930
|
+
parent.children.push(file);
|
|
8931
|
+
}
|
|
8932
|
+
const aggregate = (node) => {
|
|
8933
|
+
const own = emptyAggregate();
|
|
8934
|
+
for (const child of node.children) {
|
|
8935
|
+
if (child.kind === "file") addFileAggregate(own, child.change);
|
|
8936
|
+
else {
|
|
8937
|
+
aggregate(child);
|
|
8938
|
+
addAggregate(own, child);
|
|
8939
|
+
}
|
|
8940
|
+
}
|
|
8941
|
+
node.fileCount = own.fileCount;
|
|
8942
|
+
node.additions = own.additions;
|
|
8943
|
+
node.deletions = own.deletions;
|
|
8944
|
+
node.binaryCount = own.binaryCount;
|
|
8945
|
+
node.children.sort(compareNodes);
|
|
8946
|
+
};
|
|
8947
|
+
aggregate(root);
|
|
8948
|
+
return root;
|
|
8949
|
+
}
|
|
8950
|
+
function escapeDisplay(value) {
|
|
8951
|
+
return value.replace(/\r/g, "\\r").replace(/\n/g, "\\n").replace(/\t/g, "\\t");
|
|
8952
|
+
}
|
|
8953
|
+
function countDescription(node) {
|
|
8954
|
+
const binary = node.binaryCount ? ` \xB7 ${node.binaryCount} binary` : "";
|
|
8955
|
+
return `${node.fileCount} file${node.fileCount === 1 ? "" : "s"} \xB7 +${node.additions} -${node.deletions}${binary}`;
|
|
8956
|
+
}
|
|
8957
|
+
function comparisonDescription(comparison) {
|
|
8958
|
+
var _a;
|
|
8959
|
+
const parent = comparison.baseSha ? `parent ${((_a = comparison.parentIndex) != null ? _a : 0) + 1}/${comparison.commit.parents.length}` : "root";
|
|
8960
|
+
return `${comparison.commit.shortSha} \xB7 ${parent}`;
|
|
8961
|
+
}
|
|
8962
|
+
function statusIcon(status) {
|
|
8963
|
+
if (status === "A") return { text: "+", hlGroup: "DiffAdd" };
|
|
8964
|
+
if (status === "M") return { text: "~", hlGroup: "DiffChange" };
|
|
8965
|
+
if (status === "D") return { text: "-", hlGroup: "DiffDelete" };
|
|
8966
|
+
if (status === "R") return { text: "R", hlGroup: "DiffChange" };
|
|
8967
|
+
if (status === "C") return { text: "C", hlGroup: "DiffAdd" };
|
|
8968
|
+
return { text: status, hlGroup: "WarningMsg" };
|
|
8969
|
+
}
|
|
8970
|
+
function fileDescription(change) {
|
|
8971
|
+
var _a, _b, _c;
|
|
8972
|
+
const status = change.status === "R" || change.status === "C" ? `${change.status}${(_a = change.score) != null ? _a : ""}` : change.status;
|
|
8973
|
+
if (change.binary) return `${status} \xB7 binary`;
|
|
8974
|
+
const stats = `+${(_b = change.additions) != null ? _b : 0} -${(_c = change.deletions) != null ? _c : 0}`;
|
|
8975
|
+
if (change.oldPath) return `${status} \xB7 ${escapeDisplay(change.oldPath)} \u2192 ${escapeDisplay(change.path)} \xB7 ${stats}`;
|
|
8976
|
+
return `${status} \xB7 ${stats}`;
|
|
8977
|
+
}
|
|
8978
|
+
function fileTooltip(change) {
|
|
8979
|
+
var _a;
|
|
8980
|
+
const current = `new path: ${escapeDisplay(change.path)}`;
|
|
8981
|
+
const old = change.oldPath ? `
|
|
8982
|
+
old path: ${escapeDisplay(change.oldPath)}
|
|
8983
|
+
similarity: ${(_a = change.score) != null ? _a : 0}%` : "";
|
|
8984
|
+
return `${current}${old}`;
|
|
8985
|
+
}
|
|
8986
|
+
function nodeCommand(node, title) {
|
|
8987
|
+
return {
|
|
8988
|
+
command: "git.commitFiles.toggle",
|
|
8989
|
+
title,
|
|
8990
|
+
arguments: [node]
|
|
8991
|
+
};
|
|
8992
|
+
}
|
|
8993
|
+
var CommitFilesProvider = class {
|
|
8994
|
+
constructor(comparison, actions) {
|
|
8995
|
+
this.actions = actions;
|
|
8996
|
+
this.emitter = new import_coc17.Emitter();
|
|
8997
|
+
this.onDidChangeTreeData = this.emitter.event;
|
|
8998
|
+
this.root = buildCommitTree(comparison);
|
|
8999
|
+
}
|
|
9000
|
+
setComparison(comparison) {
|
|
9001
|
+
this.root = buildCommitTree(comparison);
|
|
9002
|
+
this.emitter.fire(void 0);
|
|
9003
|
+
}
|
|
9004
|
+
get comparison() {
|
|
9005
|
+
return this.root.comparison;
|
|
9006
|
+
}
|
|
9007
|
+
getTreeItem(element) {
|
|
9008
|
+
if (element.kind === "root") {
|
|
9009
|
+
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);
|
|
9010
|
+
item2.id = element.id;
|
|
9011
|
+
item2.description = countDescription(element);
|
|
9012
|
+
item2.tooltip = `${element.comparison.commit.sha}
|
|
9013
|
+
${element.comparison.commit.author} \xB7 ${element.comparison.commit.authoredAt}`;
|
|
9014
|
+
item2.command = {
|
|
9015
|
+
command: "git.commitFiles.invoke",
|
|
9016
|
+
title: "Show commit",
|
|
9017
|
+
arguments: [element]
|
|
9018
|
+
};
|
|
9019
|
+
return item2;
|
|
9020
|
+
}
|
|
9021
|
+
if (element.kind === "directory") {
|
|
9022
|
+
const item2 = new import_coc17.TreeItem(escapeDisplay(element.name), element.children.length ? import_coc17.TreeItemCollapsibleState.Collapsed : import_coc17.TreeItemCollapsibleState.None);
|
|
9023
|
+
item2.id = element.id;
|
|
9024
|
+
item2.description = countDescription(element);
|
|
9025
|
+
item2.tooltip = escapeDisplay(element.relativePath);
|
|
9026
|
+
item2.command = nodeCommand(element, "Toggle directory");
|
|
9027
|
+
return item2;
|
|
9028
|
+
}
|
|
9029
|
+
const item = new import_coc17.TreeItem(escapeDisplay(element.name), import_coc17.TreeItemCollapsibleState.None);
|
|
9030
|
+
item.id = element.id;
|
|
9031
|
+
item.icon = statusIcon(element.change.status);
|
|
9032
|
+
item.description = fileDescription(element.change);
|
|
9033
|
+
item.tooltip = fileTooltip(element.change);
|
|
9034
|
+
item.command = {
|
|
9035
|
+
command: "git.commitFiles.invoke",
|
|
9036
|
+
title: "Show code",
|
|
9037
|
+
arguments: [element]
|
|
9038
|
+
};
|
|
9039
|
+
return item;
|
|
9040
|
+
}
|
|
9041
|
+
getChildren(element) {
|
|
9042
|
+
if (!element) return [this.root];
|
|
9043
|
+
return element.kind === "file" ? [] : element.children;
|
|
9044
|
+
}
|
|
9045
|
+
getParent(element) {
|
|
9046
|
+
return element.parent;
|
|
9047
|
+
}
|
|
9048
|
+
findFile(relativePath) {
|
|
9049
|
+
const pending = [...this.root.children];
|
|
9050
|
+
while (pending.length) {
|
|
9051
|
+
const node = pending.pop();
|
|
9052
|
+
if (node.kind === "file") {
|
|
9053
|
+
if (node.relativePath === relativePath) return node;
|
|
9054
|
+
} else {
|
|
9055
|
+
pending.push(...node.children);
|
|
9056
|
+
}
|
|
9057
|
+
}
|
|
9058
|
+
return void 0;
|
|
9059
|
+
}
|
|
9060
|
+
resolveActions(_item, element) {
|
|
9061
|
+
if (element.kind === "root") {
|
|
9062
|
+
const result2 = [
|
|
9063
|
+
{ title: "Show commit", handler: (item) => this.actions.showCommit(item) },
|
|
9064
|
+
{ title: "Copy commit hash", handler: (item) => this.actions.copyCommitHash(item) }
|
|
9065
|
+
];
|
|
9066
|
+
if (element.comparison.commit.parents.length > 1) {
|
|
9067
|
+
result2.push({ title: "Select parent\u2026", handler: (item) => this.actions.selectParent(item) });
|
|
9068
|
+
}
|
|
9069
|
+
return result2;
|
|
9070
|
+
}
|
|
9071
|
+
if (element.kind === "directory") {
|
|
9072
|
+
return [{ title: "Copy directory path", handler: (item) => this.actions.copyDirectoryPath(item) }];
|
|
9073
|
+
}
|
|
9074
|
+
const result = [
|
|
9075
|
+
{ title: "Show code", handler: (item) => this.actions.showCode(item) }
|
|
9076
|
+
];
|
|
9077
|
+
result.push(
|
|
9078
|
+
{ title: "Copy relative path", handler: (item) => this.actions.copyRelativePath(item) },
|
|
9079
|
+
{ title: "Open working tree file", handler: (item) => this.actions.openWorkingTree(item) }
|
|
9080
|
+
);
|
|
9081
|
+
if (element.change.status !== "D") result.push({ title: "Open after version", handler: (item) => this.actions.openVersion(item, false) });
|
|
9082
|
+
if (element.change.status !== "A") result.push({ title: "Open before version", handler: (item) => this.actions.openVersion(item, true) });
|
|
9083
|
+
return result;
|
|
9084
|
+
}
|
|
9085
|
+
dispose() {
|
|
9086
|
+
this.emitter.dispose();
|
|
9087
|
+
}
|
|
9088
|
+
};
|
|
9089
|
+
function parseTreeEntry2(output) {
|
|
9090
|
+
if (!output) return void 0;
|
|
9091
|
+
const end = output.indexOf("\0");
|
|
9092
|
+
const record = end < 0 ? output : output.slice(0, end);
|
|
9093
|
+
const tab = record.indexOf(" ");
|
|
9094
|
+
if (tab < 0) throw new Error("Invalid Git tree entry");
|
|
9095
|
+
const fields = record.slice(0, tab).split(" ");
|
|
9096
|
+
if (fields.length !== 3 || !fields[0] || !fields[1] || !fields[2]) throw new Error("Invalid Git tree entry");
|
|
9097
|
+
return { mode: fields[0], type: fields[1], oid: fields[2], path: record.slice(tab + 1) };
|
|
9098
|
+
}
|
|
9099
|
+
async function showScratch(nvim, targetWinId, name, lines, filetype = "git", line = 1) {
|
|
9100
|
+
const moved = await nvim.call("win_gotoid", [targetWinId]);
|
|
9101
|
+
if (!moved) await nvim.command("new");
|
|
9102
|
+
else await nvim.command("enew");
|
|
9103
|
+
const escapedName = await nvim.call("fnameescape", [name]);
|
|
9104
|
+
const content = lines.length ? lines : [""];
|
|
9105
|
+
nvim.pauseNotification();
|
|
9106
|
+
nvim.command("setlocal buftype=nofile bufhidden=wipe noswapfile nobuflisted modifiable", true);
|
|
9107
|
+
nvim.call("setline", [1, content], true);
|
|
9108
|
+
nvim.command(`file ${escapedName}`, true);
|
|
9109
|
+
if (filetype === "git") nvim.command("setlocal filetype=git", true);
|
|
9110
|
+
else nvim.command("filetype detect", true);
|
|
9111
|
+
nvim.command("setlocal nomodifiable readonly", true);
|
|
9112
|
+
nvim.call("cursor", [Math.max(1, Math.min(line, content.length)), 1], true);
|
|
9113
|
+
await nvim.resumeNotification();
|
|
9114
|
+
}
|
|
9115
|
+
var CommitFilesController = class {
|
|
9116
|
+
constructor(manager) {
|
|
9117
|
+
this.manager = manager;
|
|
9118
|
+
}
|
|
9119
|
+
async invoke(node) {
|
|
9120
|
+
if (!node || typeof node !== "object") return;
|
|
9121
|
+
const element = node;
|
|
9122
|
+
if (element.kind === "root") await this.showCommit(element);
|
|
9123
|
+
else if (element.kind === "file") await this.showCode(element);
|
|
9124
|
+
}
|
|
9125
|
+
async toggle(node) {
|
|
9126
|
+
if (!node || typeof node !== "object") return;
|
|
9127
|
+
const element = node;
|
|
9128
|
+
if (element.kind !== "root" && element.kind !== "directory") return;
|
|
9129
|
+
const configuredKey = import_coc17.workspace.getConfiguration("tree").get("key.toggle", "t");
|
|
9130
|
+
const key = configuredKey.startsWith("<") && configuredKey.endsWith(">") ? `\\${configuredKey}` : configuredKey;
|
|
9131
|
+
const escaped = key.replace(/\\/g, "\\\\").replace(/"/g, '\\"');
|
|
9132
|
+
await import_coc17.workspace.nvim.call("eval", [`feedkeys("${escaped}", "in")`]);
|
|
9133
|
+
}
|
|
9134
|
+
async open(revision, requestedRoot, options = {}) {
|
|
9135
|
+
var _a;
|
|
9136
|
+
const value = revision === void 0 ? await import_coc17.window.requestInput("Git commit revision", "HEAD") : revision;
|
|
9137
|
+
if (!value || !value.trim()) return;
|
|
9138
|
+
let root = requestedRoot;
|
|
9139
|
+
if (!root) root = await this.manager.resolveGitRootFromBufferOrCwd(await import_coc17.workspace.nvim.call("bufnr", ["%"]));
|
|
9140
|
+
if (!root) {
|
|
9141
|
+
import_coc17.window.showWarningMessage("Can't resolve git repository for current buffer or cwd.");
|
|
9142
|
+
return;
|
|
9143
|
+
}
|
|
9144
|
+
try {
|
|
9145
|
+
root = await this.manager.git.getRepositoryRoot(root);
|
|
9146
|
+
} catch (_e) {
|
|
9147
|
+
import_coc17.window.showWarningMessage("Can't resolve git repository for current buffer or cwd.");
|
|
9148
|
+
return;
|
|
9149
|
+
}
|
|
9150
|
+
let commit;
|
|
9151
|
+
try {
|
|
9152
|
+
commit = await resolveCommit(this.manager.git, root, value.trim());
|
|
9153
|
+
} catch (_e) {
|
|
9154
|
+
import_coc17.window.showErrorMessage(`Invalid Git commit: ${value.trim()}`);
|
|
9155
|
+
return;
|
|
9156
|
+
}
|
|
9157
|
+
let comparison;
|
|
9158
|
+
try {
|
|
9159
|
+
comparison = await loadComparisonForCommit(this.manager.git, root, commit);
|
|
9160
|
+
} catch (e) {
|
|
9161
|
+
import_coc17.window.showErrorMessage(`Failed to load commit ${commit.shortSha}: ${e.message}`);
|
|
9162
|
+
return;
|
|
9163
|
+
}
|
|
9164
|
+
const targetWinId = await import_coc17.workspace.nvim.call("win_getid");
|
|
9165
|
+
const targetBufnr = await import_coc17.workspace.nvim.call("bufnr", ["%"]);
|
|
9166
|
+
this.disposeSession();
|
|
9167
|
+
const provider = new CommitFilesProvider(comparison, this.actions);
|
|
9168
|
+
const view = import_coc17.window.createTreeView("git.commitFiles", {
|
|
9169
|
+
treeDataProvider: provider,
|
|
9170
|
+
enableFilter: true,
|
|
9171
|
+
winfixwidth: true,
|
|
9172
|
+
bufhidden: "wipe",
|
|
9173
|
+
canSelectMany: false,
|
|
9174
|
+
autoWidth: true
|
|
9175
|
+
});
|
|
9176
|
+
view.title = "Commit Files";
|
|
9177
|
+
view.description = comparisonDescription(comparison);
|
|
9178
|
+
this.session = { root, comparison, provider, view, targetWinId, cache: /* @__PURE__ */ new Map([[(_a = comparison.baseSha) != null ? _a : "root", comparison]]) };
|
|
9179
|
+
try {
|
|
9180
|
+
await view.show(import_coc17.workspace.getConfiguration("git").get("commitFiles.splitCommand", "belowright 40vs"));
|
|
9181
|
+
const currentFile = this.currentFileNode(provider, root, targetBufnr);
|
|
9182
|
+
if (currentFile) {
|
|
9183
|
+
await view.reveal(currentFile, { focus: true });
|
|
9184
|
+
if (options.showCurrentFile) await this.showCode(currentFile, options.line);
|
|
9185
|
+
}
|
|
9186
|
+
view.onDidChangeVisibility((event) => {
|
|
9187
|
+
var _a2;
|
|
9188
|
+
if (!event.visible && ((_a2 = this.session) == null ? void 0 : _a2.view) === view) this.disposeSession();
|
|
9189
|
+
});
|
|
9190
|
+
} catch (e) {
|
|
9191
|
+
this.disposeSession();
|
|
9192
|
+
import_coc17.window.showErrorMessage(`Failed to open Commit Files: ${e.message}`);
|
|
9193
|
+
}
|
|
9194
|
+
}
|
|
9195
|
+
get actions() {
|
|
9196
|
+
return {
|
|
9197
|
+
showCommit: (node) => this.showCommit(node),
|
|
9198
|
+
copyCommitHash: (node) => this.copy(node.comparison.commit.sha),
|
|
9199
|
+
selectParent: (node) => this.selectParent(node),
|
|
9200
|
+
copyDirectoryPath: (node) => this.copy(node.relativePath),
|
|
9201
|
+
showCode: (node) => this.showCode(node),
|
|
9202
|
+
openVersion: (node, before) => this.openVersion(node, before),
|
|
9203
|
+
openWorkingTree: (node) => this.openWorkingTree(node),
|
|
9204
|
+
copyRelativePath: (node) => this.copy(node.change.oldPath && node.change.status === "D" ? node.change.oldPath : node.change.path)
|
|
9205
|
+
};
|
|
9206
|
+
}
|
|
9207
|
+
currentFileNode(provider, root, bufnr) {
|
|
9208
|
+
const buffer = this.manager.getBuffer(bufnr);
|
|
9209
|
+
if (!buffer) return void 0;
|
|
9210
|
+
const absolute = import_path8.default.resolve(buffer.repo.root, buffer.relpath);
|
|
9211
|
+
const relative = import_path8.default.relative(root, absolute);
|
|
9212
|
+
if (!relative || relative === ".." || relative.startsWith(`..${import_path8.default.sep}`) || import_path8.default.isAbsolute(relative)) return void 0;
|
|
9213
|
+
return provider.findFile(relative.split(import_path8.default.sep).join("/"));
|
|
9214
|
+
}
|
|
9215
|
+
async copy(value) {
|
|
9216
|
+
await import_coc17.workspace.nvim.call("setreg", ["+", value]);
|
|
9217
|
+
}
|
|
9218
|
+
async showCommit(node) {
|
|
9219
|
+
const session = this.session;
|
|
9220
|
+
if (!session) return;
|
|
9221
|
+
try {
|
|
9222
|
+
const content = await this.manager.git.exec(session.root, ["--no-pager", "show", "--no-ext-diff", "--no-color", node.comparison.commit.sha]);
|
|
9223
|
+
await showScratch(import_coc17.workspace.nvim, session.targetWinId, `[commit ${node.comparison.commit.shortSha}]`, content.stdout.replace(/\r?\n$/, "").split(/\r?\n/));
|
|
9224
|
+
} catch (e) {
|
|
9225
|
+
import_coc17.window.showErrorMessage(`Failed to show commit ${node.comparison.commit.shortSha}: ${e.message}`);
|
|
9226
|
+
}
|
|
9227
|
+
}
|
|
9228
|
+
async showCode(node, line) {
|
|
9229
|
+
const session = this.session;
|
|
9230
|
+
if (!session) return;
|
|
9231
|
+
if (node.change.status === "D") {
|
|
9232
|
+
await this.openVersion(node, true, line);
|
|
9233
|
+
return;
|
|
9234
|
+
}
|
|
9235
|
+
if (node.change.binary) {
|
|
9236
|
+
await this.openVersion(node, false);
|
|
9237
|
+
return;
|
|
9238
|
+
}
|
|
9239
|
+
try {
|
|
9240
|
+
await import_coc17.commands.executeCommand("git.commitFiles.openDocument", session.root, node.comparison, node.change, session.targetWinId, line);
|
|
9241
|
+
} catch (e) {
|
|
9242
|
+
import_coc17.window.showErrorMessage(`Failed to show code for ${node.comparison.commit.shortSha}: ${e.message}`);
|
|
9243
|
+
}
|
|
9244
|
+
}
|
|
9245
|
+
async openVersion(node, before, line) {
|
|
9246
|
+
var _a;
|
|
9247
|
+
const session = this.session;
|
|
9248
|
+
if (!session) return;
|
|
9249
|
+
const comparison = node.comparison;
|
|
9250
|
+
const revision = before ? comparison.baseSha : comparison.commit.sha;
|
|
9251
|
+
const relativePath = before ? (_a = node.change.oldPath) != null ? _a : node.change.path : node.change.path;
|
|
9252
|
+
if (!revision) return;
|
|
9253
|
+
try {
|
|
9254
|
+
const entry = parseTreeEntry2((await this.manager.git.exec(session.root, ["ls-tree", "-z", revision, "--", relativePath])).stdout);
|
|
9255
|
+
if (!entry) {
|
|
9256
|
+
import_coc17.window.showWarningMessage(`Git path not found: ${escapeDisplay(relativePath)}`);
|
|
9257
|
+
return;
|
|
9258
|
+
}
|
|
9259
|
+
if (node.change.binary || entry.type !== "blob") {
|
|
9260
|
+
const size = entry.type === "blob" ? (await this.manager.git.exec(session.root, ["cat-file", "-s", entry.oid])).stdout.trim() : "n/a";
|
|
9261
|
+
await showScratch(import_coc17.workspace.nvim, session.targetWinId, `[version ${comparison.commit.shortSha} ${relativePath}]`, [
|
|
9262
|
+
`revision: ${revision}`,
|
|
9263
|
+
`path: ${escapeDisplay(relativePath)}`,
|
|
9264
|
+
`mode: ${entry.mode}`,
|
|
9265
|
+
`type: ${entry.type}`,
|
|
9266
|
+
`object: ${entry.oid}`,
|
|
9267
|
+
`size: ${size}`
|
|
9268
|
+
]);
|
|
9269
|
+
return;
|
|
9270
|
+
}
|
|
9271
|
+
const content = await this.manager.git.exec(session.root, ["cat-file", "-p", entry.oid]);
|
|
9272
|
+
await showScratch(import_coc17.workspace.nvim, session.targetWinId, `[version ${comparison.commit.shortSha} ${relativePath}]`, content.stdout.replace(/\r?\n$/, "").split(/\r?\n/), "detect", line);
|
|
9273
|
+
} catch (e) {
|
|
9274
|
+
import_coc17.window.showErrorMessage(`Failed to open version for ${comparison.commit.shortSha}: ${e.message}`);
|
|
9275
|
+
}
|
|
9276
|
+
}
|
|
9277
|
+
async openWorkingTree(node) {
|
|
9278
|
+
const session = this.session;
|
|
9279
|
+
if (!session) return;
|
|
9280
|
+
const relativePath = node.change.status === "D" && node.change.oldPath ? node.change.oldPath : node.change.path;
|
|
9281
|
+
const absolute = import_path8.default.resolve(session.root, ...relativePath.split("/"));
|
|
9282
|
+
const relative = import_path8.default.relative(session.root, absolute);
|
|
9283
|
+
if (relative.startsWith(`..${import_path8.default.sep}`) || import_path8.default.isAbsolute(relative)) {
|
|
9284
|
+
import_coc17.window.showWarningMessage(`Working tree path is outside repository: ${escapeDisplay(relativePath)}`);
|
|
9285
|
+
return;
|
|
9286
|
+
}
|
|
9287
|
+
let stat;
|
|
9288
|
+
try {
|
|
9289
|
+
stat = await import_fs4.default.promises.stat(absolute);
|
|
9290
|
+
} catch (_e) {
|
|
9291
|
+
import_coc17.window.showWarningMessage(`Working tree file not found: ${escapeDisplay(relativePath)}`);
|
|
9292
|
+
return;
|
|
9293
|
+
}
|
|
9294
|
+
if (!stat.isFile()) {
|
|
9295
|
+
import_coc17.window.showWarningMessage(`Working tree path is not a file: ${escapeDisplay(relativePath)}`);
|
|
9296
|
+
return;
|
|
9297
|
+
}
|
|
9298
|
+
const moved = await import_coc17.workspace.nvim.call("win_gotoid", [session.targetWinId]);
|
|
9299
|
+
if (!moved) await import_coc17.workspace.nvim.command("new");
|
|
9300
|
+
try {
|
|
9301
|
+
await import_coc17.workspace.openResource(import_coc17.Uri.file(absolute).toString());
|
|
9302
|
+
} catch (e) {
|
|
9303
|
+
import_coc17.window.showErrorMessage(`Failed to open working tree file for ${node.comparison.commit.shortSha}: ${e.message}`);
|
|
9304
|
+
}
|
|
9305
|
+
}
|
|
9306
|
+
async selectParent(node) {
|
|
9307
|
+
var _a, _b, _c;
|
|
9308
|
+
const session = this.session;
|
|
9309
|
+
if (!session || node.comparison.commit.parents.length < 2) return;
|
|
9310
|
+
const choices = node.comparison.commit.parents.map((sha, index) => `${index + 1}/${node.comparison.commit.parents.length} ${sha.slice(0, 12)}`);
|
|
9311
|
+
const selected = await import_coc17.window.showQuickPick(choices, { placeHolder: "Select parent commit" });
|
|
9312
|
+
if (!selected) return;
|
|
9313
|
+
const parentIndex = choices.indexOf(selected);
|
|
9314
|
+
if (parentIndex < 0) return;
|
|
9315
|
+
const parentSha = node.comparison.commit.parents[parentIndex];
|
|
9316
|
+
(_a = session.token) == null ? void 0 : _a.cancel();
|
|
9317
|
+
(_b = session.token) == null ? void 0 : _b.dispose();
|
|
9318
|
+
const token = new import_coc17.CancellationTokenSource();
|
|
9319
|
+
session.token = token;
|
|
9320
|
+
try {
|
|
9321
|
+
await assertParentAvailable(this.manager.git, session.root, parentSha, token.token);
|
|
9322
|
+
} catch (e) {
|
|
9323
|
+
if (!token.token.isCancellationRequested) {
|
|
9324
|
+
import_coc17.window.showErrorMessage(`Parent commit is not available in this shallow repository: ${parentSha.slice(0, 12)}`);
|
|
9325
|
+
}
|
|
9326
|
+
token.dispose();
|
|
9327
|
+
if (session.token === token) session.token = void 0;
|
|
9328
|
+
return;
|
|
9329
|
+
}
|
|
9330
|
+
try {
|
|
9331
|
+
const key = parentSha;
|
|
9332
|
+
let comparison = session.cache.get(key);
|
|
9333
|
+
if (!comparison) {
|
|
9334
|
+
comparison = await loadComparisonForCommit(this.manager.git, session.root, node.comparison.commit, parentIndex, token.token);
|
|
9335
|
+
session.cache.set(key, comparison);
|
|
9336
|
+
}
|
|
9337
|
+
if (token.token.isCancellationRequested || this.session !== session) return;
|
|
9338
|
+
session.comparison = comparison;
|
|
9339
|
+
session.provider.setComparison(comparison);
|
|
9340
|
+
session.view.description = comparisonDescription(comparison);
|
|
9341
|
+
} catch (e) {
|
|
9342
|
+
if (!token.token.isCancellationRequested) {
|
|
9343
|
+
const message = (_c = e == null ? void 0 : e.message) != null ? _c : "";
|
|
9344
|
+
import_coc17.window.showErrorMessage(`Failed to load parent ${parentSha.slice(0, 12)} for ${node.comparison.commit.shortSha}: ${message}`);
|
|
9345
|
+
}
|
|
9346
|
+
} finally {
|
|
9347
|
+
token.dispose();
|
|
9348
|
+
if (session.token === token) session.token = void 0;
|
|
9349
|
+
}
|
|
9350
|
+
}
|
|
9351
|
+
disposeSession() {
|
|
9352
|
+
var _a, _b;
|
|
9353
|
+
const session = this.session;
|
|
9354
|
+
if (!session) return;
|
|
9355
|
+
this.session = void 0;
|
|
9356
|
+
(_a = session.token) == null ? void 0 : _a.cancel();
|
|
9357
|
+
(_b = session.token) == null ? void 0 : _b.dispose();
|
|
9358
|
+
session.provider.dispose();
|
|
9359
|
+
session.view.dispose();
|
|
9360
|
+
}
|
|
9361
|
+
dispose() {
|
|
9362
|
+
this.disposeSession();
|
|
9363
|
+
}
|
|
9364
|
+
};
|
|
9365
|
+
|
|
9366
|
+
// src/tree/statusFiles.ts
|
|
9367
|
+
var import_fs5 = __toESM(require("fs"));
|
|
9368
|
+
var import_path9 = __toESM(require("path"));
|
|
9369
|
+
var import_coc18 = require("coc.nvim");
|
|
9370
|
+
function emptyAggregate2() {
|
|
9371
|
+
return { fileCount: 0, stagedCount: 0, unstagedCount: 0, untrackedCount: 0, conflictCount: 0 };
|
|
9372
|
+
}
|
|
9373
|
+
function isUntracked(entry) {
|
|
9374
|
+
return entry.index === "?" && entry.tree === "?";
|
|
9375
|
+
}
|
|
9376
|
+
function isConflict(entry) {
|
|
9377
|
+
return entry.index === "U" || entry.tree === "U" || entry.index + entry.tree === "AA" || entry.index + entry.tree === "DD";
|
|
9378
|
+
}
|
|
9379
|
+
function isStaged(entry) {
|
|
9380
|
+
return entry.index !== " " && entry.index !== "?" && entry.index !== "!";
|
|
9381
|
+
}
|
|
9382
|
+
function isUnstaged(entry) {
|
|
9383
|
+
return entry.tree !== " " && entry.tree !== "?" && entry.tree !== "!";
|
|
9384
|
+
}
|
|
9385
|
+
function addFileAggregate2(target, entry) {
|
|
9386
|
+
target.fileCount++;
|
|
9387
|
+
if (isStaged(entry)) target.stagedCount++;
|
|
9388
|
+
if (isUnstaged(entry)) target.unstagedCount++;
|
|
9389
|
+
if (isUntracked(entry)) target.untrackedCount++;
|
|
9390
|
+
if (isConflict(entry)) target.conflictCount++;
|
|
9391
|
+
}
|
|
9392
|
+
function addAggregate2(target, source) {
|
|
9393
|
+
target.fileCount += source.fileCount;
|
|
9394
|
+
target.stagedCount += source.stagedCount;
|
|
9395
|
+
target.unstagedCount += source.unstagedCount;
|
|
9396
|
+
target.untrackedCount += source.untrackedCount;
|
|
9397
|
+
target.conflictCount += source.conflictCount;
|
|
9398
|
+
}
|
|
9399
|
+
function compareNodes2(left, right) {
|
|
9400
|
+
if (left.kind === "directory" && right.kind !== "directory") return -1;
|
|
9401
|
+
if (left.kind !== "directory" && right.kind === "directory") return 1;
|
|
9402
|
+
return left.relativePath.localeCompare(right.relativePath);
|
|
9403
|
+
}
|
|
9404
|
+
function buildStatusTree(rootPath, entries) {
|
|
9405
|
+
const root = {
|
|
9406
|
+
...emptyAggregate2(),
|
|
9407
|
+
kind: "root",
|
|
9408
|
+
id: `${rootPath}\0root`,
|
|
9409
|
+
name: import_path9.default.basename(rootPath) || rootPath,
|
|
9410
|
+
relativePath: "",
|
|
9411
|
+
parent: void 0,
|
|
9412
|
+
root: rootPath,
|
|
9413
|
+
children: []
|
|
9414
|
+
};
|
|
9415
|
+
const directories = /* @__PURE__ */ new Map();
|
|
9416
|
+
const ensureDirectory = (segments) => {
|
|
9417
|
+
if (!segments.length) return root;
|
|
9418
|
+
const relativePath = segments.join("/");
|
|
9419
|
+
const existing = directories.get(relativePath);
|
|
9420
|
+
if (existing) return existing;
|
|
9421
|
+
const parent = ensureDirectory(segments.slice(0, -1));
|
|
9422
|
+
const directory = {
|
|
9423
|
+
...emptyAggregate2(),
|
|
9424
|
+
kind: "directory",
|
|
9425
|
+
id: `${rootPath}\0directory\0${relativePath}`,
|
|
9426
|
+
name: segments[segments.length - 1],
|
|
9427
|
+
relativePath,
|
|
9428
|
+
parent,
|
|
9429
|
+
children: []
|
|
9430
|
+
};
|
|
9431
|
+
directories.set(relativePath, directory);
|
|
9432
|
+
parent.children.push(directory);
|
|
9433
|
+
return directory;
|
|
9434
|
+
};
|
|
9435
|
+
for (const entry of entries) {
|
|
9436
|
+
const segments = entry.relative.split("/");
|
|
9437
|
+
const name = segments.pop();
|
|
9438
|
+
if (!name) continue;
|
|
9439
|
+
const parent = ensureDirectory(segments);
|
|
9440
|
+
parent.children.push({
|
|
9441
|
+
kind: "file",
|
|
9442
|
+
id: `${rootPath}\0file\0${entry.relative}`,
|
|
9443
|
+
name,
|
|
9444
|
+
relativePath: entry.relative,
|
|
9445
|
+
parent,
|
|
9446
|
+
entry
|
|
9447
|
+
});
|
|
9448
|
+
}
|
|
9449
|
+
const aggregate = (node) => {
|
|
9450
|
+
const own = emptyAggregate2();
|
|
9451
|
+
for (const child of node.children) {
|
|
9452
|
+
if (child.kind === "file") addFileAggregate2(own, child.entry);
|
|
9453
|
+
else {
|
|
9454
|
+
aggregate(child);
|
|
9455
|
+
addAggregate2(own, child);
|
|
9456
|
+
}
|
|
9457
|
+
}
|
|
9458
|
+
Object.assign(node, own);
|
|
9459
|
+
node.children.sort(compareNodes2);
|
|
9460
|
+
};
|
|
9461
|
+
aggregate(root);
|
|
9462
|
+
return root;
|
|
9463
|
+
}
|
|
9464
|
+
function firstFile(node) {
|
|
9465
|
+
for (const child of node.children) {
|
|
9466
|
+
if (child.kind === "file") return child;
|
|
9467
|
+
const file = firstFile(child);
|
|
9468
|
+
if (file) return file;
|
|
9469
|
+
}
|
|
9470
|
+
return void 0;
|
|
9471
|
+
}
|
|
9472
|
+
function escapeDisplay2(value) {
|
|
9473
|
+
return value.replace(/\r/g, "\\r").replace(/\n/g, "\\n").replace(/\t/g, "\\t");
|
|
9474
|
+
}
|
|
9475
|
+
var STATUS_NAMES = {
|
|
9476
|
+
M: "Modified",
|
|
9477
|
+
A: "Added",
|
|
9478
|
+
D: "Deleted",
|
|
9479
|
+
R: "Renamed",
|
|
9480
|
+
C: "Copied",
|
|
9481
|
+
T: "Type changed",
|
|
9482
|
+
U: "Unmerged"
|
|
9483
|
+
};
|
|
9484
|
+
function aggregateDescription(value) {
|
|
9485
|
+
const parts = [`${value.fileCount} file${value.fileCount === 1 ? "" : "s"}`];
|
|
9486
|
+
if (value.stagedCount) parts.push(`${value.stagedCount} staged`);
|
|
9487
|
+
if (value.unstagedCount) parts.push(`${value.unstagedCount} unstaged`);
|
|
9488
|
+
if (value.untrackedCount) parts.push(`${value.untrackedCount} untracked`);
|
|
9489
|
+
if (value.conflictCount) parts.push(`${value.conflictCount} conflicted`);
|
|
9490
|
+
return parts.join(" \xB7 ");
|
|
9491
|
+
}
|
|
9492
|
+
function fileDescription2(entry) {
|
|
9493
|
+
var _a, _b;
|
|
9494
|
+
const code = `[${entry.index}${entry.tree}]`;
|
|
9495
|
+
if (isUntracked(entry)) return `${code} \xB7 Untracked`;
|
|
9496
|
+
if (entry.index === "!" && entry.tree === "!") return `${code} \xB7 Ignored`;
|
|
9497
|
+
const parts = [code];
|
|
9498
|
+
if (isStaged(entry)) parts.push(`staged: ${(_a = STATUS_NAMES[entry.index]) != null ? _a : entry.index}`);
|
|
9499
|
+
if (isUnstaged(entry)) parts.push(`unstaged: ${(_b = STATUS_NAMES[entry.tree]) != null ? _b : entry.tree}`);
|
|
9500
|
+
if (isConflict(entry) && !parts.some((part) => part.includes("Unmerged"))) parts.push("conflicted");
|
|
9501
|
+
return parts.join(" \xB7 ");
|
|
8453
9502
|
}
|
|
9503
|
+
function statusIcon2(entry) {
|
|
9504
|
+
if (isConflict(entry)) return { text: "!", hlGroup: "Error" };
|
|
9505
|
+
if (isUntracked(entry)) return { text: "?", hlGroup: "Comment" };
|
|
9506
|
+
const status = entry.tree !== " " ? entry.tree : entry.index;
|
|
9507
|
+
if (status === "A" || status === "C") return { text: "+", hlGroup: "DiffAdd" };
|
|
9508
|
+
if (status === "D") return { text: "-", hlGroup: "DiffDelete" };
|
|
9509
|
+
if (status === "R") return { text: "R", hlGroup: "DiffChange" };
|
|
9510
|
+
return { text: "~", hlGroup: "DiffChange" };
|
|
9511
|
+
}
|
|
9512
|
+
function toggleCommand(node) {
|
|
9513
|
+
return { command: "git.statusFiles.toggle", title: "Toggle directory", arguments: [node] };
|
|
9514
|
+
}
|
|
9515
|
+
var StatusFilesProvider = class {
|
|
9516
|
+
constructor(rootPath, entries, actions) {
|
|
9517
|
+
this.actions = actions;
|
|
9518
|
+
this.emitter = new import_coc18.Emitter();
|
|
9519
|
+
this.onDidChangeTreeData = this.emitter.event;
|
|
9520
|
+
this.root = buildStatusTree(rootPath, entries);
|
|
9521
|
+
}
|
|
9522
|
+
setEntries(entries) {
|
|
9523
|
+
this.root = buildStatusTree(this.root.root, entries);
|
|
9524
|
+
this.emitter.fire(void 0);
|
|
9525
|
+
}
|
|
9526
|
+
getTreeItem(element) {
|
|
9527
|
+
if (element.kind === "root") {
|
|
9528
|
+
const item2 = new import_coc18.TreeItem(escapeDisplay2(element.name), element.children.length ? import_coc18.TreeItemCollapsibleState.Expanded : import_coc18.TreeItemCollapsibleState.None);
|
|
9529
|
+
item2.id = element.id;
|
|
9530
|
+
item2.description = aggregateDescription(element);
|
|
9531
|
+
item2.tooltip = escapeDisplay2(element.root);
|
|
9532
|
+
item2.command = { command: "git.statusFiles.refresh", title: "Refresh Git status" };
|
|
9533
|
+
return item2;
|
|
9534
|
+
}
|
|
9535
|
+
if (element.kind === "directory") {
|
|
9536
|
+
const item2 = new import_coc18.TreeItem(escapeDisplay2(element.name), element.children.length ? import_coc18.TreeItemCollapsibleState.Expanded : import_coc18.TreeItemCollapsibleState.None);
|
|
9537
|
+
item2.id = element.id;
|
|
9538
|
+
item2.description = aggregateDescription(element);
|
|
9539
|
+
item2.tooltip = escapeDisplay2(element.relativePath);
|
|
9540
|
+
item2.command = toggleCommand(element);
|
|
9541
|
+
return item2;
|
|
9542
|
+
}
|
|
9543
|
+
const item = new import_coc18.TreeItem(escapeDisplay2(element.name), import_coc18.TreeItemCollapsibleState.None);
|
|
9544
|
+
item.id = element.id;
|
|
9545
|
+
item.icon = statusIcon2(element.entry);
|
|
9546
|
+
item.description = fileDescription2(element.entry);
|
|
9547
|
+
item.tooltip = `${escapeDisplay2(element.relativePath)}
|
|
9548
|
+
${fileDescription2(element.entry)}`;
|
|
9549
|
+
item.command = { command: "git.statusFiles.open", title: "Open file", arguments: [element] };
|
|
9550
|
+
return item;
|
|
9551
|
+
}
|
|
9552
|
+
getChildren(element) {
|
|
9553
|
+
if (!element) return [this.root];
|
|
9554
|
+
return element.kind === "file" ? [] : element.children;
|
|
9555
|
+
}
|
|
9556
|
+
getParent(element) {
|
|
9557
|
+
return element.parent;
|
|
9558
|
+
}
|
|
9559
|
+
resolveActions(_item, element) {
|
|
9560
|
+
if (element.kind === "root") return [{ title: "Refresh", handler: () => this.actions.refresh() }];
|
|
9561
|
+
if (element.kind === "directory") return [{ title: "Copy directory path", handler: (node) => this.actions.copyPath(node) }];
|
|
9562
|
+
const actions = [
|
|
9563
|
+
{ title: "Open file", handler: (node) => this.actions.openFile(node) },
|
|
9564
|
+
{ title: "Copy relative path", handler: (node) => this.actions.copyPath(node) }
|
|
9565
|
+
];
|
|
9566
|
+
const entry = element.entry;
|
|
9567
|
+
if (isUntracked(entry) || isUnstaged(entry)) actions.push({ title: "Add", handler: (node) => this.actions.addFile(node) });
|
|
9568
|
+
if (isStaged(entry)) actions.push({ title: "Restore staged changes", handler: (node) => this.actions.restoreStagedFile(node) });
|
|
9569
|
+
if (isUnstaged(entry) && !isUntracked(entry) && !isConflict(entry)) {
|
|
9570
|
+
actions.push({ title: "Restore working tree changes", handler: (node) => this.actions.restoreWorkingTreeFile(node) });
|
|
9571
|
+
}
|
|
9572
|
+
return actions;
|
|
9573
|
+
}
|
|
9574
|
+
dispose() {
|
|
9575
|
+
this.emitter.dispose();
|
|
9576
|
+
}
|
|
9577
|
+
};
|
|
9578
|
+
var StatusFilesController = class {
|
|
9579
|
+
constructor(manager, commitDocuments) {
|
|
9580
|
+
this.manager = manager;
|
|
9581
|
+
this.commitDocuments = commitDocuments;
|
|
9582
|
+
}
|
|
9583
|
+
async open(requestedRoot) {
|
|
9584
|
+
let root = requestedRoot;
|
|
9585
|
+
if (!root) root = await this.manager.resolveGitRootFromBufferOrCwd(await import_coc18.workspace.nvim.call("bufnr", ["%"]));
|
|
9586
|
+
if (!root) {
|
|
9587
|
+
import_coc18.window.showWarningMessage("Can't resolve git repository for current buffer or cwd.");
|
|
9588
|
+
return;
|
|
9589
|
+
}
|
|
9590
|
+
try {
|
|
9591
|
+
root = await this.manager.git.getRepositoryRoot(root);
|
|
9592
|
+
} catch (_e) {
|
|
9593
|
+
import_coc18.window.showWarningMessage("Can't resolve git repository for current buffer or cwd.");
|
|
9594
|
+
return;
|
|
9595
|
+
}
|
|
9596
|
+
const targetWinId = await import_coc18.workspace.nvim.call("win_getid");
|
|
9597
|
+
this.disposeSession();
|
|
9598
|
+
try {
|
|
9599
|
+
const entries = await this.loadEntries(root);
|
|
9600
|
+
const provider = new StatusFilesProvider(root, entries, this.actions);
|
|
9601
|
+
const view = import_coc18.window.createTreeView("git.statusFiles", {
|
|
9602
|
+
treeDataProvider: provider,
|
|
9603
|
+
enableFilter: true,
|
|
9604
|
+
winfixwidth: true,
|
|
9605
|
+
bufhidden: "wipe",
|
|
9606
|
+
canSelectMany: false,
|
|
9607
|
+
autoWidth: true
|
|
9608
|
+
});
|
|
9609
|
+
view.title = "Git Status";
|
|
9610
|
+
view.description = aggregateDescription(buildStatusTree(root, entries));
|
|
9611
|
+
this.session = { root, provider, view, targetWinId };
|
|
9612
|
+
await view.show(import_coc18.workspace.getConfiguration("git").get("statusTree.splitCommand", "belowright 40vs"));
|
|
9613
|
+
const file = firstFile(provider.getChildren()[0]);
|
|
9614
|
+
if (file) await view.reveal(file, { select: true, focus: true, expand: true });
|
|
9615
|
+
view.onDidChangeVisibility((event) => {
|
|
9616
|
+
var _a;
|
|
9617
|
+
if (!event.visible && ((_a = this.session) == null ? void 0 : _a.view) === view) this.disposeSession();
|
|
9618
|
+
});
|
|
9619
|
+
} catch (e) {
|
|
9620
|
+
this.disposeSession();
|
|
9621
|
+
import_coc18.window.showErrorMessage(`Failed to open Git Status: ${e.message}`);
|
|
9622
|
+
}
|
|
9623
|
+
}
|
|
9624
|
+
async toggle(node) {
|
|
9625
|
+
if (!node || typeof node !== "object") return;
|
|
9626
|
+
const element = node;
|
|
9627
|
+
if (element.kind !== "root" && element.kind !== "directory") return;
|
|
9628
|
+
const configuredKey = import_coc18.workspace.getConfiguration("tree").get("key.toggle", "t");
|
|
9629
|
+
const key = configuredKey.startsWith("<") && configuredKey.endsWith(">") ? `\\${configuredKey}` : configuredKey;
|
|
9630
|
+
const escaped = key.replace(/\\/g, "\\\\").replace(/"/g, '\\"');
|
|
9631
|
+
await import_coc18.workspace.nvim.call("eval", [`feedkeys("${escaped}", "in")`]);
|
|
9632
|
+
}
|
|
9633
|
+
async refresh() {
|
|
9634
|
+
const session = this.session;
|
|
9635
|
+
if (!session) return;
|
|
9636
|
+
try {
|
|
9637
|
+
const entries = await this.loadEntries(session.root);
|
|
9638
|
+
if (this.session !== session) return;
|
|
9639
|
+
session.provider.setEntries(entries);
|
|
9640
|
+
session.view.description = aggregateDescription(buildStatusTree(session.root, entries));
|
|
9641
|
+
} catch (e) {
|
|
9642
|
+
import_coc18.window.showErrorMessage(`Failed to refresh Git Status: ${e.message}`);
|
|
9643
|
+
}
|
|
9644
|
+
}
|
|
9645
|
+
close() {
|
|
9646
|
+
this.disposeSession();
|
|
9647
|
+
}
|
|
9648
|
+
async openFile(node) {
|
|
9649
|
+
var _a, _b, _c;
|
|
9650
|
+
const session = this.session;
|
|
9651
|
+
if (!session) return;
|
|
9652
|
+
const absolute = import_path9.default.resolve(session.root, ...node.relativePath.split("/"));
|
|
9653
|
+
const relative = import_path9.default.relative(session.root, absolute);
|
|
9654
|
+
if (relative.startsWith(`..${import_path9.default.sep}`) || import_path9.default.isAbsolute(relative)) {
|
|
9655
|
+
import_coc18.window.showWarningMessage(`Working tree path is outside repository: ${escapeDisplay2(node.relativePath)}`);
|
|
9656
|
+
return;
|
|
9657
|
+
}
|
|
9658
|
+
let stat;
|
|
9659
|
+
try {
|
|
9660
|
+
stat = await import_fs5.default.promises.stat(absolute);
|
|
9661
|
+
} catch (error) {
|
|
9662
|
+
if (error.code !== "ENOENT" && error.code !== "ENOTDIR") {
|
|
9663
|
+
import_coc18.window.showErrorMessage(`Failed to inspect working tree path: ${escapeDisplay2(node.relativePath)}`);
|
|
9664
|
+
return;
|
|
9665
|
+
}
|
|
9666
|
+
try {
|
|
9667
|
+
await this.commitDocuments.openRevision(session.root, "HEAD", node.relativePath, session.targetWinId);
|
|
9668
|
+
} catch (_error) {
|
|
9669
|
+
import_coc18.window.showWarningMessage(`File not found in working tree or HEAD: ${escapeDisplay2(node.relativePath)}`);
|
|
9670
|
+
}
|
|
9671
|
+
return;
|
|
9672
|
+
}
|
|
9673
|
+
if (!stat.isFile()) {
|
|
9674
|
+
import_coc18.window.showWarningMessage(`Working tree path is not a file: ${escapeDisplay2(node.relativePath)}`);
|
|
9675
|
+
return;
|
|
9676
|
+
}
|
|
9677
|
+
let line = 1;
|
|
9678
|
+
try {
|
|
9679
|
+
const groups = await this.manager.getDiffAllForRoot(session.root, 0 /* All */);
|
|
9680
|
+
line = Math.max(1, (_c = (_b = (_a = groups.get(node.relativePath)) == null ? void 0 : _a[0]) == null ? void 0 : _b.start) != null ? _c : 1);
|
|
9681
|
+
} catch (_e) {
|
|
9682
|
+
}
|
|
9683
|
+
const moved = await import_coc18.workspace.nvim.call("win_gotoid", [session.targetWinId]);
|
|
9684
|
+
if (!moved) await import_coc18.workspace.nvim.command("new");
|
|
9685
|
+
try {
|
|
9686
|
+
await import_coc18.workspace.jumpTo(import_coc18.Uri.file(absolute), import_coc18.Position.create(line - 1, 0));
|
|
9687
|
+
} catch (e) {
|
|
9688
|
+
import_coc18.window.showErrorMessage(`Failed to open working tree file: ${e.message}`);
|
|
9689
|
+
}
|
|
9690
|
+
}
|
|
9691
|
+
async addFile(node) {
|
|
9692
|
+
await this.updateFile(node, ["add", "--", node.relativePath]);
|
|
9693
|
+
}
|
|
9694
|
+
async restoreStagedFile(node) {
|
|
9695
|
+
await this.updateFile(node, ["reset", "--", node.relativePath]);
|
|
9696
|
+
}
|
|
9697
|
+
async restoreWorkingTreeFile(node) {
|
|
9698
|
+
await this.updateFile(node, ["checkout", "--", node.relativePath]);
|
|
9699
|
+
}
|
|
9700
|
+
get actions() {
|
|
9701
|
+
return {
|
|
9702
|
+
refresh: () => this.refresh(),
|
|
9703
|
+
openFile: (node) => this.openFile(node),
|
|
9704
|
+
addFile: (node) => this.addFile(node),
|
|
9705
|
+
restoreStagedFile: (node) => this.restoreStagedFile(node),
|
|
9706
|
+
restoreWorkingTreeFile: (node) => this.restoreWorkingTreeFile(node),
|
|
9707
|
+
copyPath: (node) => import_coc18.workspace.nvim.call("setreg", ["+", node.relativePath]).then(() => void 0)
|
|
9708
|
+
};
|
|
9709
|
+
}
|
|
9710
|
+
async updateFile(node, args) {
|
|
9711
|
+
const session = this.session;
|
|
9712
|
+
if (!session) return;
|
|
9713
|
+
try {
|
|
9714
|
+
await this.manager.git.exec(session.root, args);
|
|
9715
|
+
await this.refresh();
|
|
9716
|
+
} catch (e) {
|
|
9717
|
+
import_coc18.window.showErrorMessage(`Failed to update Git status for ${escapeDisplay2(node.relativePath)}: ${e.message}`);
|
|
9718
|
+
}
|
|
9719
|
+
}
|
|
9720
|
+
async loadEntries(root) {
|
|
9721
|
+
const result = await this.manager.git.exec(root, ["status", "--porcelain=v1", "-z", "-uall"]);
|
|
9722
|
+
return parseStatusEntries(result.stdout);
|
|
9723
|
+
}
|
|
9724
|
+
disposeSession() {
|
|
9725
|
+
const session = this.session;
|
|
9726
|
+
if (!session) return;
|
|
9727
|
+
this.session = void 0;
|
|
9728
|
+
session.provider.dispose();
|
|
9729
|
+
session.view.dispose();
|
|
9730
|
+
}
|
|
9731
|
+
dispose() {
|
|
9732
|
+
this.close();
|
|
9733
|
+
}
|
|
9734
|
+
};
|
|
8454
9735
|
|
|
8455
9736
|
// src/index.ts
|
|
8456
9737
|
async function activate(context) {
|
|
8457
9738
|
var _a;
|
|
8458
|
-
const config =
|
|
9739
|
+
const config = import_coc19.workspace.getConfiguration("git");
|
|
8459
9740
|
const { subscriptions } = context;
|
|
8460
9741
|
let gitInfo;
|
|
8461
9742
|
try {
|
|
8462
9743
|
let pathHint = config.get("command", "git");
|
|
8463
|
-
gitInfo = await findGit(pathHint, (
|
|
9744
|
+
gitInfo = await findGit(pathHint, (path10) => context.logger.info(`Looking for git in: ${path10}`));
|
|
8464
9745
|
} catch (e) {
|
|
8465
|
-
|
|
9746
|
+
import_coc19.window.showErrorMessage("git command required for coc-git");
|
|
8466
9747
|
return;
|
|
8467
9748
|
}
|
|
8468
|
-
const virtualTextSrcId = await
|
|
8469
|
-
const conflictSrcId = await
|
|
8470
|
-
const
|
|
9749
|
+
const virtualTextSrcId = await import_coc19.workspace.nvim.createNamespace("coc-git-virtual");
|
|
9750
|
+
const conflictSrcId = await import_coc19.workspace.nvim.createNamespace("coc-git-conflicts");
|
|
9751
|
+
const commitDocumentSrcId = await import_coc19.workspace.nvim.createNamespace("coc-git-commit-document");
|
|
9752
|
+
const { nvim } = import_coc19.workspace;
|
|
8471
9753
|
const service = new GitService(gitInfo);
|
|
8472
9754
|
const manager = new DocumentManager(nvim, service, virtualTextSrcId, conflictSrcId);
|
|
8473
9755
|
subscriptions.push(manager);
|
|
9756
|
+
const commitDocuments = new CommitDocumentProvider(service.git, commitDocumentSrcId);
|
|
9757
|
+
subscriptions.push(commitDocuments);
|
|
9758
|
+
subscriptions.push(import_coc19.workspace.registerTextDocumentContentProvider(COMMIT_DOCUMENT_SCHEME, commitDocuments));
|
|
9759
|
+
nvim.command("highlight default link CocGitCommitAdd DiffAdd", true);
|
|
9760
|
+
nvim.command("highlight default link CocGitCommitDelete DiffDelete", true);
|
|
9761
|
+
const commitFiles = new CommitFilesController(manager);
|
|
9762
|
+
subscriptions.push(commitFiles);
|
|
9763
|
+
const statusFiles = new StatusFilesController(manager, commitDocuments);
|
|
9764
|
+
subscriptions.push(statusFiles);
|
|
8474
9765
|
addSource(context, service);
|
|
8475
|
-
subscriptions.push(
|
|
9766
|
+
subscriptions.push(import_coc19.commands.registerCommand("git.refresh", () => {
|
|
8476
9767
|
manager.refresh();
|
|
8477
9768
|
}));
|
|
8478
|
-
subscriptions.push(
|
|
8479
|
-
await
|
|
9769
|
+
subscriptions.push(import_coc19.commands.registerCommand("git.statusTree", async () => {
|
|
9770
|
+
await statusFiles.open();
|
|
9771
|
+
}));
|
|
9772
|
+
subscriptions.push(import_coc19.commands.registerCommand("git.statusFiles.open", async (node) => {
|
|
9773
|
+
await statusFiles.openFile(node);
|
|
9774
|
+
}, void 0, true));
|
|
9775
|
+
subscriptions.push(import_coc19.commands.registerCommand("git.statusFiles.add", async (node) => {
|
|
9776
|
+
await statusFiles.addFile(node);
|
|
9777
|
+
}, void 0, true));
|
|
9778
|
+
subscriptions.push(import_coc19.commands.registerCommand("git.statusFiles.restoreStaged", async (node) => {
|
|
9779
|
+
await statusFiles.restoreStagedFile(node);
|
|
9780
|
+
}, void 0, true));
|
|
9781
|
+
subscriptions.push(import_coc19.commands.registerCommand("git.statusFiles.restoreWorkingTree", async (node) => {
|
|
9782
|
+
await statusFiles.restoreWorkingTreeFile(node);
|
|
9783
|
+
}, void 0, true));
|
|
9784
|
+
subscriptions.push(import_coc19.commands.registerCommand("git.statusFiles.refresh", async () => {
|
|
9785
|
+
await statusFiles.refresh();
|
|
9786
|
+
}, void 0, true));
|
|
9787
|
+
subscriptions.push(import_coc19.commands.registerCommand("git.statusFiles.toggle", async (node) => {
|
|
9788
|
+
await statusFiles.toggle(node);
|
|
9789
|
+
}, void 0, true));
|
|
9790
|
+
subscriptions.push(import_coc19.commands.registerCommand("git.statusFiles.close", () => {
|
|
9791
|
+
statusFiles.close();
|
|
9792
|
+
}, void 0, true));
|
|
9793
|
+
subscriptions.push(import_coc19.workspace.registerKeymap(["n"], "git-nextchunk", async () => {
|
|
9794
|
+
if (!await commitDocuments.nextChunk()) await manager.nextChunk();
|
|
8480
9795
|
}, { sync: false }));
|
|
8481
|
-
subscriptions.push(
|
|
8482
|
-
await manager.prevChunk();
|
|
9796
|
+
subscriptions.push(import_coc19.workspace.registerKeymap(["n"], "git-prevchunk", async () => {
|
|
9797
|
+
if (!await commitDocuments.prevChunk()) await manager.prevChunk();
|
|
8483
9798
|
}, { sync: false }));
|
|
8484
|
-
subscriptions.push(
|
|
9799
|
+
subscriptions.push(import_coc19.workspace.registerKeymap(["n"], "git-nextconflict", async () => {
|
|
8485
9800
|
await manager.nextConflict();
|
|
8486
9801
|
}, { sync: false }));
|
|
8487
|
-
subscriptions.push(
|
|
9802
|
+
subscriptions.push(import_coc19.workspace.registerKeymap(["n"], "git-prevconflict", async () => {
|
|
8488
9803
|
await manager.prevConflict();
|
|
8489
9804
|
}, { sync: false }));
|
|
8490
|
-
subscriptions.push(
|
|
9805
|
+
subscriptions.push(import_coc19.workspace.registerKeymap(["n"], "git-keepcurrent", async () => {
|
|
8491
9806
|
await manager.keepCurrent();
|
|
8492
9807
|
}, { sync: false }));
|
|
8493
|
-
subscriptions.push(
|
|
9808
|
+
subscriptions.push(import_coc19.workspace.registerKeymap(["n"], "git-keepincoming", async () => {
|
|
8494
9809
|
await manager.keepIncoming();
|
|
8495
9810
|
}, { sync: false }));
|
|
8496
|
-
subscriptions.push(
|
|
9811
|
+
subscriptions.push(import_coc19.workspace.registerKeymap(["n"], "git-keepboth", async () => {
|
|
8497
9812
|
await manager.keepBoth();
|
|
8498
9813
|
}, { sync: false }));
|
|
8499
|
-
subscriptions.push(
|
|
9814
|
+
subscriptions.push(import_coc19.workspace.registerKeymap(["n"], "git-chunkinfo", async () => {
|
|
8500
9815
|
await manager.chunkInfo();
|
|
8501
9816
|
}, { sync: false }));
|
|
8502
|
-
subscriptions.push(
|
|
9817
|
+
subscriptions.push(import_coc19.workspace.registerKeymap(["n"], "git-commit", async () => {
|
|
8503
9818
|
await manager.showCommit();
|
|
8504
9819
|
}, { sync: false }));
|
|
8505
|
-
subscriptions.push(
|
|
9820
|
+
subscriptions.push(import_coc19.workspace.registerKeymap(["n"], "git-showblamedoc", async () => {
|
|
8506
9821
|
await manager.showBlameDoc();
|
|
8507
9822
|
}, { sync: false }));
|
|
8508
|
-
subscriptions.push(
|
|
8509
|
-
await manager.nextChunk();
|
|
9823
|
+
subscriptions.push(import_coc19.commands.registerCommand("git.nextChunk", async () => {
|
|
9824
|
+
if (!await commitDocuments.nextChunk()) await manager.nextChunk();
|
|
8510
9825
|
}));
|
|
8511
|
-
subscriptions.push(
|
|
8512
|
-
await manager.prevChunk();
|
|
9826
|
+
subscriptions.push(import_coc19.commands.registerCommand("git.prevChunk", async () => {
|
|
9827
|
+
if (!await commitDocuments.prevChunk()) await manager.prevChunk();
|
|
8513
9828
|
}));
|
|
8514
|
-
subscriptions.push(
|
|
9829
|
+
subscriptions.push(import_coc19.commands.registerCommand("git.keepCurrent", async () => {
|
|
8515
9830
|
await manager.keepCurrent();
|
|
8516
9831
|
}));
|
|
8517
|
-
subscriptions.push(
|
|
9832
|
+
subscriptions.push(import_coc19.commands.registerCommand("git.keepIncoming", async () => {
|
|
8518
9833
|
await manager.keepIncoming();
|
|
8519
9834
|
}));
|
|
8520
|
-
subscriptions.push(
|
|
9835
|
+
subscriptions.push(import_coc19.commands.registerCommand("git.keepBoth", async () => {
|
|
8521
9836
|
await manager.keepBoth();
|
|
8522
9837
|
}));
|
|
8523
|
-
subscriptions.push(
|
|
9838
|
+
subscriptions.push(import_coc19.commands.registerCommand("git.chunkInfo", async () => {
|
|
8524
9839
|
await manager.chunkInfo();
|
|
8525
9840
|
}));
|
|
8526
|
-
subscriptions.push(
|
|
9841
|
+
subscriptions.push(import_coc19.commands.registerCommand("git.allChunkInfo", async () => {
|
|
8527
9842
|
return await manager.allChunkInfo();
|
|
8528
9843
|
}));
|
|
8529
|
-
subscriptions.push(
|
|
9844
|
+
subscriptions.push(import_coc19.commands.registerCommand("git.chunkStage", async () => {
|
|
8530
9845
|
await manager.chunkStage();
|
|
8531
9846
|
}));
|
|
8532
|
-
subscriptions.push(
|
|
9847
|
+
subscriptions.push(import_coc19.commands.registerCommand("git.chunkUnstage", async () => {
|
|
8533
9848
|
await manager.chunkUnstage();
|
|
8534
9849
|
}));
|
|
8535
|
-
subscriptions.push(
|
|
9850
|
+
subscriptions.push(import_coc19.commands.registerCommand("git.chunkUndo", async () => {
|
|
8536
9851
|
await manager.chunkUndo();
|
|
8537
9852
|
}));
|
|
8538
|
-
subscriptions.push(
|
|
9853
|
+
subscriptions.push(import_coc19.commands.registerCommand("git.showCommit", async () => {
|
|
8539
9854
|
await manager.showCommit();
|
|
8540
9855
|
}));
|
|
8541
|
-
subscriptions.push(
|
|
9856
|
+
subscriptions.push(import_coc19.commands.registerCommand("git.commitFiles.open", async (revision, root) => {
|
|
9857
|
+
await commitFiles.open(revision, root);
|
|
9858
|
+
}, void 0, true));
|
|
9859
|
+
subscriptions.push(import_coc19.commands.registerCommand("git.showCommitTree", async () => {
|
|
9860
|
+
const current = await manager.getCurrentCommit();
|
|
9861
|
+
if (current) await commitFiles.open(current.sha, current.root, { showCurrentFile: true, line: current.line });
|
|
9862
|
+
}));
|
|
9863
|
+
subscriptions.push(import_coc19.commands.registerCommand("git.commitFiles.invoke", async (node) => {
|
|
9864
|
+
await commitFiles.invoke(node);
|
|
9865
|
+
}, void 0, true));
|
|
9866
|
+
subscriptions.push(import_coc19.commands.registerCommand("git.commitFiles.toggle", async (node) => {
|
|
9867
|
+
await commitFiles.toggle(node);
|
|
9868
|
+
}, void 0, true));
|
|
9869
|
+
subscriptions.push(import_coc19.commands.registerCommand("git.commitFiles.openDocument", async (root, comparison, change, targetWinId, line) => {
|
|
9870
|
+
targetWinId = targetWinId != null ? targetWinId : await nvim.call("win_getid");
|
|
9871
|
+
await commitDocuments.open(root, comparison, change, targetWinId, line);
|
|
9872
|
+
}, void 0, true));
|
|
9873
|
+
subscriptions.push(import_coc19.commands.registerCommand("git.browserOpen", async () => {
|
|
8542
9874
|
await manager.browser();
|
|
8543
9875
|
}));
|
|
8544
|
-
subscriptions.push(
|
|
9876
|
+
subscriptions.push(import_coc19.commands.registerCommand("git.copyUrl", async (...args) => {
|
|
8545
9877
|
await manager.browser("copy", args);
|
|
8546
9878
|
}));
|
|
8547
|
-
subscriptions.push(
|
|
9879
|
+
subscriptions.push(import_coc19.commands.registerCommand("git.copyPermalink", async (...args) => {
|
|
8548
9880
|
await manager.browser("copy", args, true);
|
|
8549
9881
|
}));
|
|
8550
|
-
subscriptions.push(
|
|
9882
|
+
subscriptions.push(import_coc19.commands.registerCommand("git.push", async (...args) => {
|
|
8551
9883
|
await manager.push(args);
|
|
8552
9884
|
}));
|
|
8553
|
-
subscriptions.push(
|
|
9885
|
+
subscriptions.push(import_coc19.commands.registerCommand("git.diffCached", async () => {
|
|
8554
9886
|
await manager.diffCached();
|
|
8555
9887
|
}));
|
|
8556
|
-
subscriptions.push(
|
|
9888
|
+
subscriptions.push(import_coc19.commands.registerCommand("git.toggleGutters", async () => {
|
|
8557
9889
|
await manager.toggleGutters();
|
|
8558
9890
|
}));
|
|
8559
|
-
subscriptions.push(
|
|
9891
|
+
subscriptions.push(import_coc19.commands.registerCommand("git.foldUnchanged", async () => {
|
|
8560
9892
|
await manager.toggleFold();
|
|
8561
9893
|
}));
|
|
8562
|
-
subscriptions.push(
|
|
9894
|
+
subscriptions.push(import_coc19.commands.registerCommand("git.showBlameDoc", async () => {
|
|
8563
9895
|
await manager.showBlameDoc();
|
|
8564
9896
|
}));
|
|
8565
|
-
subscriptions.push(
|
|
8566
|
-
subscriptions.push(
|
|
8567
|
-
subscriptions.push(
|
|
8568
|
-
subscriptions.push(
|
|
8569
|
-
subscriptions.push(
|
|
8570
|
-
subscriptions.push(
|
|
8571
|
-
subscriptions.push(
|
|
8572
|
-
subscriptions.push(
|
|
9897
|
+
subscriptions.push(import_coc19.listManager.registerList(new GStatus(nvim, manager)));
|
|
9898
|
+
subscriptions.push(import_coc19.listManager.registerList(new Branches(nvim, manager)));
|
|
9899
|
+
subscriptions.push(import_coc19.listManager.registerList(new Commits(nvim, manager)));
|
|
9900
|
+
subscriptions.push(import_coc19.listManager.registerList(new Bcommits(nvim, manager)));
|
|
9901
|
+
subscriptions.push(import_coc19.listManager.registerList(new Gfiles(nvim, manager)));
|
|
9902
|
+
subscriptions.push(import_coc19.listManager.registerList(new GChunks(nvim, manager)));
|
|
9903
|
+
subscriptions.push(import_coc19.listManager.registerList(new GChanges(nvim, manager)));
|
|
9904
|
+
subscriptions.push(import_coc19.languages.registerCompletionItemProvider("semantic-commit", "Commit", (_a = config.get("semanticCommit.filetypes")) != null ? _a : [], {
|
|
8573
9905
|
provideCompletionItems: async (document, position) => {
|
|
8574
9906
|
if (position.line !== 0) {
|
|
8575
9907
|
return [];
|
|
8576
9908
|
}
|
|
8577
9909
|
const text = document.getText(
|
|
8578
|
-
|
|
8579
|
-
|
|
9910
|
+
import_coc19.Range.create(
|
|
9911
|
+
import_coc19.Position.create(position.line, 0),
|
|
8580
9912
|
position
|
|
8581
9913
|
)
|
|
8582
9914
|
);
|
|
@@ -8586,10 +9918,10 @@ async function activate(context) {
|
|
|
8586
9918
|
return DEFAULT_TYPES.map((o) => {
|
|
8587
9919
|
return {
|
|
8588
9920
|
label: o.value,
|
|
8589
|
-
kind:
|
|
9921
|
+
kind: import_coc19.CompletionItemKind.Snippet,
|
|
8590
9922
|
documentation: { kind: "plaintext", value: o.name },
|
|
8591
9923
|
// detail: o.name,
|
|
8592
|
-
insertTextFormat:
|
|
9924
|
+
insertTextFormat: import_coc19.InsertTextFormat.Snippet,
|
|
8593
9925
|
// tslint:disable-next-line: no-invalid-template-strings
|
|
8594
9926
|
insertText: o.value + text2 + "\n\n"
|
|
8595
9927
|
};
|
|
@@ -8598,12 +9930,12 @@ async function activate(context) {
|
|
|
8598
9930
|
return [];
|
|
8599
9931
|
}
|
|
8600
9932
|
}));
|
|
8601
|
-
subscriptions.push(
|
|
9933
|
+
subscriptions.push(import_coc19.workspace.registerKeymap(["o", "x"], "git-chunk-inner", async () => {
|
|
8602
9934
|
let diff = await manager.getCurrentChunk();
|
|
8603
9935
|
if (!diff) return;
|
|
8604
9936
|
await nvim.command(`normal! ${diff.start}GV${diff.end}G`);
|
|
8605
9937
|
}, { sync: true, silent: true }));
|
|
8606
|
-
subscriptions.push(
|
|
9938
|
+
subscriptions.push(import_coc19.workspace.registerKeymap(["o", "x"], "git-chunk-outer", async () => {
|
|
8607
9939
|
let diff = await manager.getCurrentChunk();
|
|
8608
9940
|
if (!diff) return;
|
|
8609
9941
|
let total = await nvim.call("line", ["$"]);
|