Skip to content

Commit c555cf0

Browse files
Initialize search add-on by searching for selection.
1 parent e708ee9 commit c555cf0

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

src/GToolkit-Coder-AddOns/GtTextualCoder.extension.st

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,21 @@ GtTextualCoder >> initializeSearchTextAddOns: addOns viewModel: aCoderViewModel
120120
| anElement |
121121
anElement := GtTextualCoderSearchTextElement new
122122
textualCoderViewModel: aCoderViewModel;
123-
editorDo: [ :anEditor | anEditor requestFocus ];
123+
editorDo: [ :anEditor |
124+
anEditor requestFocus
125+
aCoderViewModel selection isEmpty ifFalse: [
126+
| text |
127+
text := (aCoderViewModel sourceText
128+
copyFrom: aCoderViewModel selection from + 1
129+
to: aCoderViewModel selection to) asString.
130+
anEditor doBlockSoon: [
131+
(anEditor inserter)
132+
atCursor;
133+
string: text;
134+
insert.
135+
(anEditor selecter)
136+
all;
137+
select ] ] ];
124138
hFitContentLimited;
125139
constraintsDo: [ :c |
126140
c minWidth: 300.

0 commit comments

Comments
 (0)