Index: CodeEditor/CodeEditor.cpp
===================================================================
--- CodeEditor/CodeEditor.cpp	(wersja 7935)
+++ CodeEditor/CodeEditor.cpp	(kopia robocza)
@@ -623,6 +623,13 @@
 	LineEdit::MouseLeave();
 }
 
+int CodeEditor::Load(Stream& s, byte charset)
+{
+	int status = LineEdit::Load(s, charset);
+	EditorBarLayout();
+	return status;
+}
+
 WString CodeEditor::GetI()
 {
 	int l, h;
@@ -765,6 +772,7 @@
 
 bool CodeEditor::Key(dword code, int count) {
 	Time key_time = GetSysTime();
+	const int lineCount = GetLineCount();
 	double diff;
 	if(!IsNull(last_key_time) && (diff = int(key_time - last_key_time)) <= 3)
 		stat_edit_time += diff;
@@ -781,6 +789,7 @@
 		return true;
 	case K_CTRL_BACKSPACE:
 		DeleteWordBack();
+		SyncEditorBarLineNumbers(lineCount);
 		return true;
 	case K_BACKSPACE:
 		if(!IsReadOnly() && !IsAnySelection() && indent_spaces) {
@@ -808,6 +817,7 @@
 				Action();
 				return true;
 			}
+			SyncEditorBarLineNumbers(lineCount);
 		}
 		break;
 	case K_SHIFT_CTRL_TAB:
@@ -814,6 +824,7 @@
 		return LineEdit::Key(K_TAB, count);
 	case K_ENTER:
 		IndentInsert('\n', count);
+		SyncEditorBarLineNumbers(lineCount);
 		return true;
 	}
 	bool sel = code & K_SHIFT;
@@ -899,7 +910,10 @@
 	if(GetCharset() != CHARSET_UTF8)
 		if(code >= 128 && code < 65536 && FromUnicode((wchar)code, GetCharset()) == DEFAULTCHAR)
 			return true;
-	return LineEdit::Key(code, count);
+	
+	bool status = LineEdit::Key(code, count);
+	SyncEditorBarLineNumbers(lineCount);
+	return status;
 }
 
 void CodeEditor::ForwardWhenBreakpoint(int i) {
@@ -953,6 +967,13 @@
 	    <<= THISBACK1(SetI, &edit);
 }
 
+void CodeEditor::SyncEditorBarLineNumbers(int previousLineCount)
+{
+	if (bar.IsLineNumbers() && 
+	    IntStr(previousLineCount).GetCount() != IntStr(GetLineCount()).GetCount())
+		EditorBarLayout();
+}
+
 CodeEditor::CodeEditor() {
 	bracket_flash = false;
 	highlight_bracket_pos0 = 0;
Index: CodeEditor/CodeEditor.h
===================================================================
--- CodeEditor/CodeEditor.h	(wersja 7935)
+++ CodeEditor/CodeEditor.h	(kopia robocza)
@@ -134,6 +134,7 @@
 	void     Annotations(int width);
 	
 	bool     IsHiliteIfEndif() const         { return hilite_if_endif; }
+	bool     IsLineNumbers() const           { return line_numbers; }
 	
 	int      GetActiveAnnotationLine() const { return active_annotation; }
 
@@ -188,7 +189,9 @@
 	virtual Image CursorImage(Point p, dword keyflags);
 	virtual void  Serialize(Stream& s);
 	virtual void  MouseLeave();
-
+	
+	virtual int Load(Stream& s, byte charset = CHARSET_DEFAULT);
+	
 protected:
 	virtual void HighlightLine(int line, Vector<LineEdit::Highlight>& h, int pos);
 	virtual void PreInsert(int pos, const WString& s);
@@ -315,7 +318,9 @@
 	void   Make(Callback1<String&> op);
 	void   TabsOrSpaces(String& out, bool maketabs);
 	void   LineEnds(String& out);
-
+	
+	void   SyncEditorBarLineNumbers(int oldLineNumbersCount);
+	
 	enum {
 		TIMEID_PERIODIC = Ctrl::TIMEID_COUNT,
 		TIMEID_COUNT,
Index: CodeEditor/EditorBar.cpp
===================================================================
--- CodeEditor/EditorBar.cpp	(wersja 7935)
+++ CodeEditor/EditorBar.cpp	(kopia robocza)
@@ -88,10 +88,10 @@
 		if(editor->GetCaret().top == y && editor->barline)
 			w.DrawRect(0, y, sz.cx, fy, Blend(SColorHighlight(), SColorLtFace(), 200));
 		if(line_numbers && i < editor->GetLineCount()) {
-			String n = AsString((i + 1) % 10000);
+			String n = AsString((i + 1) % 1000000);
 			Font fnt = editor->GetFont();
 			Size tsz = GetTextSize(n, fnt);
-			w.DrawText(sz.cx - 8 - 12 - tsz.cx, y + (fy - tsz.cy) / 2, n, fnt, Brown);
+			w.DrawText(sz.cx - 4 - 12 - tsz.cx, y + (fy - tsz.cy) / 2, n, fnt, Brown);
 		}
 		if(hi_if) {
 			Vector<IfState> nextif;
@@ -476,7 +476,10 @@
 
 void EditorBar::SyncWidth()
 {
-	Width((line_numbers && editor ? editor->GetFont()['0'] * 4 + 12 : 12) + annotations);
+	int digits = 1;
+	if (editor)
+		digits = IntStr(editor->GetLineCount()).GetLength();
+	Width((line_numbers && editor ? editor->GetFont()['0'] * digits + 12 + 4 : 12 + 4) + annotations);
 	Refresh();
 }
 
