1
0
Fork 0
mirror of https://github.com/beefytech/Beef.git synced 2025-06-10 20:42:21 +02:00

Correct handling of reopening previously closed text buffers

This commit is contained in:
blat-blatnik 2022-01-11 23:10:54 +01:00
parent 14c43d117c
commit adcab798b0

View file

@ -187,7 +187,7 @@ namespace IDE.ui
{
case NeedToRecalculate;
case UnmatchedParens;
case Valid(float x1, float y1, float x2, float y2);
case Valid(int cachedCursorTextPos, float x1, float y1, float x2, float y2);
}
public delegate void(char32, AutoCompleteOptions) mOnGenerateAutocomplete ~ delete _;
@ -4716,6 +4716,17 @@ namespace IDE.ui
// Highlight matching parenthesis under cursor
if (mEditWidget.mHasFocus && !HasSelection())
{
if (mMatchingParensPositionCache case .Valid(var cachedCursorTextPos, ?, ?, ?, ?))
{
//HACK:
// We can't just rely on setting .NeedToRecalculate in PhysCursorMoved because it looks like sometimes the
// cursor moves without that being called. For example when you open a text buffer that was already opened
// before, the cursor will initially be at the old position where you left it before being moved to (0,0)
// but this move to 0,0 won't be detected.
if (cachedCursorTextPos != CursorTextPos)
mMatchingParensPositionCache = .NeedToRecalculate;
}
if (mMatchingParensPositionCache case .NeedToRecalculate)
{
mMatchingParensPositionCache = .UnmatchedParens;
@ -4797,12 +4808,12 @@ namespace IDE.ui
GetLineColumnAtIdx(matchingParenIndex, var line2, var column2);
GetTextCoordAtLineAndColumn(line1, column1, var x1, var y1);
GetTextCoordAtLineAndColumn(line2, column2, var x2, var y2);
mMatchingParensPositionCache = .Valid(x1, y1, x2, y2);
mMatchingParensPositionCache = .Valid(CursorTextPos, x1, y1, x2, y2);
}
}
}
if (mMatchingParensPositionCache case .Valid(let x1, let y1, let x2, let y2))
if (mMatchingParensPositionCache case .Valid(?, let x1, let y1, let x2, let y2))
{
let width = mFont.GetWidth(' ');
let height = mFont.GetHeight() + GS!(2);