1- import  *   as   dmp  from  'diff-match-patch' ; 
1+ import  {   Diff ,   diff_match_patch   }  from  'diff-match-patch' ; 
22import  *  as  fs  from  'fs-extra' ; 
33import  {  injectable  }  from  'inversify' ; 
44import  *  as  md5  from  'md5' ; 
@@ -17,7 +17,7 @@ enum EditAction {
1717const  NEW_LINE_LENGTH  =  EOL . length ; 
1818
1919class  Patch  { 
20-  public  diffs ! : dmp . Diff [ ] ; 
20+  public  diffs ! : Diff [ ] ; 
2121 public  start1 ! : number ; 
2222 public  start2 ! : number ; 
2323 public  length1 ! : number ; 
@@ -61,7 +61,8 @@ export function getTextEditsFromPatch(before: string, patch: string): TextEdit[]
6161 // Remove the text added by unified_diff 
6262 // # Work around missing newline (http://bugs.python.org/issue2142). 
6363 patch  =  patch . replace ( / \\   N o   n e w l i n e   a t   e n d   o f   f i l e [ \r \n ] / ,  '' ) ; 
64- 
64+  // tslint:disable-next-line:no-require-imports 
65+  const  dmp  =  require ( 'diff-match-patch' )  as  typeof  import ( 'diff-match-patch' ) ; 
6566 const  d  =  new  dmp . diff_match_patch ( ) ; 
6667 const  patches  =  patch_fromText . call ( d ,  patch ) ; 
6768 if  ( ! Array . isArray ( patches )  ||  patches . length  ===  0 )  { 
@@ -114,6 +115,8 @@ export function getWorkspaceEditsFromPatch(filePatches: string[], workspaceRoot?
114115 // # Work around missing newline (http://bugs.python.org/issue2142). 
115116 patch  =  patch . replace ( / \\   N o   n e w l i n e   a t   e n d   o f   f i l e [ \r \n ] / ,  '' ) ; 
116117
118+  // tslint:disable-next-line:no-require-imports 
119+  const  dmp  =  require ( 'diff-match-patch' )  as  typeof  import ( 'diff-match-patch' ) ; 
117120 const  d  =  new  dmp . diff_match_patch ( ) ; 
118121 const  patches  =  patch_fromText . call ( d ,  patch ) ; 
119122 if  ( ! Array . isArray ( patches )  ||  patches . length  ===  0 )  { 
@@ -150,6 +153,8 @@ export function getWorkspaceEditsFromPatch(filePatches: string[], workspaceRoot?
150153 return  workspaceEdit ; 
151154} 
152155export  function  getTextEdits ( before : string ,  after : string ) : TextEdit [ ]  { 
156+  // tslint:disable-next-line:no-require-imports 
157+  const  dmp  =  require ( 'diff-match-patch' )  as  typeof  import ( 'diff-match-patch' ) ; 
153158 const  d  =  new  dmp . diff_match_patch ( ) ; 
154159 const  diffs  =  d . diff_main ( before ,  after ) ; 
155160 return  getTextEditsInternal ( before ,  diffs ) . map ( edit  =>  edit . apply ( ) ) ; 
@@ -178,6 +183,8 @@ function getTextEditsInternal(before: string, diffs: [number, string][], startLi
178183 } 
179184 } 
180185
186+  // tslint:disable-next-line:no-require-imports 
187+  const  dmp  =  require ( 'diff-match-patch' )  as  typeof  import ( 'diff-match-patch' ) ; 
181188 // tslint:disable-next-line:switch-default 
182189 switch  ( diffs [ i ] [ 0 ] )  { 
183190 case  dmp . DIFF_DELETE :
@@ -261,7 +268,7 @@ function patch_fromText(textline): Patch[] {
261268 throw  new  Error ( `Invalid patch string: ${ text [ textPointer ] }  ) ; 
262269 } 
263270 // tslint:disable-next-line:no-any 
264-  const  patch  =  new  ( < any > dmp . diff_match_patch ) . patch_obj ( ) ; 
271+  const  patch  =  new  ( < any > diff_match_patch ) . patch_obj ( ) ; 
265272 patches . push ( patch ) ; 
266273 patch . start1  =  parseInt ( m [ 1 ] ,  10 ) ; 
267274 if  ( m [ 2 ]  ===  '' )  { 
@@ -285,6 +292,8 @@ function patch_fromText(textline): Patch[] {
285292 patch . length2  =  parseInt ( m [ 4 ] ,  10 ) ; 
286293 } 
287294 textPointer  +=  1 ; 
295+  // tslint:disable-next-line:no-require-imports 
296+  const  dmp  =  require ( 'diff-match-patch' )  as  typeof  import ( 'diff-match-patch' ) ; 
288297
289298 while  ( textPointer  <  text . length )  { 
290299 const  sign  =  text [ textPointer ] . charAt ( 0 ) ; 
@@ -339,6 +348,8 @@ export class EditorUtils implements IEditorUtils {
339348 // # Work around missing newline (http://bugs.python.org/issue2142). 
340349 patch  =  patch . replace ( / \\   N o   n e w l i n e   a t   e n d   o f   f i l e [ \r \n ] / ,  '' ) ; 
341350
351+  // tslint:disable-next-line:no-require-imports 
352+  const  dmp  =  require ( 'diff-match-patch' )  as  typeof  import ( 'diff-match-patch' ) ; 
342353 const  d  =  new  dmp . diff_match_patch ( ) ; 
343354 const  patches  =  patch_fromText . call ( d ,  patch ) ; 
344355 if  ( ! Array . isArray ( patches )  ||  patches . length  ===  0 )  { 
0 commit comments