From 332bebe4ff23062a3b0e1cfee6b1c00c87346063 Mon Sep 17 00:00:00 2001 From: Brian Fiete Date: Sat, 19 Mar 2022 07:01:45 -0700 Subject: [PATCH] Symbol rename fixes for extended utf8 chars --- IDE/src/ui/RenameSymbolDialog.bf | 15 ++++++++++++++- IDE/src/ui/SourceEditWidgetContent.bf | 15 +++++++++++---- IDEHelper/Compiler/BfParser.cpp | 9 +++++++++ 3 files changed, 34 insertions(+), 5 deletions(-) diff --git a/IDE/src/ui/RenameSymbolDialog.bf b/IDE/src/ui/RenameSymbolDialog.bf index c2fc6ed9..cba9800e 100644 --- a/IDE/src/ui/RenameSymbolDialog.bf +++ b/IDE/src/ui/RenameSymbolDialog.bf @@ -896,6 +896,7 @@ namespace IDE.ui { if (mClosed) return; + mClosed = true; mSourceViewPanel.CancelResolve(.GetSymbolInfo); @@ -1018,6 +1019,16 @@ namespace IDE.ui return; } + uint8 curTypeNum = 0; + uint8 curFlags = sourceEditWidgetContent.mInsertDisplayFlags; + sourceEditWidgetContent.GetInsertFlags(index, ref curTypeNum, ref curFlags); + if ((curFlags & (uint8)(SourceElementFlags.SymbolReference)) == 0) + { + // The last char was non-extending + Close(); + return; + } + // Close if insert is outside match area if ((index > 0) && (index < sourceEditWidgetContent.mData.mTextLength) && ((sourceEditWidgetContent.mData.mText[index - 1].mDisplayFlags & (uint8)(SourceElementFlags.SymbolReference)) == 0) && @@ -1064,7 +1075,7 @@ namespace IDE.ui if (mIgnoreTextChanges) return; - + int left = index; while (left > 0) { @@ -1077,7 +1088,9 @@ namespace IDE.ui while (right < sourceEditWidgetContent.mData.mTextLength) { if ((sourceEditWidgetContent.mData.mText[right].mDisplayFlags & (uint8)(SourceElementFlags.SymbolReference)) == 0) + { break; + } right++; } diff --git a/IDE/src/ui/SourceEditWidgetContent.bf b/IDE/src/ui/SourceEditWidgetContent.bf index dc526471..648f61db 100644 --- a/IDE/src/ui/SourceEditWidgetContent.bf +++ b/IDE/src/ui/SourceEditWidgetContent.bf @@ -4572,21 +4572,28 @@ namespace IDE.ui base.Redo(); } - public bool IsSymbolChar(char8 c) + public bool IsWordBreakChar(char8 c) { - return (c.IsLetterOrDigit) || (c == '_'); + if (c < '0') + return true; + switch (c) + { + case '<', '>', '@', '^', '`', '{', '|', '}', '~': + return true; + } + return false; } public override void GetInsertFlags(int index, ref uint8 typeId, ref uint8 flags) { - if ((index > 0) && (IsSymbolChar((char8)mData.mText[index - 1].mChar))) + if ((index > 0) && (!IsWordBreakChar((char8)mData.mText[index - 1].mChar))) { typeId = mData.mText[index - 1].mDisplayTypeId; // Copy attr from prev attr flags = (uint8)(mData.mText[index - 1].mDisplayFlags & mExtendDisplayFlags) | mInsertDisplayFlags; } else if (index < mData.mTextLength - 1) { - if (IsSymbolChar((char8)mData.mText[index].mChar)) + if (!IsWordBreakChar((char8)mData.mText[index].mChar)) { typeId = mData.mText[index].mDisplayTypeId; // Copy attr from prev attr flags = (uint8)(mData.mText[index].mDisplayFlags & mExtendDisplayFlags) | mInsertDisplayFlags; diff --git a/IDEHelper/Compiler/BfParser.cpp b/IDEHelper/Compiler/BfParser.cpp index 35a3c132..9703a349 100644 --- a/IDEHelper/Compiler/BfParser.cpp +++ b/IDEHelper/Compiler/BfParser.cpp @@ -3264,6 +3264,11 @@ void BfParser::NextToken(int endIdx, bool outerIsInterpolate, bool disablePrepro case UTF8PROC_CATEGORY_LM: case UTF8PROC_CATEGORY_LO: case UTF8PROC_CATEGORY_NL: + case UTF8PROC_CATEGORY_SM: + case UTF8PROC_CATEGORY_SC: + case UTF8PROC_CATEGORY_SK: + case UTF8PROC_CATEGORY_SO: + allowChar = true; default: break; } @@ -3305,6 +3310,10 @@ void BfParser::NextToken(int endIdx, bool outerIsInterpolate, bool disablePrepro case UTF8PROC_CATEGORY_LM: case UTF8PROC_CATEGORY_LO: case UTF8PROC_CATEGORY_NL: + case UTF8PROC_CATEGORY_SM: + case UTF8PROC_CATEGORY_SC: + case UTF8PROC_CATEGORY_SK: + case UTF8PROC_CATEGORY_SO: case UTF8PROC_CATEGORY_MN: case UTF8PROC_CATEGORY_MC: