[Bug] DiffEditor folding not working properly after setting new model
Reproducible in vscode.dev or in VS Code Desktop?
- [x] Not reproducible in vscode.dev or VS Code Desktop
Reproducible in the monaco editor playground?
- [ ] Not reproducible in the monaco editor playground
Monaco Editor Playground Link
https://microsoft.github.io/monaco-editor/playground.html?source=v0.52.2#XQAAAAKoCgAAAAAAAABBqQkHQ5NjdU_A3v_fvV7aSEHtA0Rvtgnl-tR47YVb6__LUAu4rUHJIRdn1oa9jNB9v2vq4CUrhXrWjtMMM8X0C7Z_YtNjG6APzg1S-UugxEewoi7qbHucAZkjd3ATahfN5E6U2gvZ2pblJ6ztRAw-e76euqBZDWQfSisulxuR9nmgYLjWZIOTdWPQxIW8e3fdW_GGJcwCZa2yNj4ZroqBDYfUn3JtmbMr-i9b8ebtXOTvWj8-vb-mi5NFtmrwimi8ViNZZQ4w3HGCFfT2gwlSMVi54FbgkkZdOY-IminkQ2qq-eAJWT1dHmtnuhc1PC28MpIctp5hHHisrQl8H8ezXcMTfTEINk5JXV20y1Iva8ICgZP78jrlIJUkAuHD_gJur8JlBZiYn2kF7loZfc4g6OzSo32_A-KIp_3MQP8wkcHwjiiJGmBi7Mkik9ESUIxCEUst93_4uxpW0z8tEnV9_mOrcxJ_K-ZlIKujZ2ZH3WtkvAnQ8p1yy33ZPC0mj1qKIVYdJjB1jo0sdN4ZjyaJWe7lMyv3xY6MSltyryAcTULKoJ7_0ghWqizlaxMavj6msrXCSYfi1zh00SlYvBdUrMIWo2QyntagkC_1RHV-gO0eQracjyR9KIwmDawKdtoY09rfA5W53heFVFqYLI9d6WeAkmsJ2K5hCCW-qLVsL0UQaNFQ6vaXH_JGrU68MRLqftxNzE1g_o1i0E6SJ-61fGwMhzrvFj14yRuAJNeGZJfk-8rwY1SkE3udYsZvYWZUyWws4pj_XuFM4B-nWq47RVvKOFG-7xMpdbdfeP_DN6EO
Monaco Editor Playground Code
var originalModelText = "This line is removed on the right.\njust some text\nabcd\nefgh\nSome more textjust some text\nabcz\nzzzzefgh\nSome more text.\nThis line is removed on the left.just some text\nabcz\nzzzzefgh\nSome more text.\nThis line is removed on the left.just some text\nabcz\nzzzzefgh\nSome more text.\nThis line is removed on the left.just some text\nabcz\nzzzzefgh\nSome more text.\nThis line is removed on the left.just some text\nabcz\nzzzzefgh\nSome more text.\nThis line is removed on the left.just some text\nabcz\nzzzzefgh\nSome more text.\nThis line is removed on the left.just some text\nabcz\nzzzzefgh\nSome more text.\nThis line is removed on the left.just some text\nabcz\nzzzzefgh\nSome more text.\nThis line is removed on the left."
var modifiedModelText = "just some text\nabcz\nzzzzefgh\nSome more text.\nThis line is removed on the left.just some text\nabcz\nzzzzefgh\nSome more text.\nThis line is removed on the left.just some text\nabcz\nzzzzefgh\nSome more text.\nThis line is removed on the left.just some text\nabcz\nzzzzefgh\nSome more text.\nThis line is removed on the left.just some text\nabcz\nzzzzefgh\nSome more text.\nThis line is removed on the left.just some text\nabcz\nzzzzefgh\nSome more text.\nThis line is removed on the left.just some text\nabcz\nzzzzefgh\nSome more text.\nThis line is removed on the left.just some text\nabcz\nzzzzefgh\nSome more text.\nThis line is removed on the left.just some text\nabcz\nzzzzefgh\nSome more text.\nThis line is removed on the left. and another diff something"
var originalModel = monaco.editor.createModel(
originalModelText,
"text/plain"
);
var modifiedModel = monaco.editor.createModel(
modifiedModelText,
"text/plain"
);
var diffEditor = monaco.editor.createDiffEditor(
document.getElementById("container"),
{
// You can optionally disable the resizing
enableSplitViewResizing: false,
readOnly: true,
hideUnchangedRegions: { enabled: true },
}
);
diffEditor.setModel({
original: originalModel,
modified: modifiedModel,
});
window.viewMode = () => {
diffEditor.getModifiedEditor().getModel().setValue(modifiedModelText + 'asd');
diffEditor.updateOptions({
readOnly: true,
hideUnchangedRegions: { enabled: true },
});
diffEditor.trigger('fold', 'editor.foldAll')
}
window.editMode = () => {
diffEditor.getModifiedEditor().getModel().setValue(modifiedModelText);
diffEditor.updateOptions({
readOnly: false,
hideUnchangedRegions: { enabled: false },
});
diffEditor.trigger('unfold', 'editor.unfoldAll')
}
Reproduction Steps
- Click EditMode button to unfold and add some text
- Click ViewMode button to return to readonly state and fold code
- Unchanged code didnt collapse
Actual (Problematic) Behavior
Looks like after setting new model folding feature is not working properly and doesnt collapse unchanged code. (Buttons for expanding/collapsing folding are working)
Expected Behavior
After changing model, turning on folding again should fold and collapse not changed code
Additional Context
No response