racket / drracket

DrRacket, IDE for Racket
http://www.racket-lang.org/
Other
447 stars 94 forks source link

Tab opened in a wrong window #439

Open sorawee opened 3 years ago

sorawee commented 3 years ago

Consider the following sequence of actions:

  1. Start DrRacket
  2. Open a Racket file (say, a.rkt) in a tab via File > Open (with "Open files in separate tabs" on)
  3. Open a new window
  4. Switch back to the previous window (that has a.rkt)
  5. Open a Racket file (say, b.rkt)

I expect that b.rkt will be be in the same window as a.rkt, but it's not.

IIUC, this is due to how open-drscheme-window tries to open a new tab in newest-frame, which is set to the most recent created window. I don't understand why that's a desirable behavior however.

rfindler commented 3 years ago

The issue with newest frame is that sometimes a frame is opened separately from when a file is opened, from the perspective of DrRacket, but not from the user's point of view and we don't want spurious empty windows hanging around.

It may be that this happens only with the very first window that DrRacket creates but I have some kind of vague memory that we can get into this situation in other ways too. Going back through the git history I'm not seeing something that would help explain why it is needed after that first frame is created, but maybe to be conservative maybe the right thing to do is to keep the current behavior only when the "open in tabs" preference is disabled?

sorawee commented 3 years ago

Yes, that would help.

I definitely agree with "we don't want spurious empty windows hanging around" when "open in tabs" preference is disabled, but note that newest-frame doesn't quite solve the problem either. For example, with "open in tabs" preference disabled:

  1. Open DrRacket
  2. Open a new window
  3. Open a new window
  4. Open a.rkt
  5. Open b.rkt

Only the most recent created window is "merged" with one of the opened files. The other created window is not.

rfindler commented 3 years ago

True! I'm open to better strategies if you have something in mind.