This repository was archived by the owner on Sep 4, 2020. It is now read-only.
File tree Expand file tree Collapse file tree 1 file changed +36
-0
lines changed Expand file tree Collapse file tree 1 file changed +36
-0
lines changed Original file line number Diff line number Diff line change @@ -87,6 +87,42 @@ export = function init({ typescript }: { typescript: typeof ts_module }) {
8787 return scriptFileNames ;
8888 } ;
8989
90+ const getCompletionEntryDetails = info . languageService . getCompletionEntryDetails ;
91+ info . languageService . getCompletionEntryDetails = (
92+ fileName : string ,
93+ position : number ,
94+ name : string ,
95+ formatOptions ?: ts_module . FormatCodeOptions | ts_module . FormatCodeSettings ,
96+ source ?: string ,
97+ preferences ?: ts_module . UserPreferences ) => {
98+
99+ const details = getCompletionEntryDetails . call (
100+ info . languageService ,
101+ fileName ,
102+ position ,
103+ name ,
104+ formatOptions ,
105+ source ,
106+ preferences
107+ ) ;
108+
109+ if ( details ) {
110+ if ( details . codeActions && details . codeActions . length ) {
111+ for ( const ca of details . codeActions ) {
112+ for ( const change of ca . changes ) {
113+ if ( ! change . isNewFile ) {
114+ for ( const tc of change . textChanges ) {
115+ tc . newText = tc . newText . replace ( / ^ ( i m p o r t .* f r o m [ ' " ] ) ( \. .* ) ( [ ' " ] ; \n ) / i, "$1$2.ts$3" ) ;
116+ }
117+ }
118+ }
119+ }
120+ }
121+ }
122+
123+ return details ;
124+ } ;
125+
90126 return info . languageService ;
91127 } ,
92128
You can’t perform that action at this time.
0 commit comments