Author |
Message |
gemisigo
Joined: 11 Mar 2010 Posts: 2165
|
|
Q: Open files in existing editor |
|
Is there a way to open files in existing SQL Editor? I mean directly from the file manager, not by dropping the file on SQL Editor, or from a file open dialog opened by SQL Editor itself. Simply assigning SQL Editor to .sql filetype opens a new instance of the editor for each file.
|
|
Wed Dec 21, 2016 3:13 pm |
|
 |
gemisigo
Joined: 11 Mar 2010 Posts: 2165
|
|
|
|
There isn't?
|
|
Sun Mar 19, 2017 9:28 pm |
|
 |
SysOp
Site Admin
Joined: 26 Nov 2006 Posts: 7948
|
|
|
|
Turns out that is possible.
In SqlEditor.ini change
[SyntEditMain]
...
SQLEditorInstance.Active=True
|
|
Mon Mar 20, 2017 10:54 am |
|
 |
gemisigo
Joined: 11 Mar 2010 Posts: 2165
|
|
|
|
That's great. I'll try it ASAP, thank you very much.
|
|
Mon Mar 20, 2017 11:13 am |
|
 |
gemisigo
Joined: 11 Mar 2010 Posts: 2165
|
|
|
|
It works. Note that you have to edit SqlEditor.ini with SqlEditor closed else its contents will be overwritten the next time you close the editor which was open at the time the changes were made, and that could set SQLEditorInstance.Active back to False.
|
|
Wed Mar 29, 2017 7:30 am |
|
 |
gemisigo
Joined: 11 Mar 2010 Posts: 2165
|
|
|
|
What is the strategy of picking the target when there are multiple instances active? I had a theory that it opens it in the instance that was started last but I have no solid evidence on that. When using multiple instances on multiple virtual desktops, triggering this feature can cause quite a mess, by either moving the instances from their virtual desktop to the current virtual desktop or by making their desktop the current/active one.
|
|
Thu Mar 31, 2022 3:23 am |
|
 |
SysOp
Site Admin
Joined: 26 Nov 2006 Posts: 7948
|
|
|
|
Good question. My common sense is telling me that "active" means the one with an input focus. What else can be classified as "active"? But I'm afraid that's just a bad word choice on the part of developers. Internally Windows Explorer needs to send DDE request to the application associated with the file type, and ask if it can start a new conversation in order to receive file detaisl by DDE. But how does Windows Explorer know which one to send it too if there are multiple application instances. I believe it's either the very first one or very last one opened that registered itself as a target for such conversations.
|
|
Thu Mar 31, 2022 9:42 am |
|
 |
gemisigo
Joined: 11 Mar 2010 Posts: 2165
|
|
|
|
My thoughts exactly. Would you mind entering a feature enhancement request for this one on my behalf, please?
|
|
Thu Mar 31, 2022 10:49 am |
|
 |
SysOp
Site Admin
Joined: 26 Nov 2006 Posts: 7948
|
|
|
|
I think this is a generic issue outside of the SQL Editor. It's Windows Explorer choosing which application instance to send the request too.
On a related note, I just tested it with 12.1, and on my test system a new instance is always started for an open file. Something changed in that version, I don't know what. I sent a request for more details.
|
|
Thu Mar 31, 2022 12:31 pm |
|
 |
SysOp
Site Admin
Joined: 26 Nov 2006 Posts: 7948
|
|
|
|
I'm still checking with the team. But what I've found so far, I was totally wrong, and I have to apologize for misleading you. In 12.x it's not using standard DDE method for Windows Explorer to communicate with with editor, it's doing something proprietary for inter-process communications, which I still don't fully understand. Please give me more time to learn about what's going on there.
|
|
Fri Apr 01, 2022 9:11 am |
|
 |
SysOp
Site Admin
Joined: 26 Nov 2006 Posts: 7948
|
|
|
|
In 12.x it's always the first instance unless it's busy and not responding to interprocess requests.
It's not using DDE internally, it's using a different kind of interprocess communication.
|
|
Mon Apr 04, 2022 10:40 am |
|
 |
gemisigo
Joined: 11 Mar 2010 Posts: 2165
|
|
|
|
I see. That only works properly when you have a single instance or it is the first one you want to send the file to. I assume that happens most of the time for most users but usually not in my case, I rarely have less than three instances open simultaneously.
Anyway, thank you very much for the info. I'll try to create an AutoHotkey script that I'll pass the file name to instead of passing it to SQL Editor and make that script handle the rest (make SE active, open dialogs, select file(s), etc). AutoHotkey can reliably determine which instance is the active one. By active I mean which one was the last used, it's certainly not "active" active when being addressed from another application that has the focus/foreground.
|
|
Tue Apr 05, 2022 10:21 am |
|
 |
SysOp
Site Admin
Joined: 26 Nov 2006 Posts: 7948
|
|
|
|
You can use drag-and-drop to open it in the instance you want. Drag-and-drop is yet different mechanism.
Would that work?
|
|
Tue Apr 05, 2022 11:12 am |
|
 |
gemisigo
Joined: 11 Mar 2010 Posts: 2165
|
|
|
|
No can do. The reason I was so happy with this feature is that I was able to make SE directly open the file from another editor, bypassing the file manager completely, thus removing the manual step of having to find, select and drag-and-drop the file, which was both slow and error-prone. I only tested it from the file manager when I noticed it opens a new SE instance for each file to see if it makes any difference.
|
|
Wed Apr 06, 2022 6:47 am |
|
 |
SysOp
Site Admin
Joined: 26 Nov 2006 Posts: 7948
|
|
|
|
Have you had a chance to try that in 12.1.277?
It may open a new instance if it finds the first opened busy with something and not responding within several seconds to the file handling request
|
|
Wed Apr 06, 2022 8:19 am |
|
 |
|