Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Qt Creator and other tools
  4. fakevim number lines bugging in last line

fakevim number lines bugging in last line

Scheduled Pinned Locked Moved Unsolved Qt Creator and other tools
11 Posts 5 Posters 922 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • C Offline
    C Offline
    cute_dev
    wrote on last edited by
    #1

    Problem: in the last line the number line buggs

    65238214-81ff-4f33-914c-9480d416b5f9-image.png

    But, before that it is normal:

    3912c420-d4a3-442b-a8e9-f886d2f823d6-image.png

    anyone knows how to fix that? Thanks!

    Pl45m4P 1 Reply Last reply
    0
    • C cute_dev

      Problem: in the last line the number line buggs

      65238214-81ff-4f33-914c-9480d416b5f9-image.png

      But, before that it is normal:

      3912c420-d4a3-442b-a8e9-f886d2f823d6-image.png

      anyone knows how to fix that? Thanks!

      Pl45m4P Offline
      Pl45m4P Offline
      Pl45m4
      wrote on last edited by
      #2

      @cute_dev

      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.


      If debugging is the process of removing software bugs, then programming must be the process of putting them in.

      ~E. W. Dijkstra

      C 1 Reply Last reply
      0
      • Christian EhrlicherC Christian Ehrlicher moved this topic from General and Desktop on
      • Pl45m4P Pl45m4

        @cute_dev

        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.

        C Offline
        C Offline
        cute_dev
        wrote on last edited by cute_dev
        #3

        @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:
        2fb9d7e5-d6be-4d80-9683-19ffdb9d0552-image.png

        With relative line numbers:
        d5496a4b-0701-4e94-988c-b87c3876f31f-image.png

        1 Reply Last reply
        0
        • C Offline
          C Offline
          cute_dev
          wrote on last edited by
          #4

          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:

          cec0b1c1-2491-400d-a7de-6a0d2cf8b624-image.png

          It's totally not working...

          Tried to find this issue but didn't find anyone having it

          1 Reply Last reply
          0
          • K Offline
            K Offline
            kaybedenler
            wrote on last edited by
            #5

            same problem

            1 Reply Last reply
            0
            • M Offline
              M Offline
              mikewy0527
              wrote last edited by
              #6

              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,
              
              1 Reply Last reply
              0
              • aha_1980A Offline
                aha_1980A Offline
                aha_1980
                Lifetime Qt Champion
                wrote last edited by
                #7

                @andr ^^

                Qt has to stay free or it will die.

                1 Reply Last reply
                0
                • M Offline
                  M Offline
                  mikewy0527
                  wrote last edited by mikewy0527
                  #8

                  This new workaround is better than previous I posted.

                  It fix:

                  1. relative line number incorrect when cursor is at the last line.
                  2. relative line number incorrect when change Text Editor's font (except change Line spacing).

                  It not fix:

                  1. old relative line number remained when increase Text Editor's Line spacing. (the old relative line number disappear when click mouse on editor or move 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;
                   };
                  
                  1 Reply Last reply
                  1
                  • aha_1980A Offline
                    aha_1980A Offline
                    aha_1980
                    Lifetime Qt Champion
                    wrote last edited by
                    #9

                    @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

                    Qt has to stay free or it will die.

                    M 1 Reply Last reply
                    0
                    • aha_1980A aha_1980

                      @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

                      M Offline
                      M Offline
                      mikewy0527
                      wrote last edited by
                      #10

                      @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;
                       };
                      
                      1 Reply Last reply
                      1
                      • aha_1980A Offline
                        aha_1980A Offline
                        aha_1980
                        Lifetime Qt Champion
                        wrote last edited by aha_1980
                        #11

                        @mikewy0527 Awesome, thanks for your contribution.

                        Patch is under review here: https://codereview.qt-project.org/c/qt-creator/qt-creator/+/707785

                        Regards

                        Qt has to stay free or it will die.

                        1 Reply Last reply
                        0

                        • Login

                        • Login or register to search.
                        • First post
                          Last post
                        0
                        • Categories
                        • Recent
                        • Tags
                        • Popular
                        • Users
                        • Groups
                        • Search
                        • Get Qt Extensions
                        • Unsolved