Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 8 additions & 15 deletions app/src/cc/arduino/view/findreplace/FindReplace.java
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@

import processing.app.Base;
import processing.app.Editor;
import processing.app.EditorTab;
import processing.app.helpers.OSUtils;

import java.awt.*;
Expand Down Expand Up @@ -284,7 +285,6 @@ private void replaceAllButtonActionPerformed(java.awt.event.ActionEvent evt) {//
// End of variables declaration//GEN-END:variables

private boolean find(boolean wrap, boolean backwards, boolean searchTabs, int originTab) {
boolean wrapNeeded = false;
String search = findField.getText();

if (search.length() == 0) {
Expand All @@ -304,10 +304,6 @@ private boolean find(boolean wrap, boolean backwards, boolean searchTabs, int or
int selectionEnd = editor.getCurrentTab().getSelectionStop();

nextIndex = text.indexOf(search, selectionEnd);
if (wrap && nextIndex == -1) {
// if wrapping, a second chance is ok, start from beginning
wrapNeeded = true;
}
} else {
// int selectionStart = editor.textarea.getSelectionStart();
int selectionStart = editor.getCurrentTab().getSelectionStart() - 1;
Expand All @@ -317,14 +313,8 @@ private boolean find(boolean wrap, boolean backwards, boolean searchTabs, int or
} else {
nextIndex = -1;
}
if (wrap && nextIndex == -1) {
// if wrapping, a second chance is ok, start from the end
wrapNeeded = true;
}
}

editor.getCurrentTab().getTextArea().getFoldManager().ensureOffsetNotInClosedFold(nextIndex);

if (nextIndex == -1) {
// Nothing found on this tab: Search other tabs if required
if (searchTabs) {
Expand All @@ -345,12 +335,12 @@ private boolean find(boolean wrap, boolean backwards, boolean searchTabs, int or
}

if (backwards) {
editor.selectNextTab();
editor.selectPrevTab();
this.setVisible(true);
int l = editor.getCurrentTab().getText().length() - 1;
editor.getCurrentTab().setSelection(l, l);
} else {
editor.selectPrevTab();
editor.selectNextTab();
this.setVisible(true);
editor.getCurrentTab().setSelection(0, 0);
}
Expand All @@ -360,13 +350,16 @@ private boolean find(boolean wrap, boolean backwards, boolean searchTabs, int or
}
}

if (wrapNeeded) {
if (wrap) {
nextIndex = backwards ? text.lastIndexOf(search) : text.indexOf(search, 0);
}
}

if (nextIndex != -1) {
editor.getCurrentTab().setSelection(nextIndex, nextIndex + search.length());
EditorTab currentTab = editor.getCurrentTab();
currentTab.getTextArea().getFoldManager().ensureOffsetNotInClosedFold(nextIndex);
currentTab.setSelection(nextIndex, nextIndex + search.length());
currentTab.getTextArea().getCaret().setSelectionVisible(true);
return true;
}

Expand Down
1 change: 0 additions & 1 deletion app/src/processing/app/EditorTab.java
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,6 @@ private SketchTextArea createTextArea(RSyntaxDocument document)

editor.lineStatus.set(lineStart, lineEnd);
});

ToolTipManager.sharedInstance().registerComponent(textArea);

configurePopupMenu(textArea);
Expand Down