31
31
32
32
import processing .app .Base ;
33
33
import processing .app .Editor ;
34
+ import processing .app .EditorTab ;
34
35
import processing .app .helpers .OSUtils ;
35
36
36
37
import java .awt .*;
@@ -284,7 +285,6 @@ private void replaceAllButtonActionPerformed(java.awt.event.ActionEvent evt) {//
284
285
// End of variables declaration//GEN-END:variables
285
286
286
287
private boolean find (boolean wrap , boolean backwards , boolean searchTabs , int originTab ) {
287
- boolean wrapNeeded = false ;
288
288
String search = findField .getText ();
289
289
290
290
if (search .length () == 0 ) {
@@ -304,10 +304,6 @@ private boolean find(boolean wrap, boolean backwards, boolean searchTabs, int or
304
304
int selectionEnd = editor .getCurrentTab ().getSelectionStop ();
305
305
306
306
nextIndex = text .indexOf (search , selectionEnd );
307
- if (wrap && nextIndex == -1 ) {
308
- // if wrapping, a second chance is ok, start from beginning
309
- wrapNeeded = true ;
310
- }
311
307
} else {
312
308
// int selectionStart = editor.textarea.getSelectionStart();
313
309
int selectionStart = editor .getCurrentTab ().getSelectionStart () - 1 ;
@@ -317,14 +313,8 @@ private boolean find(boolean wrap, boolean backwards, boolean searchTabs, int or
317
313
} else {
318
314
nextIndex = -1 ;
319
315
}
320
- if (wrap && nextIndex == -1 ) {
321
- // if wrapping, a second chance is ok, start from the end
322
- wrapNeeded = true ;
323
- }
324
316
}
325
317
326
- editor .getCurrentTab ().getTextArea ().getFoldManager ().ensureOffsetNotInClosedFold (nextIndex );
327
-
328
318
if (nextIndex == -1 ) {
329
319
// Nothing found on this tab: Search other tabs if required
330
320
if (searchTabs ) {
@@ -345,12 +335,12 @@ private boolean find(boolean wrap, boolean backwards, boolean searchTabs, int or
345
335
}
346
336
347
337
if (backwards ) {
348
- editor .selectNextTab ();
338
+ editor .selectPrevTab ();
349
339
this .setVisible (true );
350
340
int l = editor .getCurrentTab ().getText ().length () - 1 ;
351
341
editor .getCurrentTab ().setSelection (l , l );
352
342
} else {
353
- editor .selectPrevTab ();
343
+ editor .selectNextTab ();
354
344
this .setVisible (true );
355
345
editor .getCurrentTab ().setSelection (0 , 0 );
356
346
}
@@ -360,13 +350,16 @@ private boolean find(boolean wrap, boolean backwards, boolean searchTabs, int or
360
350
}
361
351
}
362
352
363
- if (wrapNeeded ) {
353
+ if (wrap ) {
364
354
nextIndex = backwards ? text .lastIndexOf (search ) : text .indexOf (search , 0 );
365
355
}
366
356
}
367
357
368
358
if (nextIndex != -1 ) {
369
- editor .getCurrentTab ().setSelection (nextIndex , nextIndex + search .length ());
359
+ EditorTab currentTab = editor .getCurrentTab ();
360
+ currentTab .getTextArea ().getFoldManager ().ensureOffsetNotInClosedFold (nextIndex );
361
+ currentTab .setSelection (nextIndex , nextIndex + search .length ());
362
+ currentTab .getTextArea ().getCaret ().setSelectionVisible (true );
370
363
return true ;
371
364
}
372
365
0 commit comments