Merge pull request #63 from marcel303/staticBufferGuard
Adding a guard to ensure the static buffer string is empty when enter…
diff --git a/TextEditor.cpp b/TextEditor.cpp
index 818ca4e..1492dcd 100644
--- a/TextEditor.cpp
+++ b/TextEditor.cpp
@@ -42,6 +42,7 @@
, mColorRangeMax(0)
, mSelectionMode(SelectionMode::Normal)
, mCheckComments(true)
+ , mLastClick(-1.0f)
{
SetPalette(GetDarkPalette());
SetLanguageDefinition(LanguageDefinition::HLSL());
@@ -543,13 +544,12 @@
if (ImGui::IsWindowHovered())
{
- static float lastClick = -1.0f;
if (!shift && !alt)
{
auto click = ImGui::IsMouseClicked(0);
auto doubleClick = ImGui::IsMouseDoubleClicked(0);
auto t = ImGui::GetTime();
- auto tripleClick = click && !doubleClick && t - lastClick < io.MouseDoubleClickTime;
+ auto tripleClick = click && !doubleClick && (mLastClick != -1.0f && (t - mLastClick) < io.MouseDoubleClickTime);
/*
Left mouse button triple click
@@ -564,7 +564,7 @@
SetSelection(mInteractiveStart, mInteractiveEnd, mSelectionMode);
}
- lastClick = -1.0f;
+ mLastClick = -1.0f;
}
/*
@@ -583,7 +583,7 @@
SetSelection(mInteractiveStart, mInteractiveEnd, mSelectionMode);
}
- lastClick = (float)ImGui::GetTime();
+ mLastClick = (float)ImGui::GetTime();
}
/*
@@ -598,7 +598,7 @@
mSelectionMode = SelectionMode::Normal;
SetSelection(mInteractiveStart, mInteractiveEnd, mSelectionMode);
- lastClick = (float)ImGui::GetTime();
+ mLastClick = (float)ImGui::GetTime();
}
// Mouse left button dragging (=> update selection)
else if (ImGui::IsMouseDragging(0) && ImGui::IsMouseDown(0))
diff --git a/TextEditor.h b/TextEditor.h
index 0f32ed9..fe1bebe 100644
--- a/TextEditor.h
+++ b/TextEditor.h
@@ -346,4 +346,6 @@
ErrorMarkers mErrorMarkers;
ImVec2 mCharAdvance;
Coordinates mInteractiveStart, mInteractiveEnd;
+
+ float mLastClick;
};