@@ -6,15 +6,40 @@ import * as vscode from 'vscode'
6
6
export function activate ( ctx : vscode . ExtensionContext ) {
7
7
ctx . subscriptions . push ( vscode . commands . registerCommand (
8
8
'snippet.find' , find ) )
9
+ ctx . subscriptions . push ( vscode . commands . registerCommand (
10
+ 'snippet.findInplace' , findInplace ) )
11
+ ctx . subscriptions . push ( vscode . commands . registerCommand (
12
+ 'snippet.findInNewEditor' , findInNewEditor ) )
9
13
ctx . subscriptions . push ( vscode . commands . registerCommand (
10
14
'snippet.findSelectedText' , findSelectedText ) )
11
15
}
12
16
13
17
function find ( ) {
18
+ let configuration = vscode . workspace . getConfiguration ( 'snippet' )
19
+ let openInNewEditor : boolean = configuration [ "openInNewEditor" ]
20
+
21
+ vscode . window . showInputBox ( )
22
+ . then ( query => {
23
+ asyncRequest ( query , function ( data ) {
24
+ insertText ( data , openInNewEditor )
25
+ } )
26
+ } ) ;
27
+ }
28
+
29
+ function findInplace ( ) {
14
30
vscode . window . showInputBox ( )
15
31
. then ( query => {
16
32
asyncRequest ( query , function ( data ) {
17
- insertText ( data )
33
+ insertText ( data , false )
34
+ } )
35
+ } ) ;
36
+ }
37
+
38
+ function findInNewEditor ( ) {
39
+ vscode . window . showInputBox ( )
40
+ . then ( query => {
41
+ asyncRequest ( query , function ( data ) {
42
+ insertText ( data , true )
18
43
} )
19
44
} ) ;
20
45
}
@@ -29,8 +54,11 @@ function findSelectedText() {
29
54
let selection = editor . selection ;
30
55
let query = editor . document . getText ( selection ) ;
31
56
57
+ let configuration = vscode . workspace . getConfiguration ( 'snippet' )
58
+ let openInNewEditor : boolean = configuration [ "openInNewEditor" ]
59
+
32
60
asyncRequest ( query , function ( data ) {
33
- insertText ( data )
61
+ insertText ( data , openInNewEditor )
34
62
} )
35
63
}
36
64
@@ -81,9 +109,7 @@ function asyncRequest(queryRaw: string, callback: (data: string) => void) {
81
109
} )
82
110
}
83
111
84
- function insertText ( content : string ) {
85
- let configuration = vscode . workspace . getConfiguration ( 'snippet' )
86
- let openInNewEditor : boolean = configuration [ "openInNewEditor" ]
112
+ function insertText ( content : string , openInNewEditor = true ) {
87
113
88
114
if ( openInNewEditor ) {
89
115
let language = vscode . window . activeTextEditor . document . languageId
0 commit comments