Theme Editor: use markAll() (instead of find()) to avoid that selection jumps to next occurrence when showing find bar or when changing options

This commit is contained in:
Karl Tauber
2020-12-31 16:11:22 +01:00
parent 1c08e98c1c
commit c40912013d

View File

@@ -77,7 +77,7 @@ class FlatFindReplaceBar
super.addNotify(); super.addNotify();
// if showing bar, highlight matches in editor // if showing bar, highlight matches in editor
find(); markAll();
} }
@Override @Override
@@ -99,11 +99,21 @@ class FlatFindReplaceBar
} }
private void find() { private void find() {
findOrMarkAll( true );
}
private void markAll() {
findOrMarkAll( false );
}
private void findOrMarkAll( boolean find ) {
// update search context // update search context
context.setSearchFor( findField.getText() ); context.setSearchFor( findField.getText() );
// find // find
SearchResult result = SearchEngine.find( textArea, context ); SearchResult result = find
? SearchEngine.find( textArea, context )
: SearchEngine.markAll( textArea, context );
// update matches info label // update matches info label
matchesLabel.setText( result.getMarkedCount() + " matches" ); matchesLabel.setText( result.getMarkedCount() + " matches" );
@@ -111,17 +121,17 @@ class FlatFindReplaceBar
private void matchCaseChanged() { private void matchCaseChanged() {
context.setMatchCase( matchCaseToggleButton.isSelected() ); context.setMatchCase( matchCaseToggleButton.isSelected() );
find(); markAll();
} }
private void matchWholeWordChanged() { private void matchWholeWordChanged() {
context.setWholeWord( matchWholeWordToggleButton.isSelected() ); context.setWholeWord( matchWholeWordToggleButton.isSelected() );
find(); markAll();
} }
private void regexChanged() { private void regexChanged() {
context.setRegularExpression( regexToggleButton.isSelected() ); context.setRegularExpression( regexToggleButton.isSelected() );
find(); markAll();
} }
private void close() { private void close() {