microsoft / vscode

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

Diff Inline View is not showing removed code #192957

Closed deadlydog closed 11 months ago

deadlydog commented 1 year ago

Type: Bug

  1. Open a file that is stored in source control.
  2. Remove some text from it.
  3. In the "Source Control" menu, select the file to open the diff and see the changes.
  4. Toggle between Split View and Inline View. Split View shows the deleted text, while Inline View does not. The minimap scrollbar shows red though, indicating it sees the removed code.

VS Code version: Code 1.82.1 (6509174151d557a81c9d0b5f8a5a1e9274db5585, 2023-09-08T08:45:05.575Z) OS version: Windows_NT x64 10.0.19045 Modes:

System Info |Item|Value| |---|---| |CPUs|Intel(R) Core(TM) i7-10875H CPU @ 2.30GHz (16 x 2304)| |GPU Status|2d_canvas: enabled
canvas_oop_rasterization: enabled_on
direct_rendering_display_compositor: disabled_off_ok
gpu_compositing: enabled
multiple_raster_threads: enabled_on
opengl: enabled_on
rasterization: enabled
raw_draw: disabled_off_ok
video_decode: enabled
video_encode: enabled
vulkan: disabled_off
webgl: enabled
webgl2: enabled
webgpu: enabled| |Load (avg)|undefined| |Memory (System)|31.72GB (15.89GB free)| |Process Argv|--crash-reporter-id e8c746cd-ffb1-4751-aa20-daae247bf885| |Screen Reader|no| |VM|0%|
Extensions (136) Extension|Author (truncated)|Version ---|---|--- better-comments|aar|3.0.2 codesnap|adp|1.3.4 Bookmarks|ale|13.4.1 arepl|alm|2.0.5 jsoncrack-vscode|Ayk|2.0.2 armview|ben|0.4.6 github-markdown-preview|bie|0.3.0 markdown-checkbox|bie|0.4.0 markdown-emoji|bie|0.3.0 markdown-footnotes|bie|0.1.1 markdown-mermaid|bie|1.19.0 markdown-preview-github-styles|bie|2.0.2 markdown-yaml-preamble|bie|0.1.0 insert-unicode|bru|0.14.0 vscode-better-align|cho|1.4.2 npm-intellisense|chr|1.4.4 gitignore|cod|0.9.0 supersharp|cra|0.1.4 vscode-markdownlint|Dav|0.51.0 vscode-eslint|dba|2.4.2 githistory|don|0.6.20 xml|Dot|2.5.1 gitlens|eam|14.3.0 sort-lines-by-selection|ear|1.2.0 vscode-html-css|ecm|1.13.1 EditorConfig|Edi|0.16.4 LogFileHighlighter|emi|2.16.0 json-tools|eri|1.0.2 file-icons|fil|1.1.0 vscode-firefox-debug|fir|2.9.8 auto-close-tag|for|0.5.14 auto-rename-tag|for|0.1.10 code-runner|for|0.12.0 copilot|Git|1.111.404 copilot-chat|Git|0.7.0 copilot-labs|Git|0.15.1019 remotehub|Git|0.60.0 vscode-github-actions|git|0.26.2 vscode-pull-request-github|Git|0.72.0 go|gol|0.39.1 gc-excelviewer|Gra|4.2.58 terraform|has|2.27.2 vscode-test-explorer|hbe|2.21.1 vscode-drawio|hed|1.6.6 randomeverything|hel|0.0.3 yaml-plus-json|hil|1.12.1 rest-client|hum|0.25.1 path-autocomplete|ion|1.25.0 vscode-hacker-typer|jev|0.1.1 azure-policy-intellisense|jus|0.0.9 vscode-colorize|kam|0.11.1 vsc-python-indent|Kev|1.18.0 vscode-gutter-preview|kis|0.30.0 regexp-preview|Lou|0.1.5 vscode-autohotkey-plus-plus|mar|5.0.3 rainbow-csv|mec|3.7.0 git-graph|mhu|1.30.0 dotenv|mik|1.0.1 azure-pipelines|ms-|1.208.0 azure-dev|ms-|0.7.0 vscode-apimanagement|ms-|1.0.8 vscode-azureappservice|ms-|0.25.0 vscode-azurecontainerapps|ms-|0.5.1 vscode-azurefunctions|ms-|1.12.4 vscode-azureresourcegroups|ms-|0.7.5 vscode-azurestaticwebapps|ms-|0.12.2 vscode-azurestorage|ms-|0.15.3 vscode-azureterraform|ms-|0.3.2 vscode-azurevirtualmachines|ms-|0.6.5 vscode-bicep|ms-|0.21.1 vscode-cosmosdb|ms-|0.19.4 vscode-docker|ms-|1.26.0 blazorwasm-companion|ms-|1.1.4 csdevkit|ms-|0.4.10 csharp|ms-|2.2.10 dotnet-interactive-vscode|ms-|1.0.4461040 vscode-dotnet-runtime|ms-|1.7.2 vscodeintellicode-csharp|ms-|0.1.26 vscode-kubernetes-tools|ms-|1.3.13 data-workspace-vscode|ms-|0.5.0 mssql|ms-|1.20.1 sql-bindings-vscode|ms-|0.4.0 sql-database-projects-vscode|ms-|1.2.0 isort|ms-|2023.10.1 python|ms-|2023.16.0 vscode-pylance|ms-|2023.9.10 jupyter|ms-|2023.8.1002501831 jupyter-keymap|ms-|1.1.2 jupyter-renderers|ms-|1.0.17 vscode-jupyter-cell-tags|ms-|0.1.8 vscode-jupyter-slideshow|ms-|0.1.5 remote-containers|ms-|0.309.0 remote-ssh|ms-|0.106.4 remote-ssh-edit|ms-|0.86.0 remote-wsl|ms-|0.81.3 vscode-remote-extensionpack|ms-|0.24.0 azure-account|ms-|0.11.5 azure-repos|ms-|0.36.0 azurecli|ms-|0.5.0 powershell|ms-|2023.6.0 remote-explorer|ms-|0.4.1 remote-repositories|ms-|0.38.1 remote-server|ms-|1.4.3 test-adapter-converter|ms-|0.1.8 vscode-node-azure-pack|ms-|1.2.0 azurerm-vscode-tools|msa|0.15.11 gremlins|nho|0.26.0 deepdark-material|Nim|3.3.1 autodocstring|njp|0.6.1 indent-rainbow|ode|8.3.1 advanced-new-file|pat|1.2.2 git-file-history|pom|1.0.1 vscode-css-peek|pra|4.4.1 pester-test|psp|2023.7.7 puppet-vscode|pup|1.4.0 quicktype|qui|12.0.46 ruby|reb|0.28.1 vscode-commons|red|0.0.6 vscode-yaml|red|1.14.0 shopify-liquid|sis|3.2.2 runme|sta|1.10.0 code-spell-checker|str|3.0.1 azure-devops-yaml-pipeline-validator|Tom|1.8.0 vscode-inline-values-powershell|Tyl|0.0.7 vscode-mdx|uni|1.4.0 errorlens|use|3.13.0 highlight-matching-tag|vin|0.11.0 intellicode-api-usage-examples|Vis|0.2.8 vscodeintellicode|Vis|1.2.30 codetour|vsl|0.0.59 gistfs|vsl|0.4.1 vscode-ruby|win|0.28.0 vscode-import-cost|wix|3.3.0 change-case|wma|1.0.0 markdown-all-in-one|yzh|3.5.1 vscode-autohotkey-debug|zer|1.11.0
A/B Experiments ``` vsliv368:30146709 vsreu685:30147344 python383cf:30185419 vspor879:30202332 vspor708:30202333 vspor363:30204092 vslsvsres303:30308271 vserr242:30382549 pythontb:30283811 vsjup518:30340749 pythonptprofiler:30281270 vshan820:30294714 vstes263:30335439 vscorecescf:30445987 vscod805:30301674 binariesv615:30325510 bridge0708:30335490 bridge0723:30353136 vsaa593:30376534 pythonvs932:30410667 py29gd2263cf:30792227 vsclangdf:30486550 c4g48928:30535728 dsvsc012:30540252 pynewext54:30695312 azure-dev_surveyone:30548225 vsccc:30803844 3biah626:30602489 f6dab269:30613381 showlangstatbar:30737416 0bi6i642:30835152 03d35959:30757346 pythonfmttext:30731395 fixshowwlkth:30771522 showindicator:30805244 pythongtdpath:30769146 i26e3531:30792625 pythonnosmt12:30797651 pythonidxptcf:30805731 pythonnoceb:30805159 copilotsettingt:30834058 dsvsc013:30795093 dsvsc014:30804076 diffeditorv2:30821572 dsvsc015cf:30829746 ```

Screenshots

Here is the Split View diff, where you can see that code was removed: image

And here is the Inline View, which would normally show the removed text, but no longer does: image

deadlydog commented 1 year ago

This looks to have been fixed in the recent VS Code update, so I'm going to close this issue.

jmalangoni commented 1 year ago

FYI this has appeared for me now in latest release.

The bug does not appear immediately on vscode application launch. Have not noticed any specific action triggering it, but will keep an eye out.

Version: 1.83.1 (user setup) Commit: f1b07bd25dfad64b0167beb15359ae573aecd2cc Date: 2023-10-10T23:48:05.904Z Electron: 25.8.4 ElectronBuildId: 24154031 Chromium: 114.0.5735.289 Node.js: 18.15.0 V8: 11.4.183.29-electron.0 OS: Windows_NT x64 10.0.19044

hediet commented 1 year ago

It looks like something with the view zones is off. The alignment viewzones are missing in the first screenshot.

Do you have repro steps?

ahkhanjani commented 1 year ago

Somewhere in the middle of coding VS Code suddenly decides to do this. Closing and reopening VS Code fixes it temporarily until this happens again. That's my current unsophisticated observation. (v1.83.1)

fbstj commented 1 year ago

https://stackoverflow.com/questions/77324073/vscode-is-hiding-removed-lines-from-diffs

I've been having this issue too. if you move the diff view or split the view the "new" view shows things correctly.

hediet commented 1 year ago

Do you have any settings enabled that could cause this? This is certainly a bug, but so far I didn't manage to reproduce

fbstj commented 1 year ago

I have looked around the "diff" & "git" configuration options and could not see anything that popped out as a cause. I don't think I have any changed / non-default configuration tbh, but it's hard to tell.

especially since the removed lines DO show up if I move the diff tab into any of the views not the "main"/origin one; and they show up if I then close the origin tabs and let the tab fill the page. but then if I open another tab.

its-dibo commented 1 year ago

I have this issue in the latest vscode version

dwoodwardgb commented 1 year ago

Happens for me invariably. Here is my version info and settings.json

Version: 1.83.1 (Universal) Commit: f1b07bd25dfad64b0167beb15359ae573aecd2cc Date: 2023-10-10T23:46:55.789Z (1 wk ago) Electron: 25.8.4 ElectronBuildId: 24154031 Chromium: 114.0.5735.289 Node.js: 18.15.0 V8: 11.4.183.29-electron.0 OS: Darwin arm64 22.6.0

{
  "window.autoDetectColorScheme": true,
  "workbench.sideBar.location": "right",
  "[typescriptreact]": {
    "editor.defaultFormatter": "esbenp.prettier-vscode"
  },
  "[javascript]": {
    "editor.defaultFormatter": "esbenp.prettier-vscode"
  },
  "editor.tabSize": 2,
  "[html]": {
    "editor.defaultFormatter": "vscode.html-language-features"
  },
  "editor.lineNumbers": "relative",
  "editor.fontFamily": "SF Mono,Menlo,monospace",
  "editor.fontLigatures": true,
  "workbench.preferredLightColorTheme": "Default Light+ Experimental",
  "workbench.preferredDarkColorTheme": "Default Dark+ Experimental",
  "git.confirmSync": false,
  "[python]": {
    "editor.formatOnType": true
  },
  "thunder-client.previewFeatures": true,
  "thunder-client.responseLimit": 5,
  "ruby.rubocop.onSave": false,
  "[json]": {
    "editor.defaultFormatter": "esbenp.prettier-vscode"
  },
  "[typescript]": {
    "editor.defaultFormatter": "esbenp.prettier-vscode"
  },
  "terminal.integrated.fontSize": 17,
  "ruby.useBundler": true, //run non-lint commands with bundle exec
  "ruby.useLanguageServer": true, // use the internal language server (see below)
  "ruby.lint": {
    "rubocop": {
      "useBundler": true // enable rubocop via bundler
    }
  },
  "ruby.format": "rubocop",
  "workbench.colorTheme": "Alabaster",
  "editor.formatOnSaveMode": "modificationsIfAvailable",
  "editor.formatOnSave": true,
  "editor.fontSize": 17
}
vikvikvr commented 1 year ago

toggling the Diff Editor: Render Side By Side setting on and off worked for me

image

ahkhanjani commented 1 year ago

toggling the Diff Editor: Render Side By Side setting on and off worked for me

Doesn't work for me.

noalbalint commented 1 year ago

Another quick fix/workaround is to run > Developer: Reload Window from the Command Pallete. @ahkhanjani try that maybe?

hediet commented 1 year ago

Can you check/share the dev tool logs when this happens? Can you also share both sides of the diff where this happens?

I'm using the diff editor daily and so far I didn't see this yet.

maxjf1 commented 1 year ago

Same just happened for me. In my case it asked if i want to increase the diff time processing (was processing 2 big files), apart from that i haven't done anything unusual.

Reloading the window solved for me

bvfusion1001 commented 1 year ago

This issue has been a huge problem for me for over a month - especially because I frequent the use of Stage selected changes which was resulting is some very strange behavior. Developer: Reload Window solved all my problems. Thanks!

UPDATE: This doesn't solve my issue, this solved an issue, but I think I'm experiencing another unrelated one.

ADTC commented 1 year ago

I faced this issue and updated to 1.84.2 (user setup). After restart, the issue is not present, but that could be temporary until the issue returns again (as per previous comments here). I'm not able to forcefully reproduce the issue by doing things like switching diff views, staging, unstaging, staging selected ranges etc.

It's interesting to note that the first occurrence of this issue happened when I staged a file. Usually the diff in the working tree disappears fully, but this time only the added diff (green) disappeared, where as the deleted diff (red) still remained. I thought that was odd, and checked the diff in the index, and it only contained the added diff (green).

I checked git diff on Terminal and everything is alright there, so I'm thinking this might be a corruption of the VS Code's internal diff cache or something, which could explain why Reload Window or restart of VS Code fixes this temporarily.

PS: When I first noticed it, I incorrectly thought this is some kind of a new feature which hides unnecessary deleted lines 😂 (for example if the line has no deleted chars, only added ones) and went around digging in Settings to turn it off. Apparently, it's a bug and regression.

ADTC commented 1 year ago

@hediet is there a way for one of us to get a dump of the VS Code app diff engine/module/whatever when this happens again? Maybe you can inspect it to see what's going on. 🙂

Logs could be an alternative too. Maybe the diff engine is hitting some errors and silently bypassing them.

JoshHarmon commented 1 year ago

Just ran into this after doing a lot of work in a single session (i.e. the problem did not immediately start occurring). Developer: Reload Window was an effective workaround for me as well. Before this occurred, I had been doing an abundant amount of mass find/replace (non-regex, non-case-sensitive, non-whole-word, non-preserve-case), that had cumulatively dirtied >800 files in my working directory. In the course of doing this, I had invoked the diff editor many dozens (if not hundreds) of times from within the session before this misbehavior occurred.

This misbehavior was not isolated to a specific file or find result; once it began occurring, the misbehavior continued with each file/location in my find results list.

Version: 1.84.2 (user setup) Commit: 1a5daa3a0231a0fbba4f14db7ec463cf99d7768e Date: 2023-11-09T10:51:52.184Z Electron: 25.9.2 ElectronBuildId: 24603566 Chromium: 114.0.5735.289 Node.js: 18.15.0 V8: 11.4.183.29-electron.0 OS: Windows_NT x64 10.0.22621

ADTC commented 1 year ago

@hediet this is most consistently happening to me when I'm viewing worktree diff, then staging it in the sidebar. It happens randomly, but I noticed this is what I was usually doing just before it does.

I have to Reload Window each time it happens to fix the issue, until it re-occurs sometime later.

JoshHarmon commented 12 months ago

@hediet Time-correlated renderer.log entries when something that looked like this issue re-occurred (except showing only the removal, not the addition) just a bit ago... hope this provides a hint at what might be going on.

2023-11-22 13:38:00.272 [error] Cannot read properties of undefined (reading 'endLineNumberExclusive'): TypeError: Cannot read properties of undefined (reading 'endLineNumberExclusive')
    at E.intersectsStrict (vscode-file://vscode-app/c:/Users/me/AppData/Local/Programs/Microsoft%20VS%20Code/resources/app/out/vs/workbench/workbench.desktop.main.js:96:10545)
    at D (vscode-file://vscode-app/c:/Users/me/AppData/Local/Programs/Microsoft%20VS%20Code/resources/app/out/vs/workbench/workbench.desktop.main.js:681:45393)
    at vscode-file://vscode-app/c:/Users/me/AppData/Local/Programs/Microsoft%20VS%20Code/resources/app/out/vs/workbench/workbench.desktop.main.js:681:47301
    at w (vscode-file://vscode-app/c:/Users/me/AppData/Local/Programs/Microsoft%20VS%20Code/resources/app/out/vs/workbench/workbench.desktop.main.js:85:8256)
    at vscode-file://vscode-app/c:/Users/me/AppData/Local/Programs/Microsoft%20VS%20Code/resources/app/out/vs/workbench/workbench.desktop.main.js:681:47296
2023-11-22 13:38:45.797 [error] Cannot read properties of undefined (reading 'endLineNumberExclusive'): TypeError: Cannot read properties of undefined (reading 'endLineNumberExclusive')
    at E.intersectsStrict (vscode-file://vscode-app/c:/Users/me/AppData/Local/Programs/Microsoft%20VS%20Code/resources/app/out/vs/workbench/workbench.desktop.main.js:96:10545)
    at D (vscode-file://vscode-app/c:/Users/me/AppData/Local/Programs/Microsoft%20VS%20Code/resources/app/out/vs/workbench/workbench.desktop.main.js:681:45393)
    at vscode-file://vscode-app/c:/Users/me/AppData/Local/Programs/Microsoft%20VS%20Code/resources/app/out/vs/workbench/workbench.desktop.main.js:681:47301
    at w (vscode-file://vscode-app/c:/Users/me/AppData/Local/Programs/Microsoft%20VS%20Code/resources/app/out/vs/workbench/workbench.desktop.main.js:85:8256)
    at vscode-file://vscode-app/c:/Users/me/AppData/Local/Programs/Microsoft%20VS%20Code/resources/app/out/vs/workbench/workbench.desktop.main.js:681:47296
2023-11-22 13:38:56.498 [error] Cannot read properties of undefined (reading 'endLineNumberExclusive'): TypeError: Cannot read properties of undefined (reading 'endLineNumberExclusive')
    at E.intersectsStrict (vscode-file://vscode-app/c:/Users/me/AppData/Local/Programs/Microsoft%20VS%20Code/resources/app/out/vs/workbench/workbench.desktop.main.js:96:10545)
    at D (vscode-file://vscode-app/c:/Users/me/AppData/Local/Programs/Microsoft%20VS%20Code/resources/app/out/vs/workbench/workbench.desktop.main.js:681:45393)
    at vscode-file://vscode-app/c:/Users/me/AppData/Local/Programs/Microsoft%20VS%20Code/resources/app/out/vs/workbench/workbench.desktop.main.js:681:47301
    at w (vscode-file://vscode-app/c:/Users/me/AppData/Local/Programs/Microsoft%20VS%20Code/resources/app/out/vs/workbench/workbench.desktop.main.js:85:8256)
    at vscode-file://vscode-app/c:/Users/me/AppData/Local/Programs/Microsoft%20VS%20Code/resources/app/out/vs/workbench/workbench.desktop.main.js:681:47296
2023-11-22 13:40:04.384 [error] Cannot read properties of undefined (reading 'endLineNumberExclusive'): TypeError: Cannot read properties of undefined (reading 'endLineNumberExclusive')
    at E.intersectsStrict (vscode-file://vscode-app/c:/Users/me/AppData/Local/Programs/Microsoft%20VS%20Code/resources/app/out/vs/workbench/workbench.desktop.main.js:96:10545)
    at D (vscode-file://vscode-app/c:/Users/me/AppData/Local/Programs/Microsoft%20VS%20Code/resources/app/out/vs/workbench/workbench.desktop.main.js:681:45393)
    at vscode-file://vscode-app/c:/Users/me/AppData/Local/Programs/Microsoft%20VS%20Code/resources/app/out/vs/workbench/workbench.desktop.main.js:681:47301
    at w (vscode-file://vscode-app/c:/Users/me/AppData/Local/Programs/Microsoft%20VS%20Code/resources/app/out/vs/workbench/workbench.desktop.main.js:85:8256)
    at vscode-file://vscode-app/c:/Users/me/AppData/Local/Programs/Microsoft%20VS%20Code/resources/app/out/vs/workbench/workbench.desktop.main.js:681:47296

Edit to add: One other thing I observe is the only-shows-deleted behavior seems to happen on the second or later Replace (Ctrl+Shift+1) operation in the same file. Clicking a find result in a different file and then clicking back to the offending file seems to "reinitialize" things into a working state that shows the addition and removal as expected.

Edit to add again: This seems to be happening in the Replace Preview editor today. I'm not sure how to judge whether what I'm seeing today is related to the original issue or not since it's similar squirrely behavior in diffing. Sorry if this is in fact a distinct issue.

hediet commented 11 months ago

This actually might be a duplicate of https://github.com/microsoft/vscode/issues/198516 which I already fixed last week in insiders. Thanks so much @JoshHarmon for the log! That was super helpful to track this down.

hediet commented 11 months ago

Closing as duplicate of https://github.com/microsoft/vscode/issues/198516.

dzid26 commented 11 months ago

Are you sure this is fixed? If you look in the first post of the issue, the split screen screenshot is not correct either -it's missing deleted lines decorations. I just had the same behaviour as that screenshot.

Missing deleted line decorations in split view: image And inline view doesn't show anything: image

This happened after "Staging Selected Ranges". Reloading the window fixes it temporarily: image image

dzid26 commented 11 months ago

Nevermind, I think your fix didn't go to release yet

Version: 1.84.2 (user setup) Commit: 1a5daa3a0231a0fbba4f14db7ec463cf99d7768e Date: 2023-11-09T10:51:52.184Z Electron: 25.9.2 ElectronBuildId: 24603566 Chromium: 114.0.5735.289 Node.js: 18.15.0 V8: 11.4.183.29-electron.0 OS: Windows_NT x64 10.0.22631

jbnv commented 10 months ago

This issue is most certainly not resolved. I've had this problem for several months but it was always "fixed" by closing and restarting Code. As of today it's happening about every five files or so. Developer: Reload Window is an effective workaround only when the problem happens infrequently; but when I'm trying to review hundreds of files to push a bug fix into production, it's not an effective workaround. The issue that this issue "duplicates" doesn't mean anything to me.

It's definitely a cross-browser issue. I'm using Ubuntu and at least two of the people reporting the bug in this thread are using Windows.

Can someone give me a status on this that I can explain easily to my boss? Thanks.

Version: 1.85.1 Commit: 0ee08df0cf4527e40edc9aa28f4b5bd38bbff2b2 Date: 2023-12-13T09:47:11.635Z Electron: 25.9.7 ElectronBuildId: 25551756 Chromium: 114.0.5735.289 Node.js: 18.15.0 V8: 11.4.183.29-electron.0 OS: Linux x64 5.4.0-169-generic snap

hediet commented 10 months ago

@jbnv Please see the issue here.

The fix just landed last week, so it will be available in next months release (https://github.com/microsoft/vscode/commit/17e0dec8cf3a60d75e5517093752af6f8e8e1978). Feel free to use VS Code insiders, which already contains the fix,

Also, please share the logs of the dev tools the next time this happens. This helps to verify that the bugfix indeed fixes your issue.