Skip to content

Commit 21a9881

Browse files
committed
Fix merge error, put ZTestMarkers back
1 parent 49d8a89 commit 21a9881

File tree

3 files changed

+72
-12
lines changed

3 files changed

+72
-12
lines changed

src/editor.cpp

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@ void ZepEditor::NextTabWindow()
183183

184184
if (itr == m_tabWindows.end())
185185
{
186-
itr = m_tabWindows.begin();
186+
itr = m_tabWindows.end() - 1;
187187
}
188188
m_pActiveTabWindow = *itr;
189189
}
@@ -196,11 +196,7 @@ void ZepEditor::PreviousTabWindow()
196196
return;
197197
}
198198

199-
if (itr == m_tabWindows.begin())
200-
{
201-
itr = m_tabWindows.end() - 1;
202-
}
203-
else
199+
if (itr != m_tabWindows.begin())
204200
{
205201
itr--;
206202
}

src/mode_vim.cpp

Lines changed: 51 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -418,6 +418,7 @@ bool ZepMode_Vim::HandleExCommand(const std::string& strCommand, const char key)
418418
{
419419
auto pWindow = GetEditor().GetActiveTabWindow()->GetActiveWindow();
420420
auto& buffer = pWindow->GetBuffer();
421+
auto bufferCursor = pWindow->GetBufferCursor();
421422
if (GetEditor().Broadcast(std::make_shared<ZepMessage>(Msg_HandleCommand, strCommand)))
422423
{
423424
return true;
@@ -437,10 +438,29 @@ bool ZepMode_Vim::HandleExCommand(const std::string& strCommand, const char key)
437438
}
438439
GetEditor().SetCommandText(str.str());
439440
}
440-
else if (strCommand == ":tabedit")
441+
else if (strCommand.find(":tabedit") == 0)
441442
{
442443
auto pTab = GetEditor().AddTabWindow();
443-
pTab->AddWindow(&pWindow->GetBuffer(), nullptr, true);
444+
auto strTok = string_split(strCommand, " ");
445+
if (strTok.size() > 1)
446+
{
447+
if (strTok[1] == "%")
448+
{
449+
pTab->AddWindow(&GetEditor().GetActiveTabWindow()->GetActiveWindow()->GetBuffer(), nullptr, true);
450+
}
451+
else
452+
{
453+
auto fname = strTok[1];
454+
auto pBuffer = GetEditor().GetBuffer(fname);
455+
pBuffer->Load(fname);
456+
pTab->AddWindow(pBuffer, nullptr, true);
457+
}
458+
}
459+
else
460+
{
461+
pTab->AddWindow(GetEditor().GetBuffer("Empty"), nullptr, true);
462+
}
463+
GetEditor().SetCurrentTabWindow(pTab);
444464
}
445465
else if (strCommand == ":vsplit")
446466
{
@@ -450,8 +470,7 @@ bool ZepMode_Vim::HandleExCommand(const std::string& strCommand, const char key)
450470
pTab->AddWindow(&pWindow->GetBuffer(), pTab->GetActiveWindow(), true);
451471
}
452472
}
453-
else if (strCommand == ":hsplit" ||
454-
strCommand == ":split")
473+
else if (strCommand == ":hsplit" || strCommand == ":split")
455474
{
456475
auto pTab = GetEditor().GetActiveTabWindow();
457476
if (pTab)
@@ -484,6 +503,34 @@ bool ZepMode_Vim::HandleExCommand(const std::string& strCommand, const char key)
484503
GetEditor().GetActiveTabWindow()->CloseActiveWindow();
485504
}
486505
}
506+
else if (strCommand.find(":ZTestMarkers") == 0)
507+
{
508+
int markerType = 0;
509+
auto strTok = string_split(strCommand, " ");
510+
if (strTok.size() > 1)
511+
{
512+
markerType = std::stoi(strTok[1]);
513+
}
514+
RangeMarker marker;
515+
long start, end;
516+
start = buffer.GetLinePos(bufferCursor, LineLocation::LineFirstGraphChar);
517+
end = buffer.GetLinePos(bufferCursor, LineLocation::LineLastGraphChar) + 1;
518+
marker.range = BufferRange{start, end};
519+
switch (markerType)
520+
{
521+
case 1:
522+
marker.color = ThemeColor::Warning;
523+
marker.name = "Warning";
524+
marker.name = "This is an example warning mark";
525+
break;
526+
case 0:
527+
default:
528+
marker.color = ThemeColor::Error;
529+
marker.name = "Error";
530+
marker.name = "This is an example error mark";
531+
}
532+
buffer.AddRangeMarker(marker);
533+
}
487534
else if (strCommand == ":ZWhiteSpace")
488535
{
489536
pWindow->ToggleFlag(WindowFlags::ShowCR);

test_area.txt

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,20 @@
1-
Foobar sdf
1+
Chris
2+
3+
4+
5+
6+
7+
8+
9+
10+
11+
12+
13+
14+
15+
16+
17+
18+
19+
220

3-
sdfsdfs

0 commit comments

Comments
 (0)