Saturday, March 27, 2021

How to hide the CodeInsight status panel

The new CodeInsight status panel added in 10.4.2 can be very distracting with its busy progressbar. Unfortunately there is no builtin mechanism to hide it but doing so is very easy.

Edit: Apparently as Lachlan pointed out on the comments I totally missed the "Code Insight Activity" toggle in the Options dropdown of the Project manager toolbar:



I leave the obsolete way here for documentation - here is the code to add a toggle button to the projectmanager toolbar (adding an icon is left as an excersise to the reader):

unit ToggleLSPStatusPanel;

interface

procedure Register;

implementation

uses
  System.Classes,
  Vcl.Forms,
  Vcl.ComCtrls,
  Vcl.ExtCtrls;

var
  LSPPanel: TPanel;
  ToolButton: TToolButton;

procedure TogglePanel(instance: TObject; Sender: TObject);
begin
  LSPPanel.Visible := not LSPPanel.Visible;
end;

procedure Register;
var
  e: TNotifyEvent;
begin
  var projectManagerForm := Application.MainForm.FindComponent('ProjectManagerForm');
  var toolBar := TToolBar(projectManagerForm.FindComponent('Toolbar'));
  ToolButton := TToolButton.Create(nil);
  LSPPanel := TPanel(projectManagerForm.FindComponent('pLSPStatus'));
  ToolButton.Left := toolbar.Width;
  ToolButton.Parent := toolbar;
  TMethod(e).Data := nil;
  TMethod(e).Code := @TogglePanel;
  ToolButton.OnClick := e;
end;

initialization

finalization
  try
    ToolButton.Free;
  except 
    // simply swallow the exception when closing the IDE as 
    // it will already have destroyed the button
    // feel free to make this more robust
  end;

end.

Simply add this unit to a designtime package and install it. Enjoy!

6 comments:

  1. Or you could just turn it off using the Project Manager Options button. Click the rightmost button on the Project Manager toolbar and deselect "CodeInsight Activity Indicator". Bingo, problem solved.

    ReplyDelete
    Replies
    1. Hahaha, I totally missed that one!

      Delete
    2. It was pretty well hidden. Really I don't know why they thought anyone other than people working on the LSP engine development would be interested in seeing that progress bar. It should be hidden by default.

      Delete
    3. Indeed. David Millington said on Facebook:
      "For big projects sometimes people say “why isn’t code completion working” and the answer was, “it’s not ready yet.” “But how do I know that?!” Well, that was a good question and why we added it."
      And after mentioning that other IDEs have something similar but way less prominent and distracting, he added: "I really like small and unobtrusive indicators and I would like this bar in 10.5 to look very different."

      Delete
  2. Why not just create the TToolButton with owner LSPPanel. That way you can get rid of the clean up code in finalization.

    ReplyDelete
    Replies
    1. I also need to destroy the button when the package is being unloaded.

      Delete