GNOME Bugzilla – Bug 143646
gedit opens same file multiple times
Last modified: 2006-08-08 10:16:18 UTC
To reproduce: 1. open a file in gedit. 2. open the file again. Result: Two tabs each with a copy of the file Expected result: The second "open" switches to the existing buffer. This should also work for drag and drop so that 1. dropping an already open file switches to that tab 2. dropping multiple files only opens tabs for new files
Created attachment 30664 [details] [review] this patch should prevent opening of same file more than once.
*** Bug 162162 has been marked as a duplicate of this bug. ***
(silly me, I wrote the comments on the bug I was marking as duplicate, pasting them here for reference) I am not sure that forcing a "spatial behavior" on gedit (just one view per file) is the right thing to do: for instance opening the same file twice to compare the modified one from the original is a totally legit thing to do (and I do it from time to time). Beside every other text editor on earth allows you to open the same text file more than once, so I do not consider it a very surprising behavior. So I guess that this requires more thinking and discussions, a couple of things that come to my mind: 1 - would a popup dialog sayng "this file is already open, do you want to open another copy" be annoyng? 2 - note that the risk of losing some work if two different copys are edited would be milded by the use of file monitoring and/or by checking the mtime before saving (two issues which are already reported in other bugreports)
I think it would be a good thing to let the user decide what to do. There could be an addon on preferences... I see there's yet a patch, so it won't take much time to implement it. Answering at your points: 1. in my opinion it won't be annoying coz this lets the user know that he's risking to loose some data. As currently gedit is, everything happens silently. 2. If I've N opened files, with N big, I would prefer to have just one tab for a file, not 2/3/4...: the tab bar is limited by the screen resolution so it'll take more time to quickly switch from a file to another, there could be some confusions etc.. Anyway if you don't like the spatial way, you should at least offer it [as for instance nautilus does]. Under windows I always use Ultraedit that for default lets just one view per file...
I think we can get the best of both worlds easily enough. When we are about to open a file which is already open, we show a dialog with the choices: The file "%s" is already opened for editing. "Switch to opened file" "Open Read-Only" "Edit anyway" "Dont open" Also this dialog has a radiobutton "Always prompt" "Always switch to unmodified files" "Always switch" I think that covers all possible use cases. I'd suggest that most of the ui is in an "Advanced" expander, with the default dialog being a warning plus "open", "don't open" buttons.
An extra popup dialog to get in your face + another config option is hardly the best of both worlds. Both should be kept to a minimum, to avoid forcing the user to think about the internal workings of the application. However, multiple views of the same file is potentially interesting, so I would suggest the following: - open file should just read and open a new file, in a new tab, just as the user expects, and the way it is now. There is no need for special behavior. - right mouse button click on the tab, with a menu option there "Open new view", or - have the "New" menu item in the "File" menu bar become a submenu, and put "Document", "View", and so on in there. I would recommend the first approach, since it's totally non-intrusive.
Bert - keeping the current behaviour is bad because it's far too easy to cause data loss. Scenario: open file, make edits. open in other tab, make edits. Now theres no way to save both edits. Indeed, currently you don't even get warned! The solution is to make sure the second set of edits don't happen in the first place. You could share the textbuffer between the views, but IMHO it's more intuitive to share the views too. Re: views. Multiple views can be useful, but only as a split pane within a tab so two or more areas are visible at once. I cannot imagine a good use case for multiple view in separate tabs.
See also bug #167867
*** Bug 167867 has been marked as a duplicate of this bug. ***
*** Bug 301510 has been marked as a duplicate of this bug. ***
Paolo, ok sorry I didn't see the dup. this really annoys many people cause they cannot trust gedit to hack/work seriously. plz fix it asap :)
How tightly integrated is the view with the document data? Would it be possible to have several views into the same document? I.e. if I change the text in one view the changes will be reflected in all others. This seems to be what comment 7 is getting at but I don't agree that split pane is necessary. Since you can pull off tabs you can have the views side by side with the current system. And in many cases it's just useful to be able to keep several views at different points in the document.
Making two views reflect the changes is possible, but it just complicates things without real gain, since one of the reason to keep the same doc open two times is to be able to compare two diverging versions of the doc. At the moment the solution we plan is to warn the user user when he opens the file the second time and give him the choice to 1) just read it making the view Read Only or 2) Edit anyway
I also like the idea of a dialog to ask the user, but it shouldn't be as complicated as the one above. How about just " File already open. The file is already open. Would you like to open it in a second read-only tab? [Cancel] [Show existing tab] [Open in new tab] " That should cover most cases. Even if it doesn't cover everything, it would be a big improvement over what we have now.
Created attachment 54909 [details] screenie it currently look like this in new_mdi
What does 'Dont edit' mean? Close or read-only? Perhaps this text should be something more obvious. And why the firefox-esqe placement of the error? Is GNOME going in this direction? Otherwise it seems like a big UI discrepance for little gain. </nitpick> I think it's great that you're working on this function so this is meant as constructive critisism, not whining. :)
Wording improvements and suggestions are always welcome... 'Don't Edit' means read-only, we decided to not close the document since chances are that the user opened it on purpose, beside closing is just as easy by normally closing the tab. The firefoxesque error messages are an UI decisions we adopted for every error that affects just one document so that it doesn't block all the other tabs like a dialog would do. As far as I know, epiphany also uses per tab error pages.
Seems great to me. Good also is the choice of not using a dialog block to notify the user. Perhaps the "don't edit" would be more understandable by "let it read only" or just "read only".
The multiple-open-copies of a document thing is particularly annoying when using external tools in cooperation with Gedit. My preference here would be (a) when a file is being opened from the shell on an existing Gedit instance, it *doesn't* open a new copy of the file, it just raises the existing open file. (b) when a file is being opened from the File..Open dialog inside Gedit, the user should be prompted "Open another copy?", along with "always yes", "always no", "yes" and "no", plus settings in the preferences to govern this.
Someone suggested to reuse the buffer from the already opened version of the document, so that both are keeped in sync.
GtkTextView/GtkSourceView support for multiple views of the same document is broken by design. There is no way we can implement this in a sane way without rewriting GtkTextView.
Steve, it's a nice though! I really like this (I love it in OOoWriter) Paolo, are you sure about textview? gtk-demo text widget --> multiple views seems to does it
pbor and I discussed this topic on IRC. We propose the following solution: - if the file is already open in the same window, then the tab is raised and the file is not open twice - otherwise, we open the file and show the warning message. For historical reasons I put here the IRC log (in italian): paolo riguardo al discorso dei documenti aperti due volte paolo stavo pensando ad un possibile "compromesso" paolo ossia se il file si trova nella stessa window paolo allora seleziona la tab paolo altrimenti, se è in una altra finestra mostra il warning paolo come or paolo a pbor o nello stesso workspace paolo beh... quella mi sembra una finezza in più pbor pero a quel punto bisognerebbe aggoungere un menu item per aprire un'altra copia del doc corrente... paolo perchè? pbor e aggiungere una command line option per forzare l'apertura invece del raise paolo semplicemente non è possibile farlo pbor ma a volte io voglio farlo paolo apri un altra finestra e non rompi :) pbor hehe pbor ok pbor almeno concedimi la command line option pbor :) paolo piuttosto possiamo aggiungere una voce di menu "New Window" pbor potremmo mostrare il warning quando fai File->open pbor e invece fare il raise se semplicemente fai il double click pbor o magari no pbor sarebbe un po incasinato paolo infatti pbor ok, per me va bene il raise di default
Just make sure that virtual desktops are handled in a sane manner. :)
Created attachment 65947 [details] [review] First version of a patch implementing my suggestion on comment #13 I have prepared a first version of a patch implementing my suggestion on comment #13. I have put it here for you testing pleasure and for comments. I still need to: - sanitize the list of files to open in order to remove duplicates (see the FIXME in the code) - rephrase the warning message we already have since it is broken (see bug #324491) and since it is now shown only if a duplicated document exists in another window. Suggestions are welcome.
It was comment #23, not #13
Created attachment 65961 [details] [review] Patch v.2 As patch v.1, but removes duplicates from "uris" list. The code still has a potential problem I don't think it is worth worrying about: you should be able to open the same file twice in the same window if you open a remote file and you are fast enough to open it in two different requests before the URI of the file is set. I don't think it can happen in practice and in any case you will get the warning message we already have now. hmmmm... re-reading the code, probably this potential problem does not exist. I leave the comment to remember to check this case again.
patch looks ok, the FIXME can now be removed.
We also need to modify the warning message in case the duplicated file is in a different window. Any suggestion?
What about: Primary: This file (%s) is already opened in another gedit window. Secondary: gedit opened the file in a non-editable way. Do you want to edit it anyway? This patch should really go in. I think it may annoy some people who actually want to open another instance of the file in the same window (because there is no way of doing that now). How about adding a yellow message to the already opened file giving the choice to open it in a new tab? (Sorry if this already came up in the discussion)
The problem with that is when windows are on different workspaces: switching workspace automatically is very confusing, moving the window to the current work space is even worse and annoying since chances are that it was on a workspace with other related windows opened (terminals, nautilus, epiphany etc)
Ok, since Paolo Maggi is away and time is running out for 2.16, we bit the bullet and committed the above patch after review/test and updated the message area message.
*** Bug 350348 has been marked as a duplicate of this bug. ***
How have you changed the message?
see comment #30: Primary: This file (%s) is already opened in another gedit window. Secondary: gedit opened the file in a non-editable way. Do you want to edit it anyway?