microsoft / vscode

Visual Studio Code
https://code.visualstudio.com
MIT License
164.26k stars 29.3k forks source link

Git Merge Shortcuts Disappear in Some Conditions #82946

Closed ZhangPuXi closed 5 years ago

ZhangPuXi commented 5 years ago

When I merge my code, there's a conflict in a js file.

const os = require('os');

//动态获取本地IP
const getLocalIpAddress = () => {
  let result;

  const network = os.networkInterfaces();

  for (let key in network) {
    const networkUnit = network[key];

    networkUnit.map((item) => {
      if (item.family === 'IPv4' && !item.internal) {
        result = item.address;
      }
    });
  }

  return result;
};

module.exports = {
<<<<<<< HEAD
  entry: '/Invoice/app.js',
=======
<<<<<<< HEAD
  entry: '/explainPages/app.js',
>>>>>>> cd2f036b783fb28030c83110d5c46ab791d66421
  //无需手动配置IP
  localhost: getLocalIpAddress(),
  // localhost: '192.168.1.112',

<<<<<<< HEAD
  buildRootPath: '/gtgjwap/Vue/Invoice/',
  //为了实现自适应用的模板
  template: path.resolve(__dirname, '../index.html')
=======
  buildRootPath: '/gtgjwap/Vue/explainPages/',
  //为了实现自适应用的模板
  template: path.resolve(__dirname, '../index-adaptive.html')
=======
  entry: '/welfareCenter/app.js',
  //无需手动配置IP
  localhost: getLocalIpAddress(),
  //localhost: 'localhost',
  wtestBase: 'huangl',
  buildRootPath: '/gtgjwap/Vue/welfareCenter/',
  //为了实现自适应用的模板
  template: path.resolve(__dirname, '../src/welfareCenter/index.html')
>>>>>>> c7a461f1cabd09d662e8f9cec622a99872db66bb
>>>>>>> cd2f036b783fb28030c83110d5c46ab791d66421
}

And the Accept Incoming Changes button is disappear.

When I start manually fix the conflict, just delete the first <<<<<<< HEAD line, the shortcuts is appear. I'm not sure whether it is a bug. Just report for your information.

chrmarti commented 5 years ago

The merge conflicts appear to overlap. Can you provide step-by-step instructions on how to arrive at the above content?

ZhangPuXi commented 5 years ago
  1. Copy the above code to a new js file. And all you can see is just raw code.

image

  1. Remove the first appearance of <<<<<<< HEAD, and you can see the convenient buttons now.

image

I guess this is caused by embed of the '<<<<<<<' strings. Thanks for your time.

chrmarti commented 5 years ago

@ZhangPuXi I don't understand what Git (or other SCM) operations resulted in the file content you have. It looks like the overlapping merge conflicts are not valid merge conflict syntax and for that reason not supported.

Starting from a file without merge conflicts, how did you arrive at the file content you have?

ZhangPuXi commented 5 years ago

@chrmarti I just merge my dev branch into the master branch and that results in the conflicts. This is the first time I've met this situation. And one of my workmates also met this.

chrmarti commented 5 years ago

Maybe one of the commits had one of the merge conflict texts as its content and when merging that a new merge conflict occurred. The merge conflict syntax does not support nesting / interleaving of conflicts, so I will close this issue. Thanks.

vscodebot[bot] commented 5 years ago

We closed this issue because we don't plan to address it in the foreseeable future. You can find more detailed information about our decision-making process here. If you disagree and feel that this issue is crucial: We are happy to listen and to reconsider.

If you wonder what we are up to, please see our roadmap and issue reporting guidelines.

Thanks for your understanding and happy coding!

kiprasmel commented 5 years ago

Edit: Fixed in #83221!

settings.json:

/** must: */
"editor.codeLens": true,
"merge-conflict.codeLens.enabled": true,

/** optional: */
"typescript.referencesCodeLens.enabled": false,
"typescript.implementationsCodeLens.enabled": false,
"javascript.referencesCodeLens.enabled": false

Hello, I'd like to add to this - the shortcuts disappear for me too! This happens always since I've updated vscode from 1.38 to 1.39.2.

I opened the same merge conflict with vscode 1.38 / vscode-insiders 1.39.0 and it works absolutely fine.

Can we get this re-opened?

/cc @chrmarti

Let's create a sample conflict:

mkdir repo
cd repo
git init
touch file
echo "1" > file
git add file
git commit -m "master: init & write '1' to file"
git checkout -b other-branch
echo "2" > file
git add file
git commit -m "other branch: change '1' to '2' in file"
git checkout master
echo "3" > file
git add file
git commit -m "master again: change '1' to '3' in file"
git checkout other-branch
git rebase -i master
# <confirm>
Auto-merging file
CONFLICT (content): Merge conflict in file
error: could not apply 0d65af8... other branch: change '1' to '2' in file
Resolve all conflicts manually, mark them as resolved with
"git add/rm <conflicted_files>", then run "git rebase --continue".
You can instead skip this commit: run "git rebase --skip".
To abort and get back to the state before "git rebase", run "git rebase --abort".
Could not apply 0d65af8... other branch: change '1' to '2' in file
cat file
<<<<<<< HEAD
3
=======
2
>>>>>>> 0d65af8... other branch: change '1' to '2' in file
code .

vscode-normal-nope

As you can see - the resolve merge conflict buttons are nowhere to be found. There is no way in hell that vscode cannot support this.

Now, if I open up an older version of vscode (1.39.0-insider instead of 1.39.2), it all works fine:

vscode-insiders-works-thought

it will probably work with vscode 1.38.x.


My setup:

$ uname -a
Linux arch-usb 5.3.7-arch1-1-ARCH #1 SMP PREEMPT Fri Oct 18 00:17:03 UTC 2019 x86_64 GNU/Linux

$ code -v
1.39.2
6ab598523be7a800d7f3eb4d92d7ab9a66069390
x64