coc-git 2.7.3 → 2.7.4

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.
Files changed (3) hide show
  1. package/Readme.md +1 -1
  2. package/lib/index.js +35 -30
  3. package/package.json +7 -1
package/Readme.md CHANGED
@@ -30,7 +30,7 @@ In your vim/neovim, run command:
30
30
  - Git related lists, including `issues`, `gfiles`, `gstatus`, `commits`, `branches` & `bcommits`
31
31
  - Keymaps for git chunks, including `<Plug>(coc-git-chunkinfo)` `<Plug>(coc-git-nextchunk)` & `<Plug>(coc-git-prevchunk)` ,
32
32
  - Commands for chunks, including `git.chunkInfo` `git.chunkStage` `git.chunkUndo` and more.
33
- - Keymaps for git conflicts, including `<Plug>(coc-git-nextconflict)`, `<Plug>(coc-git-prevconflict)`, `<Plug>(coc-git-keepcurrent)`, `<Plug>(coc-git-keepincoming)` & `<Plug>(coc-git-keepboth)`.
33
+ - Keymaps & commands for git conflicts.
34
34
  - Completion support for semantic commit.
35
35
  - Completion support for GitHub/GitLab issues.
36
36
 
package/lib/index.js CHANGED
@@ -5853,7 +5853,8 @@ var DocumentManager = class {
5853
5853
  conflict: {
5854
5854
  enabled: config.get("conflict.enabled", true),
5855
5855
  currentHlGroup: config.get("conflict.current.hlGroup", "DiffChange"),
5856
- incomingHlGroup: config.get("conflict.incoming.hlGroup", "DiffAdd")
5856
+ incomingHlGroup: config.get("conflict.incoming.hlGroup", "DiffAdd"),
5857
+ commonHlGroup: config.get("conflict.common.hlGroup", "DiffText")
5857
5858
  },
5858
5859
  floatConfig: config.get("floatConfig", {}),
5859
5860
  gstatus: {
@@ -6682,6 +6683,11 @@ register("zh_CN", zh_CN_default);
6682
6683
  // src/model/buffer.ts
6683
6684
  var import_url = require("url");
6684
6685
  var signGroup = "CocGit";
6686
+ var revPattern = "([0-9A-Za-z_.:/-]+)";
6687
+ var startPattern = new RegExp(`^<{7} (${revPattern})(:? .+)?$`);
6688
+ var sepPattern = new RegExp(`^={7}$`);
6689
+ var endPattern = new RegExp(`^>{7} (${revPattern})(:? .+)?$`);
6690
+ var commonPattern = /^\|{7}\smerged\scommon\sancestors/;
6685
6691
  var GitBuffer = class {
6686
6692
  constructor(doc, config, relpath, repo, git, channel, floatFactory) {
6687
6693
  this.doc = doc;
@@ -7167,15 +7173,19 @@ var GitBuffer = class {
7167
7173
  if (conflict.start <= line && conflict.end >= line) {
7168
7174
  switch (part) {
7169
7175
  case 0 /* Current */:
7170
- await nvim.command(`${conflict.sep},${conflict.end}d`);
7171
- return nvim.command(`${conflict.start}d`);
7176
+ let start = conflict.common ? conflict.common : conflict.sep;
7177
+ await nvim.command(`${start},${conflict.end}d | ${conflict.start}d`);
7178
+ return;
7172
7179
  case 1 /* Incoming */:
7173
- await nvim.command(`${conflict.end}d`);
7174
- return nvim.command(`${conflict.start},${conflict.sep}d`);
7180
+ await nvim.command(`${conflict.end}d | ${conflict.start},${conflict.sep}d`);
7181
+ return;
7175
7182
  case 2 /* Both */:
7176
- await nvim.command(`${conflict.end}d`);
7177
- await nvim.command(`${conflict.sep}d`);
7178
- return nvim.command(`${conflict.start}d`);
7183
+ if (conflict.common) {
7184
+ await nvim.command(`${conflict.end}d | ${conflict.common},${conflict.sep}d | ${conflict.start}d`);
7185
+ } else {
7186
+ await nvim.command(`${conflict.end}d | ${conflict.sep}d | ${conflict.start}d`);
7187
+ }
7188
+ return;
7179
7189
  }
7180
7190
  }
7181
7191
  }
@@ -7347,8 +7357,6 @@ var GitBuffer = class {
7347
7357
  nvim.call("setpos", [".", cursor], true);
7348
7358
  await nvim.resumeNotification();
7349
7359
  } else {
7350
- console.log(33);
7351
- console.log(ranges);
7352
7360
  this.foldEnabled = true;
7353
7361
  let [foldmethod, foldenable, foldlevel] = await nvim.eval("[&foldmethod,&foldenable,&foldlevel]");
7354
7362
  this.foldSettings = {
@@ -7381,11 +7389,7 @@ var GitBuffer = class {
7381
7389
  }
7382
7390
  async parseConflicts() {
7383
7391
  if (!this.hasConflicts || !this.config.conflict.enabled) return;
7384
- const lines = this.doc.getLines();
7385
- const revPattern = "([0-9A-Za-z_.:/-]+)";
7386
- const startPattern = new RegExp(`^<{7} (${revPattern})(:? .+)?$`);
7387
- const sepPattern = new RegExp(`^={7}$`);
7388
- const endPattern = new RegExp(`^>{7} (${revPattern})(:? .+)?$`);
7392
+ const lines = this.doc.textDocument.lines;
7389
7393
  let conflicts = [];
7390
7394
  let conflict = null;
7391
7395
  let state = 0 /* Initial */;
@@ -7406,11 +7410,12 @@ var GitBuffer = class {
7406
7410
  }
7407
7411
  break;
7408
7412
  }
7413
+ case 2 /* MatchedCommon */:
7409
7414
  case 1 /* MatchedStart */: {
7410
- const match = line.match(sepPattern);
7415
+ let match = line.match(sepPattern);
7411
7416
  if (match) {
7412
7417
  conflict.sep = index + 1;
7413
- state = 2 /* MatchedSep */;
7418
+ state = 3 /* MatchedSep */;
7414
7419
  } else {
7415
7420
  const startMatch = line.match(startPattern);
7416
7421
  if (startMatch) {
@@ -7419,11 +7424,14 @@ var GitBuffer = class {
7419
7424
  } else if (line.match(endPattern)) {
7420
7425
  conflict = null;
7421
7426
  state = 0 /* Initial */;
7427
+ } else if (line.match(commonPattern)) {
7428
+ conflict.common = index + 1;
7429
+ state = 2 /* MatchedCommon */;
7422
7430
  }
7423
7431
  }
7424
7432
  break;
7425
7433
  }
7426
- case 2 /* MatchedSep */: {
7434
+ case 3 /* MatchedSep */: {
7427
7435
  const match = line.match(endPattern);
7428
7436
  if (match) {
7429
7437
  conflict.end = index + 1;
@@ -7455,23 +7463,20 @@ var GitBuffer = class {
7455
7463
  let buffer = this.doc.buffer;
7456
7464
  let currentHlGroup = this.config.conflict.currentHlGroup;
7457
7465
  let incomingHlGroup = this.config.conflict.incomingHlGroup;
7466
+ let commonHlGroup = this.config.conflict.commonHlGroup;
7458
7467
  let { nvim } = import_coc13.workspace;
7459
7468
  nvim.pauseNotification();
7460
7469
  buffer.clearNamespace(this.config.conflictSrcId, 0, -1);
7461
7470
  const srcId = this.config.conflictSrcId;
7462
7471
  conflicts.map((conflict) => {
7463
- buffer.addHighlight({
7464
- hlGroup: currentHlGroup,
7465
- line: conflict.start,
7466
- colStart: 0,
7467
- colEnd: 1e4,
7468
- srcId
7469
- });
7470
- for (let line = conflict.start - 1; line < conflict.sep - 1; line++) {
7471
- buffer.addHighlight({ hlGroup: currentHlGroup, line, srcId });
7472
- }
7473
- for (let line = conflict.end - 1; line >= conflict.sep; line--) {
7474
- buffer.addHighlight({ hlGroup: incomingHlGroup, line, srcId });
7472
+ let currEnd = conflict.common ? conflict.common - 1 : conflict.sep - 1;
7473
+ let currRange = import_coc13.Range.create(import_coc13.Position.create(conflict.start - 1, 0), import_coc13.Position.create(currEnd, 0));
7474
+ let incomingRange = import_coc13.Range.create(import_coc13.Position.create(conflict.sep, 0), import_coc13.Position.create(conflict.end, 0));
7475
+ buffer.highlightRanges(srcId, currentHlGroup, [currRange]);
7476
+ buffer.highlightRanges(srcId, incomingHlGroup, [incomingRange]);
7477
+ if (conflict.common) {
7478
+ let range = import_coc13.Range.create(import_coc13.Position.create(conflict.common - 1, 0), import_coc13.Position.create(conflict.sep - 1, 0));
7479
+ buffer.highlightRanges(srcId, commonHlGroup, [range]);
7475
7480
  }
7476
7481
  });
7477
7482
  nvim.resumeNotification(false, true);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "coc-git",
3
- "version": "2.7.3",
3
+ "version": "2.7.4",
4
4
  "description": "Git extension for coc.nvim",
5
5
  "main": "lib/index.js",
6
6
  "publisher": "chemzqm",
@@ -430,6 +430,12 @@
430
430
  "scope": "application",
431
431
  "description": "Highlight group for the incoming version of a merge conflict."
432
432
  },
433
+ "git.conflict.common.hlGroup": {
434
+ "type": "string",
435
+ "default": "DiffText",
436
+ "scope": "application",
437
+ "description": "Highlight group for the merged common ancestors highlight group."
438
+ },
433
439
  "git.gstatus.saveBeforeOpen": {
434
440
  "type": "boolean",
435
441
  "default": "false",