fakevim number lines bugging in last line
-
Problem: in the last line the number line buggs

But, before that it is normal:

anyone knows how to fix that? Thanks!
-
C Christian Ehrlicher moved this topic from General and Desktop on
-
Do you have any copy function active? e.g. moving/replacing lines or something? I looks like some helper when you copy or move line 10 there, but I could be wrong.
@Pl45m4 Not that I know of, where can I check if I do have one?"
Also, it's worth noting that I'm using relative line numbers with fakevim
and It should work without any problem but when I'm at at the last line like I said it buggs. It might be because it's overlapping with the default line numbers.Without:

With relative line numbers:

-
Okay, I tried testing things around and I found that it is the "fakevim" 's relative number lines that is bugging I removed the "text editor " 's line numbers and I kept the relative line numbers and here's what happening on the last line:

It's totally not working...
Tried to find this issue but didn't find anyone having it
-
same problem
-
Same issue for me. I spent some time to debug it. Finally I found a workaround to fix. I try to make a bug report but failed, so I post my change in here.
diff --git a/src/plugins/fakevim/fakevimplugin.cpp b/src/plugins/fakevim/fakevimplugin.cpp index b3cf98c8dde..af9a5e66e99 100644 --- a/src/plugins/fakevim/fakevimplugin.cpp +++ b/src/plugins/fakevim/fakevimplugin.cpp @@ -304,7 +304,8 @@ private: { QTextCursor tc = m_editor->textCursor(); m_currentPos = tc.position(); - m_lineSpacing = m_editor->document()->documentLayout()->blockBoundingRect(tc.block()).height(); + if (m_lineSpacing == 0) + m_lineSpacing = m_editor->document()->documentLayout()->blockBoundingRect(tc.block()).height(); setFont(m_editor->extraArea()->font()); // Follow geometry of normal line numbers if visible, -
This new workaround is better than previous I posted.
It fix:
- relative line number incorrect when
cursor is at the last line. - relative line number incorrect when change
Text Editor'sfont (except changeLine spacing).
It not fix:
- old relative line number remained when
increase Text Editor's Line spacing. (the old relative line number disappear whenclick mouse on editorormove cursor)
diff --git a/src/plugins/fakevim/fakevimplugin.cpp b/src/plugins/fakevim/fakevimplugin.cpp index af9a5e66e99..d5f7025144e 100644 --- a/src/plugins/fakevim/fakevimplugin.cpp +++ b/src/plugins/fakevim/fakevimplugin.cpp @@ -234,6 +234,10 @@ public: &m_timerUpdate, start); connect(TextEditorSettings::instance(), &TextEditorSettings::displaySettingsChanged, &m_timerUpdate, start); + connect(TextEditorSettings::instance(), &TextEditorSettings::fontSettingsChanged, + this, &RelativeNumbersColumn::followEditorLayout); + connect(m_editor->document()->documentLayout(), &QAbstractTextDocumentLayout::documentSizeChanged, + this, &RelativeNumbersColumn::followEditorLayout); m_editor->installEventFilter(this); @@ -302,11 +306,14 @@ protected: private: void followEditorLayout() { - QTextCursor tc = m_editor->textCursor(); - m_currentPos = tc.position(); - if (m_lineSpacing == 0) - m_lineSpacing = m_editor->document()->documentLayout()->blockBoundingRect(tc.block()).height(); - setFont(m_editor->extraArea()->font()); + QTextCursor tc = m_editor->cursorForPosition(QPoint(0, 0)); + int lineSpacing = m_editor->document()->documentLayout()->blockBoundingRect(tc.block()).height(); + QFont font = m_editor->font(); + if (m_font != font || m_lineSpacing != lineSpacing) { + m_font = font; + m_lineSpacing = lineSpacing; + setFont(m_font); + } // Follow geometry of normal line numbers if visible, // otherwise follow geometry of marks (breakpoints etc.). @@ -325,6 +332,7 @@ private: int m_currentPos = 0; int m_lineSpacing = 0; + QFont m_font; TextEditorWidget *m_editor; QTimer m_timerUpdate; }; - relative line number incorrect when
-
@mikewy0527 Could you please post your code changes to Gerrit?
An introduction can be found here: https://wiki.qt.io/Gerrit_Introduction
Thanks and regards
-
@mikewy0527 Could you please post your code changes to Gerrit?
An introduction can be found here: https://wiki.qt.io/Gerrit_Introduction
Thanks and regards
@aha_1980 Thank you, I'll give a try.
Previous workaround still have bug when file have only empty lines. This the new one:
diff --git a/src/plugins/fakevim/fakevimplugin.cpp b/src/plugins/fakevim/fakevimplugin.cpp index af9a5e66e99..6736cdef0a2 100644 --- a/src/plugins/fakevim/fakevimplugin.cpp +++ b/src/plugins/fakevim/fakevimplugin.cpp @@ -234,12 +234,23 @@ public: &m_timerUpdate, start); connect(TextEditorSettings::instance(), &TextEditorSettings::displaySettingsChanged, &m_timerUpdate, start); + connect(TextEditorSettings::instance(), &TextEditorSettings::fontSettingsChanged, + this, &RelativeNumbersColumn::updateFontSettings); + connect(m_editor->document()->documentLayout(), &QAbstractTextDocumentLayout::documentSizeChanged, + this, &RelativeNumbersColumn::updateFontSettings); m_editor->installEventFilter(this); followEditorLayout(); } + void updateFontSettings() + { + QTextCursor tc = m_editor->cursorForPosition(QPoint(0, 0)); + m_newLineSpacing = m_editor->document()->documentLayout()->blockBoundingRect(tc.block()).height(); + followEditorLayout(); + } + protected: void paintEvent(QPaintEvent *event) override { @@ -302,11 +313,12 @@ protected: private: void followEditorLayout() { - QTextCursor tc = m_editor->textCursor(); - m_currentPos = tc.position(); - if (m_lineSpacing == 0) - m_lineSpacing = m_editor->document()->documentLayout()->blockBoundingRect(tc.block()).height(); - setFont(m_editor->extraArea()->font()); + QFont font = m_editor->font(); + if (m_font != font || m_lineSpacing != m_newLineSpacing) { + m_font = font; + m_lineSpacing = m_newLineSpacing; + setFont(m_font); + } // Follow geometry of normal line numbers if visible, // otherwise follow geometry of marks (breakpoints etc.). @@ -325,6 +337,8 @@ private: int m_currentPos = 0; int m_lineSpacing = 0; + int m_newLineSpacing = 0; + QFont m_font; TextEditorWidget *m_editor; QTimer m_timerUpdate; }; -
@mikewy0527 Awesome, thanks for your contribution.
Patch is under review here: https://codereview.qt-project.org/c/qt-creator/qt-creator/+/707785
Regards