Bug 345253 - Folder I'm currently in not restored when selecting "Open file" with remote protocol
Summary: Folder I'm currently in not restored when selecting "Open file" with remote p...
Status: RESOLVED UPSTREAM
Alias: None
Product: kate
Classification: Applications
Component: general (show other bugs)
Version: 5.0.0
Platform: Ubuntu Linux
: NOR normal
Target Milestone: ---
Assignee: KWrite Developers
URL:
Keywords:
: 346721 353794 (view as bug list)
Depends on:
Blocks:
 
Reported: 2015-03-17 11:00 UTC by rgpublic
Modified: 2016-05-16 20:11 UTC (History)
11 users (show)

See Also:
Latest Commit:
Version Fixed In:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description rgpublic 2015-03-17 11:00:00 UTC
I'm on the new Kubuntu Beta 1 with KDE5. Under KDE4 when I clicked on "File"=>"Open" the directory of the file I'm currently editing was opened. This was extremely useful, because I often want to open files from the same directory. Now, I always start with my home folder and have to navigate again and again to the files. I'm badly missing the old functionality. The problem only occurs with remote files (FISH).

Reproducible: Always

Steps to Reproduce:
1. Open any file on a remote (SSH/"FISH") server
2. Click "open file" again


Actual Results:  
I'm in the home folder

Expected Results:  
I'm in the folder of the file I'm currently editing in the editor - just like it happens with local files.
Comment 1 Nikola Kovacs 2015-04-27 13:45:58 UTC
This still works with gwenview, but gwenview uses KFileDialog.
I wrote a small app to test this. QFileDialog does not work with "sftp:/" or "remote:/", even though it's using the native dialog.
Comment 2 Nikola Kovacs 2015-04-27 16:22:11 UTC
Here's the problem:
https://github.com/qtproject/qtbase/blob/v5.4.1/src/widgets/dialogs/qfiledialog.cpp#L2203
QUrl::fromLocalFile(dir) mangles sftp urls.

You should use getOpenFileUrls instead of getOpenFileNames.

This at least passes the url correctly to kdeplatformfiledialoghelper, but it still doesn't work.
Comment 3 Nikola Kovacs 2015-04-27 18:36:03 UTC
Sorry, Kate and Kwrite do use "getOpenFileUrls" for opening files, so it looks like the bug is in kdeplatformfiledialoghelper.
Comment 4 rgpublic 2015-06-25 09:42:30 UTC
Any update on when this might be fixed? BTW: What I find really amazing is that no one else seems to be complaining about this bug? Doesn't it occur on all distros? What am I doing differently? How does anyone else live with navigating 10 folders deep again and again for every single file they open? For me, Kate has become totally unusable due to this. I'm really puzzled that no one seems to bother...
Comment 5 Kåre Särs 2015-06-25 10:11:14 UTC
Most people probably only use local files, where it is not a problem. Are you able to use sshfs to mount the remote folder until it is fixed?
Comment 6 rgpublic 2015-06-25 11:45:13 UTC
Ah, ok. That might explain it. SSHFS is unfortunately as slow as a Galapagos turtle on tranqulizer. And the fact that I need to open files on lots of different servers with different network protocols doesn't help either. Oh, well. The great thing about Kate and KDE in general was always the network transparency. I'm currently using a different editor as a workaround which at least has some protocols built-in - nevertheless I miss Kate a lot - that's why I was asking if there is any progress on this. Thanks anyway, I'll wait patiently...
Comment 7 Alexander Potashev 2015-06-25 14:05:31 UTC
*** Bug 346721 has been marked as a duplicate of this bug. ***
Comment 8 Kåre Särs 2015-06-28 20:31:12 UTC
This looks like a bug in either frameworksintegration, Qt or KIO
I have not figured out which one yet. At some point the initial directory is overwritten..
Comment 9 Nikola Kovacs 2015-06-29 08:20:23 UTC
These two don't work:

QFileDialog::getOpenFileUrls(this, "Open File", QUrl("sftp://user@example.org:22/home/user/"));

QFileDialog::getOpenFileUrls(this, "Open File", QUrl("remote:/"));

This works:

KFileDialog dialog(QUrl("sftp://user@example.org:22/home/user/"), "", this);
dialog.exec();

I've tried to debug QFileDialog, it looks like it initially sets the url, and I couldn't figure out where it gets overridden.
Comment 10 Kåre Särs 2015-06-29 08:34:11 UTC
I'm suspecting that the problem might be related to:
void QFileDialogPrivate::helperPrepareShow(QPlatformDialogHelper *)

In this function we have a call to  options->setInitialDirectory(), but I can not confirm that this is the problem yet, and I do not know yet what the proper solution would be in that case.
Comment 11 EMR_Kde 2015-08-20 14:28:01 UTC
Same problem here, under KDE4 everything worked fine, with KF5, when I go to open a file it takes me to my home directory instead of whatever sftp:// directory I was at, while I have an open sftp:// file.
Comment 12 Kåre Särs 2015-08-20 20:16:00 UTC
This should be fixed in newer versions of Qt and Frameworks (I think it was fixed in Qt 5.5 and a workaround in KF5 5.13)
Comment 13 EMR_Kde 2015-09-09 17:43:00 UTC
So, in their fixing it, they kinda broke it. So now when I have a file open via sftp, if I go to File -> Open, it attempts to open the actual full path/filename instead of the dirname.

Reproduce: 
1) open a file via sftp (sftp://foo.example.com/home/smithj/myfile.txt)
2) edit the file and save it
3) goto file -> open
4) error dialog comes up: The file or folder sftp://foo.example.com/home/smithj/myfile.txt does not exist.

It's trying to go to that directory, but it's actually the file you have open instead.
Comment 14 EMR_Kde 2015-09-09 17:45:21 UTC
(when you click OK in the dialog box, in the directory line edit there's the full path/filename instead of just the path. In the above example it should be sftp://foo.example.com/home/smithj.) Should I open a new bug?
Comment 15 Michael Ziegler 2015-09-15 08:43:33 UTC
JFTR, you're not alone. Debian recently updated Kate in unstable, and this is beyond the first things I noticed. Now I'm waiting for them to update to a version where this bug is fixed.

In the meantime, I found that having two unnamed files open helps:

1. Open some remote file.
2. Hit ^o. Be presented a file open dialog located in ~. Close the dialog in frustration.
3. Hit ^n ^n.
4. Select the remote file in the documents tree. (I haven't tried the tabs.)
5. Select one of the unnamed files (doesn't seem to matter which one).
6. Hit ^o. The open file dialog should now try to browse the remote file as a directory (see https://bugs.kde.org/show_bug.cgi?id=352490), which is more closely to what we actually want.

Works at least for Kate 15.08.0.

Michael
Comment 16 Kåre Särs 2015-10-12 06:06:22 UTC
*** Bug 353794 has been marked as a duplicate of this bug. ***
Comment 17 Jakob Simon-Gaarde 2015-10-13 10:42:59 UTC
Funny thing about this bug is that "Save as..." seems to work. I also badly need "open..." to work but for now I have found a work-around just be careful:

Pres "Save as..." to open the correct folder then drag the file you need to open to the main kate window.

/ JAkob
Comment 18 Andreas Hartmetz 2016-03-29 15:36:54 UTC
Regarding the wrong path in open dialog, see bug 352490.