-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcommit495.diff
More file actions
72 lines (64 loc) · 3.06 KB
/
commit495.diff
File metadata and controls
72 lines (64 loc) · 3.06 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
commit 495c9bfbeaa60b379986106c285902acf815fcdf
Author: Dennis Esternon <djwisdom@gmail.com>
Date: Fri Apr 24 07:22:01 2026 +0800
Show ~ for empty lines beyond EOF in line numbers (Vim style)
diff --git a/src/window.cpp b/src/window.cpp
index e91294e8..9ca5195b 100644
--- a/src/window.cpp
+++ b/src/window.cpp
@@ -1237,6 +1237,7 @@ void ZepWindow::DisplayLineNumbers()
if (m_numberRegion->rect.Width() > 0)
{
+ long totalLines = m_pBuffer->GetLineCount();
for (long windowLine = m_visibleLineIndices.x; windowLine < m_visibleLineIndices.y; windowLine++)
{
auto& lineInfo = *m_windowLines[windowLine];
@@ -1249,14 +1250,25 @@ void ZepWindow::DisplayLineNumbers()
auto mode = m_pBuffer->GetMode();
- // In Vim mode show relative lines, unless in Ex mode (with hidden cursor)
- if (mode->UsesRelativeLines() && mode->GetCursorType() != CursorType::None)
+ // Check if this line is beyond EOF (empty virtual line)
+ bool beyondEOF = (lineInfo.bufferLineNumber >= totalLines);
+
+ if (beyondEOF)
{
- strNum = std::to_string(std::abs(lineInfo.bufferLineNumber - cursorBufferLine));
+ // Vim-style tilde for lines beyond end of file
+ strNum = "~";
}
else
{
- strNum = std::to_string(lineInfo.bufferLineNumber + 1);
+ // In Vim mode show relative lines, unless in Ex mode (with hidden cursor)
+ if (mode->UsesRelativeLines() && mode->GetCursorType() != CursorType::None)
+ {
+ strNum = std::to_string(std::abs(lineInfo.bufferLineNumber - cursorBufferLine));
+ }
+ else
+ {
+ strNum = std::to_string(lineInfo.bufferLineNumber + 1);
+ }
}
auto& numFont = display.GetFont(ZepTextType::UI);
@@ -1269,16 +1281,13 @@ void ZepWindow::DisplayLineNumbers()
digitCol = m_pBuffer->GetTheme().GetColor(ThemeColor::CursorNormal);
}
- if (m_numberRegion->rect.Width() > 0)
- {
- // Numbers
- display.SetClipRect(m_numberRegion->rect);
- display.DrawChars(numFont,
- NVec2f(m_numberRegion->rect.bottomRightPx.x - textSize.x,
- ToWindowY(lineCenter - numFont.GetPixelHeight() * .5f)),
- digitCol,
- (const uint8_t*)strNum.c_str(), (const uint8_t*)(strNum.c_str() + strNum.size()));
- }
+ // Numbers
+ display.SetClipRect(m_numberRegion->rect);
+ display.DrawChars(numFont,
+ NVec2f(m_numberRegion->rect.bottomRightPx.x - textSize.x,
+ ToWindowY(lineCenter - numFont.GetPixelHeight() * .5f)),
+ digitCol,
+ (const uint8_t*)strNum.c_str(), (const uint8_t*)(strNum.c_str() + strNum.size()));
if (m_indicatorRegion->rect.Width() > 0)
{