@@ -65,7 +65,7 @@ export function formatRangeEdits(document: vscode.TextDocument, range: vscode.Ra
65
65
const cursor = mirroredDoc . getTokenCursor ( startIndex ) ;
66
66
if ( ! cursor . withinString ( ) ) {
67
67
const rangeTuple : number [ ] = [ startIndex , endIndex ] ;
68
- const newText : string = _formatRange ( text , document . getText ( ) , rangeTuple , document . eol == 2 ? "\r\n" : "\n" ) ;
68
+ const newText : string = _formatRange ( text , document . getText ( ) , rangeTuple , document . eol == 2 ? "\r\n" : "\n" ) [ 'range-text' ] ;
69
69
if ( newText ) {
70
70
return [ vscode . TextEdit . replace ( range , newText ) ] ;
71
71
}
@@ -122,17 +122,18 @@ export function formatPositionInfoEditableDoc(document: docModel.EditableDocumen
122
122
}
123
123
124
124
export function formatRangeEditableDoc ( document : docModel . EditableDocument , range : [ number , number ] , onType : boolean = false , extraConfig = { } ) : Thenable < boolean > {
125
- const formattedInfo = formatRangeInfoEditableDoc ( document , range , onType , extraConfig ) ;
125
+ const formattedInfo = formatRangeInfoEditableDoc ( document , range , onType , { performFormatAsYouType : false , ... extraConfig } ) ;
126
126
return performFormatEditableDoc ( document , formattedInfo , onType , extraConfig ) ;
127
127
}
128
128
129
129
export function formatPositionEditableDoc ( document : docModel . EditableDocument , onType : boolean = false , extraConfig = { } ) : Thenable < boolean > {
130
- const formattedInfo = formatPositionInfoEditableDoc ( document , onType , extraConfig ) ;
130
+ const formattedInfo = formatPositionInfoEditableDoc ( document , onType , { performFormatAsYouType : true , ... extraConfig } ) ;
131
131
return performFormatEditableDoc ( document , formattedInfo , onType , extraConfig ) ;
132
132
}
133
133
134
134
function performFormatEditableDoc ( document : docModel . EditableDocument , formattedInfo , onType : boolean , extraConfig = { } ) : Thenable < boolean > {
135
135
const adjustSelection = extraConfig [ 'adjustSelection' ] === undefined || extraConfig [ 'adjustSelection' ] ;
136
+ const performFormatAsYouType = extraConfig [ 'performFormatAsYouType' ] === undefined || extraConfig [ 'performFormatAsYouType' ] ;
136
137
if ( formattedInfo ) {
137
138
const newSelectionConfig = adjustSelection ? { selection : new docModel . ModelEditSelection ( formattedInfo . newIndex ) } : { } ;
138
139
if ( formattedInfo . previousText != formattedInfo . formattedText ) {
@@ -210,7 +211,7 @@ function _formatIndex(allText: string, range: [number, number], index: number, e
210
211
}
211
212
212
213
213
- function _formatRange ( rangeText : string , allText : string , range : number [ ] , eol : string ) : string {
214
+ function _formatRange ( rangeText : string , allText : string , range : number [ ] , eol : string ) : { "range-text" : string , "range" : [ number , number ] , "new-index" : number } {
214
215
const d = {
215
216
"range-text" : rangeText ,
216
217
"all-text" : allText ,
@@ -221,6 +222,6 @@ function _formatRange(rangeText: string, allText: string, range: number[], eol:
221
222
const cljData = cljify ( d ) ;
222
223
const result = jsify ( formatTextAtRange ( cljData ) ) ;
223
224
if ( ! result [ "error" ] ) {
224
- return result [ "range-text" ] ;
225
+ return result ;
225
226
}
226
227
}
0 commit comments