Recent

Author Topic: Tabs in Source Editor  (Read 4976 times)

ChrisR

  • Full Member
  • ***
  • Posts: 247
Tabs in Source Editor
« on: April 15, 2021, 05:33:41 pm »
I am using Lazarus Trunk (64999) on my BigSur M1. Whenever I press the 'tab' key in the source editor, the cursor position changes to the first line of the source code. I removed the configuration folder ~/.lazarus and rebuilt Lazarus from Source, and I have the same behavior. I tried different preferences in the Preferences/General/TabAndIndent menu which did not resolve anything. Is this issue unique to me, and if not is there a work around? It is 100% reliable, pressing tab anywhere in any project's source code shifts the cursor to the start of the file.

trev

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 2020
  • Former Delphi 1-7, 10.2 user
Re: Tabs in Source Editor
« Reply #1 on: April 16, 2021, 02:56:13 am »
I hadn't noticed (I guess I'm used to using spaces) but you're right - same issue in r64891. Best create a Bug Report over in the BugTracker.

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 9794
  • Debugger - SynEdit - and more
    • wiki
Re: Tabs in Source Editor
« Reply #2 on: April 16, 2021, 03:43:15 am »
If you go to tools >Options > Editor > Keymap:

Using e.g. Search and capture key: What does it get if you capture the tab key?

What does it show, to which command it is assigned?

trev

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 2020
  • Former Delphi 1-7, 10.2 user
Re: Tabs in Source Editor
« Reply #3 on: April 16, 2021, 05:10:50 am »
Lazarus > Preferences > Editor -> Key mappings

See pic.

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 9794
  • Debugger - SynEdit - and more
    • wiki
Re: Tabs in Source Editor
« Reply #4 on: April 16, 2021, 05:28:41 am »
That (the layout in the image) is correct.
And I take it, the "grab key" did recognize tab as tab?

I suspect that there is some key handling before the editor gets the tab.
But lets make  sure of a couple of things.

1) The editor does not believe to be in syncro or template mode.
Remove the "tab" for each of the 2 groups (first for one then for the other group).
The 2 syncro as group, and the 2 template as group.

2) With tab assigned again, start syncro edit (select text with duplicate words, and press ctrl-J). There should be highlighted fields for the duplicate words. Tab should go between the fields.

trev

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 2020
  • Former Delphi 1-7, 10.2 user
Re: Tabs in Source Editor
« Reply #5 on: April 16, 2021, 06:48:56 am »
That (the layout in the image) is correct.
And I take it, the "grab key" did recognize tab as tab?

Correct.

Quote
I suspect that there is some key handling before the editor gets the tab.
But lets make  sure of a couple of things.

1) The editor does not believe to be in syncro or template mode.
Remove the "tab" for each of the 2 groups (first for one then for the other group).
The 2 syncro as group, and the 2 template as group.

Issue remains.

Quote
2) With tab assigned again, start syncro edit (select text with duplicate words, and press ctrl-J). There should be highlighted fields for the duplicate words. Tab should go between the fields.

The tab key moves between the fields as expected in syncro edit. Otherwise the issue remains. A tab is inserted at the original cursor point from the left margin, but then the cursor moves to the top of the file after the word unit. If the starting position is further across a line, it moves up vertically to the top line in the same column.

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 9794
  • Debugger - SynEdit - and more
    • wiki
Re: Tabs in Source Editor
« Reply #6 on: April 16, 2021, 12:50:16 pm »
Quote
2) With tab assigned again, start syncro edit (select text with duplicate words, and press ctrl-J). There should be highlighted fields for the duplicate words. Tab should go between the fields.

The tab key moves between the fields as expected in syncro edit. Otherwise the issue remains. A tab is inserted at the original cursor point from the left margin, but then the cursor moves to the top of the file after the word unit. If the starting position is further across a line, it moves up vertically to the top line in the same column.

So the tab key gets delivered to the Editor.

"cursor moves to top" => that is not just visual? Newly typed chars are then also inserted at the top?


The desired cursor position after the tab, is it well within the visible area? I.e. the editor would not need any scrolling (vert or horiz) to keep the caret visible?

It is regardless of the line content, and the caret being at the start, middle or end of the line?


Please compile with -dVerboseKeys -dSynCaretDebug -dSynUndoDebug
and run with lazarus --debug-log=file
and attach said file

Please attach your editoroptions.xml
« Last Edit: April 16, 2021, 01:22:16 pm by Martin_fr »

ChrisR

  • Full Member
  • ***
  • Posts: 247
Re: Tabs in Source Editor
« Reply #7 on: April 16, 2021, 04:41:09 pm »
I can not build Lazarus trunk on MacOS AArch64 with these settings, I get
   Error: <stdin>:593908:1: error: assembler local symbol 'La3267' not defined

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 9794
  • Debugger - SynEdit - and more
    • wiki
Re: Tabs in Source Editor
« Reply #8 on: April 16, 2021, 04:57:34 pm »
Well that has to be a bug in FPC.
And that means, that there is now also the option to investigate if the tab-issue is caused by an FPC bug too.

Btw, both of you, which FPC version are you using?

Which settings? -O?  -CRriot?  and similar?

Can you try (even without the defines) what happens if you compile with each of the optimization levels 0,1,2?
In combination with/without -CRriot?
Or maybe try the 3.2.2rc?

Especially, does the bad tab behaviour occur with all of those settings?

--
Also, if the error persists with all the various options given to the compiler, maybe the defines will work with one of them?

trev

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 2020
  • Former Delphi 1-7, 10.2 user
Re: Tabs in Source Editor
« Reply #9 on: April 17, 2021, 01:30:31 am »
Btw, both of you, which FPC version are you using?

As per my signature.

Quote
Which settings? -O?  -CRriot?  and similar?

Nope. "make distclean all LCL_PLATFORM=cocoa CPU_TARGET=aarch64 bigide"

As for optimization levels, there's been a few aarch64 bugs squashed since I last updated FPC 3.3.1 (https://bugs.freepascal.org/view.php?id=38053). If I get time today I'll try recompiling the latest FPC + Lazarus trunks.

[Edit: Recompiled with today's FPC + Lazarus trunks (see signature) and still the same issue.]
« Last Edit: April 17, 2021, 07:39:18 am by trev »

trev

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 2020
  • Former Delphi 1-7, 10.2 user
Re: Tabs in Source Editor
« Reply #10 on: April 17, 2021, 01:44:22 am »
The tab key moves between the fields as expected in syncro edit. Otherwise the issue remains. A tab is inserted at the original cursor point from the left margin, but then the cursor moves to the top of the file after the word unit. If the starting position is further across a line, it moves up vertically to the top line in the same column.

So the tab key gets delivered to the Editor.

"cursor moves to top" => that is not just visual? Newly typed chars are then also inserted at the top?

Yes, newly typed characters appear at the top where the cursor is located.

Quote
The desired cursor position after the tab, is it well within the visible area? I.e. the editor would not need any scrolling (vert or horiz) to keep the caret visible?

Yes, the desired pos is well within the visible area.

Quote
It is regardless of the line content, and the caret being at the start, middle or end of the line?

Yes.

Quote
Please attach your editoroptions.xml

Attached.

I should note that this unexpected behaviour of the tab key does not occur on my Intel Mac mini, only on the ARM64 Mac mini.

trev

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 2020
  • Former Delphi 1-7, 10.2 user
Re: Tabs in Source Editor
« Reply #11 on: April 17, 2021, 07:57:25 am »
Please compile with -dVerboseKeys -dSynCaretDebug -dSynUndoDebug
and run with lazarus --debug-log=file
and attach said file

Compiled with: make distclean all LCL_PALTFORM=cocoa CPU_TARGET=aarch64 OPT='-O- -dVerboseKeys -dSynCaretDebug -dSynUndoDebug'

Log Attached.
« Last Edit: April 17, 2021, 08:07:27 am by trev »

ChrisR

  • Full Member
  • ***
  • Posts: 247
Re: Tabs in Source Editor
« Reply #12 on: April 17, 2021, 12:54:02 pm »

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 9794
  • Debugger - SynEdit - and more
    • wiki
Re: Tabs in Source Editor
« Reply #13 on: April 17, 2021, 03:47:04 pm »
I've seen the report.
But I can't do much about it, as I do not have an M1, and by all likelihood it is bound to that.


What I do here, is
1) Check, if it really is not SynEdit.
2) Potentially help finding the location in the code, where something goes wrong.

1)
I ensured that even with Trev's editoroptions, it does not happen on my PC.
Also the log looks correct. It does not show any indication that extra commands are sent to the Editor (I.e focus moves, that may have side effects). The caret is changed while handling the #9 key. So even if any other unwanted calls to SynEdit happen, the caret has gone wrong while handling #9.

2)
I will provide details which code is involved.
Then if someone with an M1 and moderate debugging experience and willingness can step through that, maybe we can find the line of code that changes the value for caret-Y. (This may require several iterations of debugging, feedback, debugging something else).
It can then be checked, if the error is in the Pascal source (and hence in SynEdit), or if it is wrongly compiled.
In either case narrowing it down, will help fixing the issue.

If the process renders any information on the cause of the issue, then that should be added to the bug report. (Adding the whole process will clutter the report / I.e. if it goes to fpc, they will "love" reading about SynEdit)

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 9794
  • Debugger - SynEdit - and more
    • wiki
Re: Tabs in Source Editor
« Reply #14 on: April 17, 2021, 03:53:23 pm »
Compiled with: make distclean all LCL_PALTFORM=cocoa CPU_TARGET=aarch64 OPT='-O- -dVerboseKeys -dSynCaretDebug -dSynUndoDebug'

Can you none the less try with  -O-1 or even -O-2 or -O2

I know you indicated that this may trigger bugs in fpc elsewhere. But as long as the IDE starts and allows a tab to be entered....

If this is a code generation issue, then changing the O level is a good test.
While often those bugs only happen at higher O level, the opposite can (and afaik has) happen(ed) too.

Of course this is no prove. Optimizations can also hide/reveal errors in the Pascal source. But given the M1 only characteristic, it would be highly indicative.


The same goes for adding -CRriot. The added code may have an affect on optimizations applied be the code generator.

 

TinyPortal © 2005-2018