@@ -42,77 +42,76 @@ define([
4242 return rpc . execute ( "search/code" , _ . pick ( options , OPTIONS ) ) ;
4343 } ;
4444
45- var doSearch = function ( _args ) {
46- return searchCode ( _args )
47- . then ( function ( results ) {
48- return normResults ( results ) ;
49- } )
50- . then ( function ( buffer ) {
51- return files . openNew ( "Find Results" , buffer ) ;
52- } )
53- . fail ( function ( err ) {
54- console . error ( "error" , err ) ;
55- } ) ;
56- } ;
45+
5746
58- // Command search code
59- var commandSearch = Command . register ( "code.search" , {
60- title : "Find in Files" ,
61- category : "Find" ,
62- shortcuts : [
63- "mod+shift+f"
64- ] ,
65- action : function ( args ) {
47+ var searchCommandHandler = function ( title , fields , forceOptions ) {
48+ return function ( args ) {
6649 if ( _ . isString ( args ) ) args = { 'query' : args } ;
6750 args = _ . defaults ( args || { } , { } ) ;
6851
52+ var doSearch = function ( _args ) {
53+ return searchCode ( _ . extend ( _args , forceOptions || { } ) )
54+ . then ( function ( results ) {
55+ return normResults ( results ) ;
56+ } )
57+ . then ( function ( buffer ) {
58+ return files . openNew ( "Find Results" , buffer ) ;
59+ } )
60+ . fail ( function ( err ) {
61+ console . error ( "error" , err ) ;
62+ } ) ;
63+ } ;
64+
6965 if ( ! args . query ) {
70- return dialogs . fields ( "Find in Files" , {
71- 'query' : {
72- 'label' : "Find" ,
73- 'type' : "text"
74- } ,
75- 'casesensitive' : {
76- 'label' : "Case Sensitive" ,
77- 'type' : "checkbox"
78- }
79- } , args )
66+ return dialogs . fields ( title , fields , args )
8067 . then ( doSearch ) ;
8168 }
8269
8370 return doSearch ( args ) ;
8471 }
72+ } ;
73+
74+
75+ // Command search code
76+ var commandSearch = Command . register ( "code.search" , {
77+ title : "Find in Files" ,
78+ category : "Find" ,
79+ shortcuts : [
80+ "mod+shift+f"
81+ ] ,
82+ action : searchCommandHandler ( "Find in Files" , {
83+ 'query' : {
84+ 'label' : "Find" ,
85+ 'type' : "text"
86+ } ,
87+ 'casesensitive' : {
88+ 'label' : "Case Sensitive" ,
89+ 'type' : "checkbox"
90+ }
91+ } )
8592 } ) ;
8693
8794 // Command replace code
8895 var commandReplace = Command . register ( "code.replace" , {
8996 title : "Replace in Files" ,
9097 category : "Find" ,
9198 shortcuts : [ ] ,
92- action : function ( args ) {
93- if ( _ . isString ( args ) ) args = { 'query' : args } ;
94- args = _ . defaults ( args || { } , { } ) ;
95-
96- if ( ! args . query ) {
97- return dialogs . fields ( "Find and Replace in Files" , {
98- 'query' : {
99- 'label' : "Find" ,
100- 'type' : "text"
101- } ,
102- 'replacement' : {
103- 'label' : "Replace" ,
104- 'type' : "text"
105- } ,
106- 'casesensitive' : {
107- 'label' : "Case Sensitive" ,
108- 'type' : "checkbox"
109- }
110- } , args )
111- . then ( doSearch ) ;
99+ action : searchCommandHandler ( "Find and Replace in Files" , {
100+ 'query' : {
101+ 'label' : "Find" ,
102+ 'type' : "text"
103+ } ,
104+ 'replacement' : {
105+ 'label' : "Replace" ,
106+ 'type' : "text"
107+ } ,
108+ 'casesensitive' : {
109+ 'label' : "Case Sensitive" ,
110+ 'type' : "checkbox"
112111 }
113-
114- return doSearch ( args ) ;
115- }
112+ } , {
113+ replaceAll : true
114+ } )
116115 } )
117116
118117
0 commit comments