66import nls = require( 'vs/nls' ) ;
77import { TPromise } from 'vs/base/common/winjs.base' ;
88import URI from 'vs/base/common/uri' ;
9+ import * as network from 'vs/base/common/network' ;
910import * as Map from 'vs/base/common/map' ;
1011import { IReplaceService } from 'vs/workbench/parts/search/common/replace' ;
1112import { EditorInput } from 'vs/workbench/common/editor' ;
1213import { IEditorService , IEditorInput , ITextEditorModel } from 'vs/platform/editor/common/editor' ;
14+ import { IWorkbenchEditorService } from 'vs/workbench/services/editor/common/editorService' ;
1315import { IModel } from 'vs/editor/common/editorCommon' ;
1416import { IModelService } from 'vs/editor/common/services/modelService' ;
1517import { IEventService } from 'vs/platform/event/common/event' ;
@@ -22,7 +24,8 @@ class EditorInputCache {
2224
2325 private cache : Map . SimpleMap < URI , TPromise < DiffEditorInput > > ;
2426
25- constructor ( private replaceService : ReplaceService , private editorService , private modelService : IModelService ) {
27+ constructor ( private replaceService : ReplaceService , private editorService : IWorkbenchEditorService ,
28+ private modelService : IModelService ) {
2629 this . cache = new Map . SimpleMap < URI , TPromise < DiffEditorInput > > ( ) ;
2730 }
2831
@@ -32,10 +35,8 @@ class EditorInputCache {
3235 editorInputPromise = this . createInput ( fileMatch ) ;
3336 this . cache . set ( fileMatch . resource ( ) , editorInputPromise ) ;
3437 this . refreshInput ( fileMatch , text , true ) ;
38+ fileMatch . addListener2 ( 'disposed' , fileMatch => this . disposeInput ( fileMatch ) ) ;
3539 }
36-
37- fileMatch . addListener2 ( 'disposed' , fileMatch => this . disposeInput ( fileMatch ) ) ;
38-
3940 return editorInputPromise ;
4041 }
4142
@@ -66,8 +67,7 @@ class EditorInputCache {
6667 let editorInputPromise = this . cache . get ( resourceUri ) ;
6768 if ( editorInputPromise ) {
6869 editorInputPromise . done ( ( diffInput ) => {
69- diffInput . dispose ( ) ;
70- this . modelService . destroyModel ( this . getReplaceResource ( resourceUri ) ) ;
70+ this . disposeReplaceInput ( this . getReplaceResource ( resourceUri ) , diffInput ) ;
7171 this . cache . delete ( resourceUri ) ;
7272 } ) ;
7373 }
@@ -82,7 +82,8 @@ class EditorInputCache {
8282 return TPromise . join ( [ this . createLeftInput ( fileMatch ) ,
8383 this . createRightInput ( fileMatch ) ] ) . then ( inputs => {
8484 const [ left , right ] = inputs ;
85- return new DiffEditorInput ( nls . localize ( 'fileReplaceChanges' , "{0} ↔ {1} (after)" , fileMatch . name ( ) , fileMatch . name ( ) ) , undefined , < EditorInput > left , < EditorInput > right ) ;
85+ let editorInput = new DiffEditorInput ( nls . localize ( 'fileReplaceChanges' , "{0} ↔ {1} (Replace Preview)" , fileMatch . name ( ) , fileMatch . name ( ) ) , undefined , < EditorInput > left , < EditorInput > right ) ;
86+ return editorInput ;
8687 } ) ;
8788 }
8889
@@ -101,10 +102,14 @@ class EditorInputCache {
101102 } ) ;
102103 }
103104
104- private getReplaceResource ( resource : URI ) : URI {
105- return resource . with ( { scheme : 'private' } ) ;
105+ private disposeReplaceInput ( replaceUri : URI , diffInput : EditorInput ) :void {
106+ diffInput . dispose ( ) ;
107+ this . modelService . destroyModel ( replaceUri ) ;
106108 }
107109
110+ private getReplaceResource ( resource : URI ) : URI {
111+ return resource . with ( { scheme : network . Schemas . internal , fragment : 'preview' } ) ;
112+ }
108113}
109114
110115export class ReplaceService implements IReplaceService {
0 commit comments