Developer forums (C::B DEVELOPMENT STRICTLY!) > Development

cbeditor's bug fix in bracecompletion function

<< < (3/4) > >>

Jenna:
And what is the oncoding of the file ?
DC3 is a control-character (ascii-code less than 32) don't know which one.

Does not happen for me, and the patch seems to work.

killerbot:
the encoding is utf-8.

Whatever normal text character I type in at the end, that DC3 is added.

I now have this on 2 linux boxes (32 bit) and it works correctly on 1 linux box (64 bit). No idea if the 'xx-bit' has anything to do with it.

What the bracing part is concerned, that indeed works correctly, so the patch does have the intended result, apart from that strange side effect I have.

Jenna:
I did not try on 32-bit, so it might be related.

Could you test the patch if you add braces around the OR'ed arguments in the if-clause:

--- Quote ---        #if wxCHECK_VERSION(2, 9, 0)
        if ((index != wxNOT_FOUND) && ((unWant.Find(wxUniChar(nextChar)) != wxNOT_FOUND) || nextChar == _T('\0')))
        #else
        if ((index != wxNOT_FOUND) && ((unWant.Find(nextChar) != wxNOT_FOUND) || nextChar == _T('\0')))
        #endif

--- End quote ---

otherwise the brace-completion tries to kick in for any character, if your are at the last position of the file, because in that case nexChar is always 0x0, but index is wxNOT_FOUND ( == - 1,  because ch is not in leftBrace) and the result of control->AddText(rightBrace.GetChar(-1)); is surely not what we want.

killerbot:
Yes Jens, you nailed it.
This helps, just tested on my laptop, things evening I will test it on my netbook.

Loaden:
Cool! I think that's the final reason.

--- Code: ---Index: src/sdk/cbeditor.cpp
===================================================================
--- src/sdk/cbeditor.cpp (revision 6197)
+++ src/sdk/cbeditor.cpp (working copy)
@@ -404,10 +404,11 @@
         const wxString rightBrace(_T(")]}"));
         int index = leftBrace.Find(ch);
         const wxString unWant(_T(");\n\r\t\b "));
+        wxChar nextChar = control->GetCharAt(pos);
         #if wxCHECK_VERSION(2, 9, 0)
-        if ((index != wxNOT_FOUND) && (unWant.Find(wxUniChar(control->GetCharAt(pos))) != wxNOT_FOUND))
+        if (index != wxNOT_FOUND && (unWant.Find(wxUniChar(nextChar)) != wxNOT_FOUND || nextChar == _T('\0')))
         #else
-        if ((index != wxNOT_FOUND) && (unWant.Find(control->GetCharAt(pos)) != wxNOT_FOUND))
+        if (index != wxNOT_FOUND && (unWant.Find(nextChar) != wxNOT_FOUND || nextChar == _T('\0')))
         #endif
         {
             control->AddText(rightBrace.GetChar(index));

--- End code ---


[attachment deleted by admin]

Navigation

[0] Message Index

[#] Next page

[*] Previous page

Go to full version