1
- import * as vscode from 'vscode' ;
2
- import { CommandNames } from './constants' ;
3
- import * as request from 'request-promise-native' ;
4
1
import * as cheerio from 'cheerio' ;
5
- import * as LRU from 'lru-cache' ;
6
- import * as _ from 'lodash' ;
7
2
import * as yaml from 'js-yaml' ;
3
+ import * as _ from 'lodash' ;
4
+ import * as LRU from 'lru-cache' ;
5
+ import * as request from 'request-promise-native' ;
6
+ import * as vscode from 'vscode' ;
7
+ import { CommandNames } from './constants' ;
8
8
9
9
const askHoogle = async ( variable : string ) : Promise < any > => {
10
10
return await request ( {
@@ -13,13 +13,13 @@ const askHoogle = async (variable: string): Promise<any> => {
13
13
} ) . promise ( ) ;
14
14
} ;
15
15
16
- const withCache = < T , U > ( cache : LRU . Cache < T , U > , f : ( a : T ) => U ) => ( a : T ) => {
17
- const maybeB = cache . get ( a ) ;
16
+ const withCache = < T , U > ( theCache : LRU . Cache < T , U > , f : ( a : T ) => U ) => ( a : T ) => {
17
+ const maybeB = theCache . get ( a ) ;
18
18
if ( maybeB ) {
19
19
return maybeB ;
20
20
} else {
21
21
const b = f ( a ) ;
22
- cache . set ( a , b ) ;
22
+ theCache . set ( a , b ) ;
23
23
return b ;
24
24
}
25
25
} ;
@@ -79,15 +79,16 @@ export namespace ImportIdentifier {
79
79
80
80
export function registerCommand ( ) : vscode . Disposable {
81
81
return vscode . commands . registerTextEditorCommand ( CommandNames . ImportIdentifierCommandName , async ( editor , edit ) => {
82
- const identifierRegExp = new RegExp ( '[' + _ . escapeRegExp ( '!#$%&*+./<=>?@^|-~:' ) + ']+' + '|' + "[\\w']+" ) ;
82
+ // \u0027 is ' (satisfies the linter)
83
+ const identifierRegExp = new RegExp ( '[' + _ . escapeRegExp ( '!#$%&*+./<=>?@^|-~:' ) + ']+' + '|' + '[\\w\u0027]+' ) ;
83
84
84
85
const identifierRange = editor . selection . isEmpty
85
86
? editor . document . getWordRangeAtPosition ( editor . selections [ 0 ] . active , identifierRegExp )
86
87
: new vscode . Range ( editor . selection . start , editor . selection . end ) ;
87
88
88
89
if ( ! identifierRange ) {
89
90
vscode . window . showErrorMessage (
90
- " No Haskell identifier found at the cursor (here's the regex used: " + identifierRegExp + ' )'
91
+ ' No Haskell identifier found at the cursor (here is the regex used: ' + identifierRegExp + ' )'
91
92
) ;
92
93
return ;
93
94
}
0 commit comments