microsoft / vscode

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

Comment Panel mis after when deleting first comment in comment thread #77663

Closed rebornix closed 5 years ago

rebornix commented 5 years ago

Issue Type: Bug

As we use the first comment as the root of a thread, when we delete the first comment, comments panel fail to render the whole thread.

VS Code version: Code - Insiders 1.37.0-insider (628bdedf671d3230fc76982fae845875a6f6c0da, 2019-07-19T08:10:27.295Z) OS version: Darwin x64 18.6.0

System Info |Item|Value| |---|---| |CPUs|Intel(R) Core(TM) i7-4770HQ CPU @ 2.20GHz (8 x 2200)| |GPU Status|2d_canvas: enabled
flash_3d: enabled
flash_stage3d: enabled
flash_stage3d_baseline: enabled
gpu_compositing: enabled
multiple_raster_threads: enabled_on
native_gpu_memory_buffers: enabled
oop_rasterization: disabled_off
protected_video_decode: unavailable_off
rasterization: enabled
skia_deferred_display_list: disabled_off
skia_renderer: disabled_off
surface_synchronization: enabled_on
video_decode: enabled
viz_display_compositor: disabled_off
webgl: enabled
webgl2: enabled| |Load (avg)|3, 4, 4| |Memory (System)|16.00GB (0.12GB free)| |Process Argv|-psn_0_6997676| |Screen Reader|no| |VM|0%|
Extensions (58) Extension|Author (truncated)|Version ---|---|--- spellright|ban|3.0.46 github-markdown-preview|bie|0.0.2 markdown-checkbox|bie|0.1.3 markdown-emoji|bie|0.0.9 markdown-preview-github-styles|bie|0.1.6 markdown-yaml-preamble|bie|0.0.4 npm-intellisense|chr|1.3.0 vscode-svgviewer|css|2.0.0 vscode-markdownlint|Dav|0.28.0 vscode-eslint|dba|1.9.0 xml|Dot|2.5.0 gitlens|eam|9.8.5 tsl-problem-matcher|eam|0.0.4 EditorConfig|Edi|0.13.0 tslint|eg2|1.0.44 vsc-material-theme|Equ|29.2.0 prettier-vscode|esb|1.9.0 flow-for-vscode|flo|1.1.4 vscode-pull-request-github-insiders|Git|2019.7.25382 ocaml|hac|0.6.43 beautify|Hoo|1.5.0 vscode-ghc-mod|hoo|1.2.0 references-plusplus|jri|0.0.5 language-haskell|jus|2.6.0 vscode-colorize|kam|0.8.11 graphql-for-vscode|kum|1.15.0 vscode-smoketest-check|mic|0.0.1 dotenv|mik|1.0.1 theme-monokai-pro-vscode|mon|1.1.13 vscode-azurefunctions|ms-|0.17.1 vscode-docker|ms-|0.7.0 vscode-language-pack-zh-hans|MS-|1.36.2 python|ms-|2019.6.24221 remote-containers|ms-|0.66.0 remote-ssh-edit-nightly|ms-|2019.7.23941 remote-ssh-explorer-nightly|ms-|2019.7.23940 remote-ssh-nightly|ms-|2019.7.23940 azure-account|ms-|0.8.4 cpptools|ms-|0.24.0 Go|ms-|0.11.4 powershell|ms-|2019.5.0 vscode-typescript-tslint-plugin|ms-|1.2.2 wordcount|ms-|0.1.0 vsliveshare|ms-|1.0.540 debugger-for-chrome|msj|4.11.6 debugger-for-ios-web|msj|0.1.2 vetur|oct|0.21.1 subtitles-editor|pep|1.0.4 vscode-versionlens|pfl|0.24.0 material-icon-theme|PKi|3.8.1 seti-icons|qin|0.1.3 smartpaste|reb|0.0.3 toggle|reb|0.0.1 sass-indented|rob|1.5.1 rust|rus|0.6.1 sourcekit-lsp|unp|0.0.1 vscode-lldb|vad|1.2.3 vscode-swiftformat|vkn|1.3.2 (12 theme extensions excluded)
rebornix commented 5 years ago

It turns out to be related to how the tree refreshes itself. In Comments Panel, we use the first node as the container of all comments in a thread, say a comment thread with 3 comments a, b, c, it's rendered as

- fileName
  - a
    - b
    - c

when we remove the first node of the comment thread, we call tree.refresh and at this moment, the data model for the tree becomes

- fileName
  - b
    - c

when the tree attempts to create node b again, it throws exception Error: Assertion failed (item already registered.

@joaomoreno I suppose we are still using the old tree api, if so does the new tree potentially have the same issue? Any suggestion for quickly workaround this issue?

joaomoreno commented 5 years ago

Unfortunately no quick suggestions apart from clearing the tree and resetting its content.

rebornix commented 5 years ago

Verification steps:

alexr00 commented 5 years ago

I tried to use https://github.com/microsoft/vscode-extension-samples/tree/master/comment-sample, but it is using an older version of vscode.d.ts. I copied in the newer version, but now I get an empty comment when I try to create a comment on line 1:

empty comment
rebornix commented 5 years ago

I updated the comment sample with the right typings. Please

Then you should be able to operate like below

comment-sample