fix: Multiple memory corruption issues
This commit is contained in:
parent
e46d9d7650
commit
5948a74ad1
@ -30,7 +30,7 @@ TextEditor::Palette TextEditor::sPaletteBase = TextEditor::GetDarkPalette();
|
|||||||
TextEditor::FindReplaceHandler::FindReplaceHandler() : mWholeWord(false),mFindRegEx(false),mMatchCase(false) {}
|
TextEditor::FindReplaceHandler::FindReplaceHandler() : mWholeWord(false),mFindRegEx(false),mMatchCase(false) {}
|
||||||
|
|
||||||
TextEditor::TextEditor()
|
TextEditor::TextEditor()
|
||||||
: mLineSpacing(1.0f), mUndoIndex(0), mTabSize(4), mOverwrite(false), mReadOnly(false), mWithinRender(false), mScrollToCursor(false), mScrollToTop(false), mScrollToBottom(false), mTextChanged(false), mColorizerEnabled(true), mTextStart(20.0f), mLeftMargin(10), mTopMargin(0), mCursorPositionChanged(false), mColorRangeMin(0), mColorRangeMax(0), mSelectionMode(SelectionMode::Normal), mCheckComments(true), mLastClick(-1.0f), mHandleKeyboardInputs(true), mHandleMouseInputs(true), mIgnoreImGuiChild(false), mShowWhitespaces(true), mShowCursor(true), mShowLineNumbers(true),mStartTime(ImGui::GetTime() * 1000) {
|
: mLineSpacing(1.0f), mUndoIndex(0), mTabSize(4), mOverwrite(false), mReadOnly(false), mWithinRender(false), mScrollToCursor(false), mScrollToTop(false), mScrollToBottom(false), mTextChanged(false), mColorizerEnabled(true), mTextStart(20.0f), mLeftMargin(10), mTopMargin(0), mCursorPositionChanged(false), mColorRangeMin(0), mColorRangeMax(0), mSelectionMode(SelectionMode::Normal), mCheckComments(true), mLastClick(-1.0f), mHandleKeyboardInputs(true), mHandleMouseInputs(true), mIgnoreImGuiChild(false), mShowWhitespaces(true), mShowCursor(true), mShowLineNumbers(true),mStartTime(ImGui::GetTime() * 1000), mBreakPointsChanged(false) {
|
||||||
SetLanguageDefinition(LanguageDefinition::HLSL());
|
SetLanguageDefinition(LanguageDefinition::HLSL());
|
||||||
mLines.push_back(Line());
|
mLines.push_back(Line());
|
||||||
}
|
}
|
||||||
@ -493,17 +493,20 @@ TextEditor::Coordinates TextEditor::StringIndexToCoordinates(int aIndex, const s
|
|||||||
int TextEditor::GetCharacterIndex(const Coordinates &aCoordinates) const {
|
int TextEditor::GetCharacterIndex(const Coordinates &aCoordinates) const {
|
||||||
if (aCoordinates.mLine >= mLines.size())
|
if (aCoordinates.mLine >= mLines.size())
|
||||||
return -1;
|
return -1;
|
||||||
auto &line = mLines[aCoordinates.mLine];
|
|
||||||
int c = 0;
|
const auto &line = mLines[aCoordinates.mLine];
|
||||||
int i = 0;
|
int column = 0;
|
||||||
while (i < line.size() && c < aCoordinates.mColumn) {
|
int index = 0;
|
||||||
i += UTF8CharLength(line[i].mChar);
|
while (index < line.size() && column < aCoordinates.mColumn) {
|
||||||
if (line[i].mChar == '\t')
|
const auto character = line[index].mChar;
|
||||||
c = (c / mTabSize) * mTabSize + mTabSize;
|
index += UTF8CharLength(character);
|
||||||
|
if (character == '\t')
|
||||||
|
column = (column / mTabSize) * mTabSize + mTabSize;
|
||||||
else
|
else
|
||||||
++c;
|
++column;
|
||||||
}
|
}
|
||||||
return i;
|
|
||||||
|
return index;
|
||||||
}
|
}
|
||||||
|
|
||||||
int TextEditor::GetCharacterColumn(int aLine, int aIndex) const {
|
int TextEditor::GetCharacterColumn(int aLine, int aIndex) const {
|
||||||
|
@ -418,8 +418,8 @@ namespace hex::plugin::builtin {
|
|||||||
ImGui::EndPopup();
|
ImGui::EndPopup();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (auto editor = getEditorFromFocusedWindow(); editor != nullptr)
|
||||||
setupFindReplace(getEditorFromFocusedWindow());
|
setupFindReplace(editor);
|
||||||
|
|
||||||
ImGui::Button("##settings_drag_bar", ImVec2(ImGui::GetContentRegionAvail().x, 2_scaled));
|
ImGui::Button("##settings_drag_bar", ImVec2(ImGui::GetContentRegionAvail().x, 2_scaled));
|
||||||
if (ImGui::IsMouseDragging(ImGuiMouseButton_Left, 0)) {
|
if (ImGui::IsMouseDragging(ImGuiMouseButton_Left, 0)) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user