Recent

Author Topic: [SOLVED] "Persistent block" and "Classic" keyboard scheme: pressing TAB deletes  (Read 2950 times)

oh_ha

  • New Member
  • *
  • Posts: 12
Hello,

I have enabled "Persistent block" with the "Classic" keyboard scheme. The option "Tab indents block" is not active.
If I have a block of text selected and press the [Tab] key, the selected text gets deleted, which is unwanted.

Is there a way to change this behavior to the way it is in Delphi: pressing [Tab] inserts a tab at the current cursor position and leaves the selection intact.

EDIT: I use Lazarus v2.0.6.

Thanks in advance, Olaf
« Last Edit: April 19, 2020, 09:27:25 am by oh_ha »

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 9870
  • Debugger - SynEdit - and more
    • wiki
Just checked, that is a bug.
Please report on our Bugtracker.

You may try the following (untested) workaround:

Open components/synedit/synedit.pp
line 8599 (may differ in your version) -> it is towards the end of procedure TCustomSynEdit.DoTabKey;
It currently has the code
    SetSelTextExternal(Spaces);
replace this with
    ExecuteCommand(ecChar, Spaces, nil);

Then recompile the IDE : Menu Tools > Build IDE

« Last Edit: April 15, 2020, 05:17:43 pm by Martin_fr »

oh_ha

  • New Member
  • *
  • Posts: 12
Thanks for your reply. I tried the change, but the problem persisted. I have opened a bug report (#0036917).
« Last Edit: April 15, 2020, 06:16:34 pm by oh_ha »

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 9870
  • Debugger - SynEdit - and more
    • wiki
Ok some more changes, all in the same procedure

line 8565 (3 lines below the "try")
    SelText := '';
changes to
    if SelAvail and (not FBlockSelection.Persistent) and (eoOverwriteBlock in fOptions2) then
      SelText := '';

and surrounding the change from my previous post are 2 lines (one slightly above, one below the ExecuteCommand)
    OldCaretX := CaretX;
    CaretX := OldCaretX + i;
which both need to be removed / commented out.

Then it should work.

For the final fix, I need do to some refactor, and more testing.

oh_ha

  • New Member
  • *
  • Posts: 12
This works now.
Thank you very much for fixing this so fast!

Regards, Olaf

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 9870
  • Debugger - SynEdit - and more
    • wiki
I changed the fix https://svn.freepascal.org/cgi-bin/viewvc.cgi/trunk/components/synedit/synedit.pp?root=lazarus&r1=63014&r2=63013&pathrev=63014


The previous fix would go wrong in overwrite mode / Usually toggled by the "insert" key.
Note that tabs actually do not overwrite the existing text. (except selection).
But with the wrong fix, exactly one existing char would get deleted/replaced.

oh_ha

  • New Member
  • *
  • Posts: 12
Thanks again for your efforts!

 

TinyPortal © 2005-2018