为什么 VS 代码包含强调项但没有错误?

我正在用 VS 代码写一个 React 项目。我在 VS 代码中遇到了这个问题。在我的项目中,这个文件夹 包含强调的项目,我知道这意味着在我的文件中有一个错误。但在图片中:

vs code project,

我已经检查了所有的文件,但没有发现错误。所以这让我感到困惑。

我在谷歌上搜索了这个问题,发现了一个类似的 GitHub 问题

97519 次浏览

Committing once with git can be resolved.

I saw this message after moving a file from one folder to another, renaming and committing everything to git.

The Visual Studio "Problems" window showed an issue with the "deleted" file. Somehow VS had left a window open for the original location of the file and in it's tab the file was labeled as "deleted". Closing that tab in VS got rid of the "Contains emphasized items"

This error occurs because there are pending changes to be saved in git, so to solve this problem, open a command terminal and go to the folder where your project is located, execute the following commands

git add .
git commit -m "your commit description"

In my case it works with this.

Had the same issue.

Committing multiple times from within the VS Code did not help.

However, once I added the files and committed from the shell, everything fell in place.

I can solve the problem react-native start --reset-cache and by reloading VS with the command Ctrl + shift + p and searching Developer: Reload Window

I noticed this when I working on a Rails application using Visual Studio Code editor.

I used an underscore for a directory name, that is instead of staticpages, I named the directory static_pages.

However, committing the code change using the below commands fixed it:

git add .
git commit -m "commit message"

That's all.

I hope this helps

VSCode using React. Changed a folder name in the src folder. Would not pass compilation after changing names of components. Committed to git. Restarted the app with npm start. All is well.

In my case, the already deleted files were opened in the VS code. Closing those files resolved my issue.

This is an edge case but I am putting it here just in case it helps someone in the future...

I had accidentally done a git add . before I had fully set up my .gitignore file, so it had staged a couple folders with hundreds of files (mostly the entire Electron out folder) that I definitely didn't want in the repo.

This is the procedure I went thru to clean up my staged files:

  • updated .gitignore so that when I reverted the add I could be sure that GIT was ignoring the right files and folders (which worked, hundreds to 7, the moment I did the git reset)
  • git reset -f
  • noting that the correct files were now in line to be staged, I did:
    • git add .
    • git commit -m "message"
    • git push

When I returned to the regular file list, I noticed that node_modules was showing the "emphasized items" indicator. So just to make sure that I had actually gotten everything committed and such I tweaked .gitignore again (added node_modules/** just in case lol), did another commit, and still had the issue. Nothing helped, and like I said, it was confusing because the indicated files were under node_modules and it was in the ignore list.

So I hit cmd-p and ran Developer: Reload Window. It turned out out all I had to do was reload the window and the emphasized items went away entirely. Simple fix, confusing problem.

Apparently adding, reverting, then adding a subset of my directories confused vs code and it just needed to reload the window.

I had the same issue, pushing to git didn't solve the problem. I simply closed all files, cancelled my dev server and restarted VS Code. The emphasizing was gone.

this work for me :

I can solve the problem react-native start --reset-cache and by reloading VS with the command Ctrl + shift + p and searching Developer: Reload Window

In my case files that had been deleted were still opened in VsCode. After closing them (and also git commit as other posts suggest) helped solved the problem

Use the command, CTRL+SHIFT+P on windows or COMMAND+SHIFT+P on mac, then search "Developer: reload window", click on it, your vs will reload and enjoy your stress-free coding.

git add . git commit -m "your commit description"

If this not helps, after commit restart the VS CODE

Select this tab from toolbar - View -> Problems or Ctrl + Shift + M and on bottom Terminal you will see whats problem is it.

You may have hidden files. My Explorer was not listing hidden files in those directories. Hidden files on Linux begin with a . (for example, .hidden.txt)

0

When I was working on a angular application in the Visual Studio Code editor, I observed this. And resolved it by simply restarting VSCode.

This error is coming because sometimes we delete something so its need window reloading and to reload Type the command, CTRL+SHIFT+P on windows or COMMAND+SHIFT+P on mac, then search "Developer: reload window", click on it. It will reload the window and your error will be gone

uninstall any extension if you have installed in vs code.It will be solved.

Had the same issue, had copied files from a folder into another folder. git commit as suggested solved the issue.

This happens when you've deleted some files/folders from project and haven't yet added the event to a commit.

There is multiple solutions

Option 1: Close the VS code and open it again

Option 2: Commit your code chages in git(if you are using)

Option 3: Reload the VS code - Use the command, CTRL+SHIFT+P on windows or COMMAND+SHIFT+P on mac, then search "Developer: reload window", click on it

Just to know I was in an Angular project, using Windows, WSL, I created a service and after that I renamed it, when I committed the changes, I noticed this red mark.

I just pressed Ctrl + Shift + P and then typed: Developer: Reload Window. It will just reload the entire project and the mark will disappear.

commit the changes, if still, the error is there, reopen the vscode