leodevbro / vscode-blockman

VSCode extension to highlight nested code blocks
https://github.com/leodevbro/vscode-blockman
MIT License
345 stars 16 forks source link

Feature Request: Option to disable for diff comparison #112

Open snaphat opened 1 year ago

snaphat commented 1 year ago

Blockman can be bit busy when viewing side by side comparisons such that distracts from the actual differences. I would like to request a option to automatically disable blockman for diff views.

leodevbro commented 1 year ago

Thank. I hope I will have time soon to try implementing this feature request. Right now you can toggle disable/enable Blockman with F1 command: >Blockman Toggle Enable/Disable or >Blockman Toggle Enable/Disable And Force Show/Hide Indent Guides

leodevbro commented 1 year ago

So far I found these solutions:

if (editor.document.uri.scheme === "git") {
    // this editor is the left side of the diff
}
const theUri = editor.document.uri.toString();

const trueOrFalse = window.tabGroups.all.some((tabGroup) =>
    tabGroup.tabs.some((tab) => {
        const tabInp: any = tab.input;

        return (
            tabInp?.modified?.toString() === theUri ||
            tabInp?.original?.toString() === theUri
        );
    }),
);

if (trueOrFalse) {
    // this editor has the document which is open in at least one diff editor
    // but this editor may not be the diff editor.
    // For example, maybe this editor is just a normal editor and this document is open in another editor which is diff editor.
}

Sources: https://github.com/microsoft/vscode/issues/36019 https://github.com/microsoft/vscode/issues/15513

So, for now, we can detect the left side of diff editor, but I could not find a solution to detect the right side of diff editor. I mean, as you can see in the above code samples, we can detect that the editor has the document which is open in at least one diff editor, but we cannot be sure that this editor is the diff editor itself.

If you or anyone finds a solution for it, please let me know.