ContextKeeper / ContextKeeper.VisualStudio

Session Manager for Visual Studio
16 stars 0 forks source link

Single document did not restore a split window #10

Open PhilipJBeck opened 11 months ago

PhilipJBeck commented 11 months ago

Hi,

Following my review at https://marketplace.visualstudio.com/items?itemName=ContextKeeper.ContextKeeperVsix&ssr=false#review-details to clarify my comment, the positioning of single document windows (splitting left,right,top,bottom) worked fine. What didn't appear to work was the vertical split of a single document. So that you can look at line 100 in the top pain, then a horizontal split bar, then line 1000 in the lower pane of the same document window.

Thanks Phil

PiotrKarczmarz commented 11 months ago

Hi Phil! Thanks for clarification and really fast response! Indeed splitting the same document is not supported yet. But it will be supported, if only there is a way to implement it using VS API or any other hack I'll find 🤞

Those small details like:

are really important for the whole context. I'm adding a graphical diagram for future reference down below:

image

PhilipJBeck commented 11 months ago

Hi Piotr,

I had a quick google just now and couldn't find any programmatic way of doing it. At least the first few hits were all user / GUI descriptions.

So I asked ChatGPT. I don't know if the following is accurate or true....

Regards Phil

------markdown---------------------------------

Yes, using the Visual Studio API, it is possible to split a document window vertically. Visual Studio provides a comprehensive extensibility model that allows developers to manipulate the IDE's behavior, including window layout and user interface features.

To split a document window vertically, you would typically use the Window and Split methods provided by the DTE (Development Tools Environment) object. Here's a general outline of how you might achieve this using the Visual Studio API:

  1. Access the DTE Object: Obtain a reference to the DTE object, which represents the Visual Studio development environment.

  2. Retrieve the Active Window: Use the DTE object to access the active window (the document window you want to split).

  3. Split the Window Vertically: Call the Split method on the active window, specifying the desired vertical split ratio.

  4. Load Content into Each Pane: Load content (documents, views, etc.) into each pane of the split window as needed.

Here's a simplified example in C#:

using EnvDTE;

public void SplitDocumentWindowVertically(DTE dte)
{
    // Get the active window
    Window activeWindow = dte.ActiveWindow;

    // Split the window vertically (50% split ratio)
    activeWindow.Split(vsPaneSplitType.pstVertical, 2);

    // Load content into each pane if needed
    // For example:
    activeWindow.Visible = true;  // Make the active window visible

    // Load content into each pane as needed
    // activeWindow.SetDocumentContent(...)
}

In this example, we're splitting the active window vertically with a 50% split ratio, creating two panes. You can adjust the split ratio according to your specific requirements.

Keep in mind that the actual implementation may vary based on your exact use case and requirements. You'll need to use the Visual Studio API documentation and experiment to tailor the functionality to your needs.

On Fri, 29 Sept 2023 at 10:14, Piotr Karczmarz @.***> wrote:

Hi Phil! Thanks for clarification and really fast response! Indeed splitting the same document is not supported yet. But it will be supported, if only there is a way to implement it using VS API or any other hack I'll find 🤞

Those small details like:

  • like horizontal split bar for the same document,
  • opening the same file in multiple windows,

are really important for the whole context. I'm adding a graphical diagram for future reference down below:

[image: image] https://user-images.githubusercontent.com/8102322/271525504-e1e073a9-acdf-488f-b746-e320427e272d.png

— Reply to this email directly, view it on GitHub https://github.com/ContextKeeper/ContextKeeper.VisualStudio/issues/10#issuecomment-1740568685, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAWGR4KSVEFXAU5UNAUTSWLX42GP7ANCNFSM6AAAAAA5MDVREA . You are receiving this because you authored the thread.Message ID: @.***>

PiotrKarczmarz commented 11 months ago

Unfortunately ChatGPT is hallucinating, there is no such a method like activeWindow.Split() for active window from DTE object. For a second I've had hope that maybe this time it will be a little easier 😉

But the there is good news. After searching through VS internals I've found some promising code that may work!

PhilipJBeck commented 11 months ago

Sorry for the bad lead.

Looking forward to updates...

Regards Phil

On Thu, 5 Oct 2023, 17:43 Piotr Karczmarz, @.***> wrote:

Unfortunately ChatGPT is hallucinating, there is no such a method like activeWindow.Split() for active window from DTE object. For a second I've had hope that maybe this time it will be a little easier 😉

But the there is good news. After searching through VS internals I've found some promising code that may work!

— Reply to this email directly, view it on GitHub https://github.com/ContextKeeper/ContextKeeper.VisualStudio/issues/10#issuecomment-1749291640, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAWGR4ICKHNA527FHUZBBZLX53PSVAVCNFSM6AAAAAA5MDVRECVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTONBZGI4TCNRUGA . You are receiving this because you authored the thread.Message ID: @.***>