Bug 128263 - Using trailing "_" with If statement breaks line positioning when debugging
Summary: Using trailing "_" with If statement breaks line positioning when debugging
Status: RESOLVED FIXED
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: BASIC (show other bugs)
Version:
(earliest affected)
Inherited From OOo
Hardware: All All
: medium normal
Assignee: Mike Kaganski
URL:
Whiteboard: target:6.4.0
Keywords:
Depends on:
Blocks:
 
Reported: 2019-10-20 08:34 UTC by Mike Kaganski
Modified: 2019-10-21 08:19 UTC (History)
2 users (show)

See Also:
Crash report or crash signature:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Mike Kaganski 2019-10-20 08:34:26 UTC
In a new Basic module, replace all boilerplate with this code:

Function Foo()
    If 0 Then print 1
    If 0 Then _
        print 1
    If 0 Then _
        print 1
End Function

Sub Bar
    print "Bar"
End Sub

Note that all If statements there are using single-line syntax without EndIf, and last two of them are written in two lines each, with "_" to break the line into two.

Now try to put cursor into Bar, on the line with "print 1", and press F5 to run it. Instead of executing it, it will open LibreOffice Basic Macros dialog, as if you had put cursor outside of any macro.
The same result would be when you put cursor to the last line of Bar (with "End Sub"), but Bar would run if you put cursor to "Sub Bar", *or to the line just above*, or even *if you put cursor to the last line of Foo (with "End Function")*! This shows that IDE treats lines incorrectly, shifting by 2 lines.

If you replace any of the two-lined Ifs into a single-lined If (to look like the first If), then the shift will become 1 line; and replacing both 2-lined Ifs with 1-lined variant makes it all OK.

Also the same problem is with putting breakpoints.

Tested with Version: 6.3.3.1 (x64)
Build ID: f41f4c7f9507aeca13cb9df51f34d80e8ba30a99
CPU threads: 12; OS: Windows 10.0; UI render: GL; VCL: win; 
Locale: ru-RU (ru_RU); UI-Language: en-US
Calc: threaded

and also with OpenOffice.org 3.2.0 OOO320m12 (Build:9483) - in that old version, only Main is run when you press F5, so the problem is only visible as breakpoint displacement.
Comment 1 Oliver Brinzing 2019-10-20 13:46:16 UTC
reproducible
Comment 2 Mike Kaganski 2019-10-21 06:55:19 UTC
https://gerrit.libreoffice.org/81204
Comment 3 Commit Notification 2019-10-21 08:19:44 UTC
Mike Kaganski committed a patch related to this issue.
It has been pushed to "master":

https://git.libreoffice.org/core/commit/7199f8c91fea3d3812b08539274eb3e73a7af69c

tdf#128263: update push positions in single line IF

It will be available in 6.4.0.

The patch should be included in the daily builds available at
https://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More
information about daily builds can be found at:
https://wiki.documentfoundation.org/Testing_Daily_Builds

Affected users are encouraged to test the fix and report feedback.