| CODENOTIFIER | HelpYou are not signed inSign in |
Project: Notepad++
Revision: 302
Author: donho
Date: 24 Jul 2008 18:24:35
Changes:[BUG_FIXED] Fix a crash bug while searching in all opened documents if a document contains long line.
Files:| ... | ...@@ -1150,12 +1150,14 @@ | |
| 1150 | 1150 | return -1; |
| 1151 | 1151 | } |
| 1152 | 1152 | |
| 1153 | switch (op) { | |
| 1154 | case ProcessFindAll: { | |
| 1153 | switch (op) | |
| 1154 | { | |
| 1155 | case ProcessFindAll: | |
| 1156 | { | |
| 1155 | 1157 | int lineNumber = (*_ppEditView)->execute(SCI_LINEFROMPOSITION, targetStart); |
| 1156 | int lend = (*_ppEditView)->execute(SCI_GETLINEENDPOSITION, lineNumber); | |
| 1157 | int lstart = (*_ppEditView)->execute(SCI_POSITIONFROMLINE, lineNumber); | |
| 1158 | int nbChar = lend - lstart; | |
| 1158 | //int lend = (*_ppEditView)->execute(SCI_GETLINEENDPOSITION, lineNumber); | |
| 1159 | //int lstart = (*_ppEditView)->execute(SCI_POSITIONFROMLINE, lineNumber); | |
| 1160 | int nbChar = (*_ppEditView)->execute(SCI_LINELENGTH, lineNumber); | |
| 1159 | 1161 | bool isRealloc = false; |
| 1160 | 1162 | |
| 1161 | 1163 | if (_maxNbCharAllocated < nbChar) //line longer than buffer, resize buffer |
| ... | ...@@ -1164,15 +1166,13 @@ | |
| 1164 | 1166 | _maxNbCharAllocated = nbChar; |
| 1165 | 1167 | delete [] _line; |
| 1166 | 1168 | _line = new char[_maxNbCharAllocated + 3]; |
| 1167 | if (isUnicode) //if unicode, also resize unicode buffer | |
| 1168 | { | |
| 1169 | const int uniCharLen = (_maxNbCharAllocated + 3) * 2 + 1; | |
| 1170 | delete [] _uniCharLine; | |
| 1171 | _uniCharLine = new char[uniCharLen]; | |
| 1172 | } | |
| 1169 | ||
| 1170 | // also resize unicode buffer | |
| 1171 | const int uniCharLen = (_maxNbCharAllocated + 3) * 2 + 1; | |
| 1172 | delete [] _uniCharLine; | |
| 1173 | _uniCharLine = new char[uniCharLen]; | |
| 1173 | 1174 | } |
| 1174 | 1175 | (*_ppEditView)->execute(SCI_GETLINE, lineNumber, (LPARAM)_line); |
| 1175 | ||
| 1176 | 1176 | _line[nbChar] = 0x0D; |
| 1177 | 1177 | _line[nbChar+1] = 0x0A; |
| 1178 | 1178 | _line[nbChar+2] = '\0'; |
| ... | ...@@ -1187,16 +1187,20 @@ | |
| 1187 | 1187 | { |
| 1188 | 1188 | pLine = _line; |
| 1189 | 1189 | } |
| 1190 | //printStr(isUnicode?"unicode":"no unicode"); | |
| 1191 | 1190 | _pFinder->add(FoundInfo(targetStart, targetEnd, pLine, fileName, _pFinder->_lineCounter), lineNumber + 1); |
| 1192 | break; } | |
| 1193 | 1191 | |
| 1194 | case ProcessReplaceAll: { | |
| 1192 | break; | |
| 1193 | } | |
| 1194 | ||
| 1195 | case ProcessReplaceAll: | |
| 1196 | { | |
| 1195 | 1197 | int replacedLength = (*_ppEditView)->execute(isRegExp?SCI_REPLACETARGETRE:SCI_REPLACETARGET, (WPARAM)stringSizeReplace, (LPARAM)pTextReplace); |
| 1196 | 1198 | replaceDelta = replacedLength - foundTextLen; |
| 1197 | break; } | |
| 1199 | break; | |
| 1200 | } | |
| 1198 | 1201 | |
| 1199 | case ProcessMarkAll: { | |
| 1202 | case ProcessMarkAll: | |
| 1203 | { | |
| 1200 | 1204 | if (_doStyleFoundToken) |
| 1201 | 1205 | { |
| 1202 | 1206 | (*_ppEditView)->execute(SCI_SETINDICATORCURRENT, SCE_UNIVERSAL_FOUND_STYLE); |
| ... | ...@@ -1211,23 +1215,31 @@ | |
| 1211 | 1215 | if (!(state & (1 << MARK_BOOKMARK))) |
| 1212 | 1216 | (*_ppEditView)->execute(SCI_MARKERADD, lineNumber, MARK_BOOKMARK); |
| 1213 | 1217 | } |
| 1214 | break; } | |
| 1218 | break; | |
| 1219 | } | |
| 1215 | 1220 | |
| 1216 | case ProcessMarkAll_2: { | |
| 1221 | case ProcessMarkAll_2: | |
| 1222 | { | |
| 1217 | 1223 | (*_ppEditView)->execute(SCI_SETINDICATORCURRENT, SCE_UNIVERSAL_FOUND_STYLE_2); |
| 1218 | 1224 | (*_ppEditView)->execute(SCI_INDICATORFILLRANGE, targetStart, foundTextLen); |
| 1219 | break; } | |
| 1225 | break; | |
| 1226 | } | |
| 1220 | 1227 | |
| 1221 | case ProcessMarkAll_IncSearch: { | |
| 1228 | case ProcessMarkAll_IncSearch: | |
| 1229 | { | |
| 1222 | 1230 | (*_ppEditView)->execute(SCI_SETINDICATORCURRENT, SCE_UNIVERSAL_FOUND_STYLE_INC); |
| 1223 | 1231 | (*_ppEditView)->execute(SCI_INDICATORFILLRANGE, targetStart, foundTextLen); |
| 1224 | break; } | |
| 1232 | break; | |
| 1233 | } | |
| 1225 | 1234 | |
| 1226 | case ProcessCountAll: { | |
| 1235 | case ProcessCountAll: | |
| 1236 | { | |
| 1227 | 1237 | //Nothing to do |
| 1228 | break; } | |
| 1238 | break; | |
| 1239 | } | |
| 1229 | 1240 | |
| 1230 | default: { | |
| 1241 | default: | |
| 1242 | { | |
| 1231 | 1243 | delete [] pTextFind; |
| 1232 | 1244 | delete [] pTextReplace; |
| 1233 | 1245 | return nbProcessed; |