Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Scrollbar position (in sql editor tab) resets after running a query #2073

Open
T1mL3arn opened this issue Dec 24, 2019 · 15 comments
Open

Scrollbar position (in sql editor tab) resets after running a query #2073

T1mL3arn opened this issue Dec 24, 2019 · 15 comments
Assignees
Labels
bug

Comments

@T1mL3arn
Copy link

@T1mL3arn T1mL3arn commented Dec 24, 2019

Details for the issue

What did you do?

  1. Enter simple query, e.g. select 1;
  2. Press ENTER key many times that query from step 1 is not visible in a sql editor tab
  3. Enter another simple query, e.g. select 2;
  4. Run the last query with Execute current line or Ctrl+F5

What did you expect to see?

Scrollbar position is the same as it was before execution.

What did you see instead?

Scrollbar position is reset (scrollbar is in its origin position at the top).

Useful extra information

Win 8.1 x64
DB4S Version 3.11.99 (Nov 23 2019)

@mgrojo
Copy link
Member

@mgrojo mgrojo commented Dec 29, 2019

In a current nightly only happens when the second query contains an error. I think that hasn't changed. I think that we only move the scroll when a statement fails.

The problem is that we consider all the whitespace before a statement to be part of it, and when a statement has an error, we move the cursor to the beginning of it. I'll check whether there is an easy and clean solution for that.

@mgrojo mgrojo self-assigned this Dec 29, 2019
@mgrojo mgrojo added the bug label Dec 29, 2019
@T1mL3arn
Copy link
Author

@T1mL3arn T1mL3arn commented Dec 30, 2019

only happens when the second query contains an error

Tested Dec 28 2019 nightly. The behavior is the same.

Some new info: if db is marked as dirty, then scrollbar works as expected.

To reproduce

  1. Do the same as in the first post
  2. Change select 2 to something that produces an error (e.g. select hi)
  3. Execute that new query with Execute current line
  4. Note db is in dirty state (it is possible to press revert changes)
  5. Restore query to select 2
  6. Execute it again.
  7. Note scrollbar works as expected
  8. Revert changes
  9. Execute query again.
  10. Note scrollbar is not on the query

easy and clean solution

Saving current scrollbar position?

mgrojo added a commit that referenced this issue Dec 30, 2019
For the error indicators and scrolling to the failing query, all the
whitespace present at the starting end of the query is skipped. Otherwise
the point indicated to the user could be very far to the actual query.

See issue #2073
mgrojo added a commit that referenced this issue Dec 30, 2019
The end of the function is unified for failed and successful cases, so
the savepoint reversion is always made when it has to be.

Reported in issue #2073
@mgrojo
Copy link
Member

@mgrojo mgrojo commented Dec 30, 2019

Thanks @T1mL3arn. There were two problems here:

  1. The starting point of the failing query was considered from the ending point of the previous statement. In this case when there is a lot of whitespace, it had this effect. Now all that whitespace is skipped and the starting point for indicating the error is at the statement beginning (in the absence of any comment that will not be skipped).
  2. Failed queries never undid a savepoint that we set when executing some SQL code. Now it is always rollback appropriately when the statement does not change anything, independently of having failed or not.

The fixes are already committed and will be available in the tomorrow's nightly. Could you try again and report any pending problem?

@T1mL3arn
Copy link
Author

@T1mL3arn T1mL3arn commented Jan 3, 2020

@mgrojo could you trigger windows build script(or whatever) so I can test new version ?

@mgrojo
Copy link
Member

@mgrojo mgrojo commented Jan 3, 2020

The windows build script is triggered each midnight (around UTC) when there are changes in the repository. In https://nightlies.sqlitebrowser.org/latest/ you can find the results and according to https://nightlies.sqlitebrowser.org/win64/commit.txt and https://nightlies.sqlitebrowser.org/win32/commit.txt, they include the latest changes.

@T1mL3arn
Copy link
Author

@T1mL3arn T1mL3arn commented Jan 3, 2020

Tested. Now db is not marked as dirty for queries with error. Wrong scroll behavior still remains for correct and incorrect queries.

@mgrojo
Copy link
Member

@mgrojo mgrojo commented Jan 3, 2020

I'd need detail steps to reproduce it or if you could record a video, it'd be more easy to reproduce and analyse.

mgrojo added a commit that referenced this issue Jan 4, 2020
QScintilla text(line) returns the string of the passed line including the
line terminator. Given the differences in platforms in that regard, we
only supported the case for a single character separator.

This should solve issue #2073 for Windows.

It also should solve #1768 and #1632, which were only reproduced in Windows
or editing files with lines ending in "\r\n" in general.
@mgrojo
Copy link
Member

@mgrojo mgrojo commented Jan 4, 2020

@T1mL3arn thanks for the video. At first, I thought that you didn't have the fix, but then, I realized that we had problems with the "Execute Current Line" function in Windows, due to the line separator differences between platforms. I could finally reproduce it under Linux using a file with CR+LF endings. This was already reported in issues #1632 and #1768.

Could you confirm with tomorrow's nightly that everything works as expected under Windows?

T1mL3arn added a commit to T1mL3arn/db4s-screen-cast that referenced this issue Jan 5, 2020
@T1mL3arn
Copy link
Author

@T1mL3arn T1mL3arn commented Jan 5, 2020

Tested. Scroll behavior for incorrect queries is fixed. The wrong scroll behavior for correct queries is still there. Here is a new video.

@mgrojo
Copy link
Member

@mgrojo mgrojo commented Jan 5, 2020

That is caused by the hourglass icon appearing and modifying the tab bar height. Maybe this could solve the problem:
ui->tabSqlAreas->setMinimumSize(ui->tabSqlAreas->iconSize());
but I don't see any change in Linux when I set big values for that minimum size, so it might do nothing actually.

Another option is setting icons permanently in the tabs. The icon could indicate if the tab is an external file, an unsaved buffer or a saved tab in the project. Or only the saved or unsaved status of the tab.

@MKleusberg, do you have any other idea?

mgrojo added a commit that referenced this issue Mar 2, 2020
The icon shows whether the tab is linked to a project file (tab icon) or
to a file in disk (document_open icon).

This has a lateral effect of fixing this, since the tab always has an icon
and the height of the tab bar never changes:

#2073 (comment)
mgrojo added a commit that referenced this issue Mar 12, 2020
The icon shows whether the tab is linked to a project file (open_sql icon)
or to a file in disk (document_open icon).

This has a lateral effect of fixing this, since the tab always has an icon
and the height of the tab bar never changes:

#2073 (comment)
mgrojo added a commit that referenced this issue May 2, 2020
The icon shows whether the tab is linked to a project file (open_sql icon)
or to a file in disk (document_open icon).

This has a lateral effect of fixing this, since the tab always has an icon
and the height of the tab bar never changes:

#2073 (comment)
justinclift added a commit that referenced this issue Jun 6, 2020
The icon shows whether the tab is linked to a project file (open_sql icon)
or to a file in disk (document_open icon).

This has a lateral effect of fixing this, since the tab always has an icon
and the height of the tab bar never changes:

#2073 (comment)
@mgrojo
Copy link
Member

@mgrojo mgrojo commented Jun 21, 2020

@T1mL3arn This is supposed to be fixed in our release 3.12.0. Could you please confirm and close this issue?

@mgrojo mgrojo added this to the 3.12.0 - Next release milestone Jun 21, 2020
@T1mL3arn
Copy link
Author

@T1mL3arn T1mL3arn commented Jun 22, 2020

@mgrojo Checked 3.12.0, It works the same as described in the post above, i.e. it is still broken.

@mgrojo
Copy link
Member

@mgrojo mgrojo commented Jun 22, 2020

It was supposed to be solved by having always an icon in the tab. I cannot reproduce it in Linux, which is my development platform, so I'm kind of blind trying to solve this. Maybe someone else can provide some insight.

@mgrojo mgrojo removed this from the 3.12.0 - Next release milestone Jun 22, 2020
@justinclift
Copy link
Member

@justinclift justinclift commented Jun 30, 2020

@MKleusberg Thoughts on this one too? 😄

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
3 participants
You can’t perform that action at this time.