| @@ -283,7 +283,7 @@ private: | |||||
| class CodeEditorComponent::GutterComponent : public Component | class CodeEditorComponent::GutterComponent : public Component | ||||
| { | { | ||||
| public: | public: | ||||
| GutterComponent() : lastNumLines (0) {} | |||||
| GutterComponent() : firstLine (0), lastNumLines (0) {} | |||||
| void paint (Graphics& g) override | void paint (Graphics& g) override | ||||
| { | { | ||||
| @@ -313,18 +313,20 @@ public: | |||||
| ga.draw (g); | ga.draw (g); | ||||
| } | } | ||||
| void documentChanged (CodeDocument& doc) | |||||
| void documentChanged (CodeDocument& doc, int firstLineOnScreen) | |||||
| { | { | ||||
| const int newNumLines = doc.getNumLines(); | const int newNumLines = doc.getNumLines(); | ||||
| if (newNumLines != lastNumLines) | |||||
| if (newNumLines != lastNumLines || firstLineOnScreen != firstLine) | |||||
| { | { | ||||
| firstLine = firstLineOnScreen; | |||||
| lastNumLines = newNumLines; | lastNumLines = newNumLines; | ||||
| repaint(); | repaint(); | ||||
| } | } | ||||
| } | } | ||||
| private: | private: | ||||
| int lastNumLines; | |||||
| int firstLine, lastNumLines; | |||||
| }; | }; | ||||
| @@ -538,7 +540,7 @@ void CodeEditorComponent::rebuildLineTokens() | |||||
| verticalScrollBar.getX(), lineHeight * (1 + maxLineToRepaint - minLineToRepaint) + 2); | verticalScrollBar.getX(), lineHeight * (1 + maxLineToRepaint - minLineToRepaint) + 2); | ||||
| if (gutter != nullptr) | if (gutter != nullptr) | ||||
| gutter->documentChanged (document); | |||||
| gutter->documentChanged (document, firstLineOnScreen); | |||||
| } | } | ||||
| void CodeEditorComponent::codeDocumentChanged (const int startIndex, const int endIndex) | void CodeEditorComponent::codeDocumentChanged (const int startIndex, const int endIndex) | ||||