rubberduck-vba / Rubberduck

Every programmer needs a rubberduck. COM add-in for the VBA & VB6 IDE (VBE).
https://rubberduckvba.com
GNU General Public License v3.0
1.91k stars 299 forks source link

CodePaneSubClass is only hooked on newly-created windows #4080

Closed DGagne25 closed 6 years ago

DGagne25 commented 6 years ago

Auto Complete will works only if I create a new object (module, form, etc), and only in that new object.

After saving, closing Access and reopen, the Auto Complete is not working for all objects.

I tested this on 3 different PC, with similar spec.

Logs:

2018-06-13 10:54:37.4033;TRACE-2.2.6737.8365;Rubberduck.Common.LogLevelHelper;
    Rubberduck version 2.2.6737.8365 loading:
    Operating System: Microsoft Windows NT 6.1.7601 Service Pack 1 x64
    Host Product: Microsoft Office 2013 x86
    Host Version: 15.0.4963.1000
    Host Executable: MSACCESS.EXE;
2018-06-13 10:54:37.4253;TRACE-2.2.6737.8365;Rubberduck.App;Checking for legacy Smart Indenter settings.;
2018-06-13 10:54:37.6453;TRACE-2.2.6737.8365;Rubberduck.Common.Hotkeys.Hotkey;Hotkey for the associated command Rubberduck.UI.Command.Refactorings.CodePaneRefactorRenameCommand was registered with id 49601;
2018-06-13 10:54:37.6453;TRACE-2.2.6737.8365;Rubberduck.Common.Hotkeys.Hotkey;Hotkey for the associated command Rubberduck.UI.Command.Refactorings.RefactorEncapsulateFieldCommand was registered with id 49596;
2018-06-13 10:54:37.6453;TRACE-2.2.6737.8365;Rubberduck.Common.Hotkeys.Hotkey;Hotkey for the associated command Rubberduck.UI.Command.Refactorings.RefactorMoveCloserToUsageCommand was registered with id 49602;
2018-06-13 10:54:37.6453;TRACE-2.2.6737.8365;Rubberduck.Common.Hotkeys.Hotkey;Hotkey for the associated command Rubberduck.UI.Command.CodeExplorerCommand was registered with id 49603;
2018-06-13 10:54:37.6453;TRACE-2.2.6737.8365;Rubberduck.Common.Hotkeys.Hotkey;Hotkey for the associated command Rubberduck.UI.Command.ExportAllCommand was registered with id 49604;
2018-06-13 10:54:37.6453;TRACE-2.2.6737.8365;Rubberduck.Common.Hotkeys.Hotkey;Hotkey for the associated command Rubberduck.UI.Command.FindSymbolCommand was registered with id 49605;
2018-06-13 10:54:37.6453;TRACE-2.2.6737.8365;Rubberduck.Common.Hotkeys.Hotkey;Hotkey for the associated command Rubberduck.UI.Command.IndentCurrentModuleCommand was registered with id 49606;
2018-06-13 10:54:37.6453;TRACE-2.2.6737.8365;Rubberduck.Common.Hotkeys.Hotkey;Hotkey for the associated command Rubberduck.UI.Command.IndentCurrentProcedureCommand was registered with id 49607;
2018-06-13 10:54:37.6453;TRACE-2.2.6737.8365;Rubberduck.Common.Hotkeys.Hotkey;Hotkey for the associated command Rubberduck.UI.Command.InspectionResultsCommand was registered with id 49608;
2018-06-13 10:54:37.6453;TRACE-2.2.6737.8365;Rubberduck.Common.Hotkeys.Hotkey;Hotkey for the associated command Rubberduck.UI.Command.ReparseCommand was registered with id 49609;
2018-06-13 10:54:37.6453;TRACE-2.2.6737.8365;Rubberduck.Common.Hotkeys.Hotkey;Hotkey for the associated command Rubberduck.UI.Command.TestExplorerCommand was registered with id 49610;
2018-06-13 10:54:37.6693;INFO-2.2.6737.8365;Rubberduck.UI.Command.VersionCheckCommand;Executing version check.;
2018-06-13 10:54:42.5638;TRACE-2.2.6737.8365;Rubberduck.Common.Hotkeys.Hotkey;Hotkey for the associated command Rubberduck.UI.Command.Refactorings.CodePaneRefactorRenameCommand was registered with id 49610;
2018-06-13 10:54:42.5638;TRACE-2.2.6737.8365;Rubberduck.Common.Hotkeys.Hotkey;Hotkey for the associated command Rubberduck.UI.Command.Refactorings.RefactorEncapsulateFieldCommand was registered with id 49609;
2018-06-13 10:54:42.5638;TRACE-2.2.6737.8365;Rubberduck.Common.Hotkeys.Hotkey;Hotkey for the associated command Rubberduck.UI.Command.Refactorings.RefactorMoveCloserToUsageCommand was registered with id 49608;
2018-06-13 10:54:42.5638;TRACE-2.2.6737.8365;Rubberduck.Common.Hotkeys.Hotkey;Hotkey for the associated command Rubberduck.UI.Command.CodeExplorerCommand was registered with id 49607;
2018-06-13 10:54:42.5638;TRACE-2.2.6737.8365;Rubberduck.Common.Hotkeys.Hotkey;Hotkey for the associated command Rubberduck.UI.Command.ExportAllCommand was registered with id 49606;
2018-06-13 10:54:42.5638;TRACE-2.2.6737.8365;Rubberduck.Common.Hotkeys.Hotkey;Hotkey for the associated command Rubberduck.UI.Command.FindSymbolCommand was registered with id 49605;
2018-06-13 10:54:42.5638;TRACE-2.2.6737.8365;Rubberduck.Common.Hotkeys.Hotkey;Hotkey for the associated command Rubberduck.UI.Command.IndentCurrentModuleCommand was registered with id 49604;
2018-06-13 10:54:42.5638;TRACE-2.2.6737.8365;Rubberduck.Common.Hotkeys.Hotkey;Hotkey for the associated command Rubberduck.UI.Command.IndentCurrentProcedureCommand was registered with id 49603;
2018-06-13 10:54:42.5638;TRACE-2.2.6737.8365;Rubberduck.Common.Hotkeys.Hotkey;Hotkey for the associated command Rubberduck.UI.Command.InspectionResultsCommand was registered with id 49602;
2018-06-13 10:54:42.5638;TRACE-2.2.6737.8365;Rubberduck.Common.Hotkeys.Hotkey;Hotkey for the associated command Rubberduck.UI.Command.ReparseCommand was registered with id 49596;
2018-06-13 10:54:42.5638;TRACE-2.2.6737.8365;Rubberduck.Common.Hotkeys.Hotkey;Hotkey for the associated command Rubberduck.UI.Command.TestExplorerCommand was registered with id 49601;
2018-06-13 10:54:57.6933;TRACE-2.2.6737.8365;Rubberduck.Common.Hotkeys.Hotkey;Hotkey for the associated command Rubberduck.UI.Command.Refactorings.CodePaneRefactorRenameCommand was registered with id 49601;
2018-06-13 10:54:57.6933;TRACE-2.2.6737.8365;Rubberduck.Common.Hotkeys.Hotkey;Hotkey for the associated command Rubberduck.UI.Command.Refactorings.RefactorEncapsulateFieldCommand was registered with id 49596;
2018-06-13 10:54:57.6933;TRACE-2.2.6737.8365;Rubberduck.Common.Hotkeys.Hotkey;Hotkey for the associated command Rubberduck.UI.Command.Refactorings.RefactorMoveCloserToUsageCommand was registered with id 49602;
2018-06-13 10:54:57.6933;TRACE-2.2.6737.8365;Rubberduck.Common.Hotkeys.Hotkey;Hotkey for the associated command Rubberduck.UI.Command.CodeExplorerCommand was registered with id 49603;
2018-06-13 10:54:57.6933;TRACE-2.2.6737.8365;Rubberduck.Common.Hotkeys.Hotkey;Hotkey for the associated command Rubberduck.UI.Command.ExportAllCommand was registered with id 49604;
2018-06-13 10:54:57.6933;TRACE-2.2.6737.8365;Rubberduck.Common.Hotkeys.Hotkey;Hotkey for the associated command Rubberduck.UI.Command.FindSymbolCommand was registered with id 49605;
2018-06-13 10:54:57.6933;TRACE-2.2.6737.8365;Rubberduck.Common.Hotkeys.Hotkey;Hotkey for the associated command Rubberduck.UI.Command.IndentCurrentModuleCommand was registered with id 49606;
2018-06-13 10:54:57.6933;TRACE-2.2.6737.8365;Rubberduck.Common.Hotkeys.Hotkey;Hotkey for the associated command Rubberduck.UI.Command.IndentCurrentProcedureCommand was registered with id 49607;
2018-06-13 10:54:57.6933;TRACE-2.2.6737.8365;Rubberduck.Common.Hotkeys.Hotkey;Hotkey for the associated command Rubberduck.UI.Command.InspectionResultsCommand was registered with id 49608;
2018-06-13 10:54:57.6933;TRACE-2.2.6737.8365;Rubberduck.Common.Hotkeys.Hotkey;Hotkey for the associated command Rubberduck.UI.Command.ReparseCommand was registered with id 49609;
2018-06-13 10:54:57.6933;TRACE-2.2.6737.8365;Rubberduck.Common.Hotkeys.Hotkey;Hotkey for the associated command Rubberduck.UI.Command.TestExplorerCommand was registered with id 49610;
retailcoder commented 6 years ago

hmm, that would be Access-specific, I'm running this exact same build here, and Excel has no problem with AC in any of the default modules of a blank workbook, or any existing modules of an existing project.

Further investigation is needed - I need to add logging to the AC/codepane hooking.

DGagne25 commented 6 years ago

Ok thank you for the info!

Meanwhile I will test this with Access 2016 and see if that gives the same results.

retailcoder commented 6 years ago

Can you please try pre-release build 3384 and see if the issue is magically fixed? The wiring-up was tweaked a bit, maybe that's all it was.

daFreeMan commented 6 years ago

RD 3384, Office 2016, Win10:

rd ac fail

Sorry, @retailcoder , only seems to work in a new module here, too. 😞

bclothier commented 6 years ago

Additional information that may be helpful.

I observe that the AC will not work on an existing module that's opened from the host, or was already open in VBE by the time VBE loads.

However, if we close the module code pane window, then re-open, the AC starts working again. For that reason I think AC simply isn't hooking into those windows that get opened before RD loads.

retailcoder commented 6 years ago

I think I have a clue (thanks @bclothier!) - when I bring up my VBE, I don't have any opened code panes, so I hit F7 to bring up the code-behind for Sheet1 ... and that should trigger the hotkeys to get attached, along with the autocompletion service.

If someone can confirm that hotkeys aren't wired-up on open, then this has to be it.

retailcoder commented 6 years ago

@daFreeMan BTW if AC is wired-up, you don't even need to type the As keyword - just hit TAB after typing the function's name, and boom :smile:

retailcoder commented 6 years ago

Ok so we dug a bit further, and it turns out the CodePaneSubClass only gets wired up when the code pane window is being created - in other words, if the VBE opens with code panes already created, AC (and any other feature that relies on these hooks - including the future keypress-based hotkeys) won't work in these windows.

Until we fix the subclass hooking, a work-around is to close the code pane window, and re-open it from the Code Explorer (or the VBE's Project Explorer).

DGagne25 commented 6 years ago

I confirm that it is working, thank you @retailcoder and @bclothier !

Hereby, it would be nice to have a "Close all windows" option menu.

Edit: Or would it be a better idea to just close all the code pane windows when RD loads?

I don't see the benefit of having every modules and forms code pane opened at startup.

retailcoder commented 6 years ago

@DGagne25 it would indeed "fix" the problem, but it could also annoy users that like having the VBE open up with the same workspace they had last time they saved & closed the workbook, ...without really fixing the hook issue. I think we need to fix the real problem, not just its symptoms.

daFreeMan commented 6 years ago

I've got to agree - a "Close all windows" option would be nice. 1) it's a handy, temporary workaround to this issue, and 2) sometimes I want to close everything to set up a nice workspace where I'm bouncing between 2-3 modules, and I don't want to have to find & click 47 little red Xs to get there (or hit Ctrl-F4 47 times).

IvenBach commented 6 years ago

I don't want RD to close the code panes down, unless it's opt-in. I leave the ones I'm working on open.

I personally use Ctrl+F4 and just hold them down while it closes every window.

DGagne25 commented 6 years ago

Thanks for the advice @IvenBach, this is doing the trick!

retailcoder commented 6 years ago

hmm, or we could "remember" what modules are opened, close everything, and re-open them?

comintern commented 6 years ago

See chat.