2
2
3
3
import { client } from '../connection'
4
4
import modules from './modules'
5
- import { wordRegex , getWord , isValidWordToInspect } from '../misc/words'
5
+ import { getWordRangeAtBufferPosition , isValidWordToInspect } from '../misc/words'
6
6
import { getLocalContext } from '../misc/blocks'
7
7
8
8
const { refactor : _refactor } = client . import ( [ 'refactor' ] )
9
+ const wordRegexWithoutDotAccessor = / @ ? [ \u00A0 - \uFFFF \w _ ! ´ ] + /
9
10
10
11
class Refactor {
11
12
activate ( ink ) {
@@ -18,7 +19,9 @@ class Refactor {
18
19
19
20
if ( ! client . isActive ( ) ) return
20
21
21
- const { word : old } = getWord ( editor , bufferPosition )
22
+ const range = getWordRangeAtBufferPosition ( editor , bufferPosition , wordRegexWithoutDotAccessor )
23
+ if ( range . isEmpty ( ) ) return
24
+ const old = editor . getTextInBufferRange ( range )
22
25
if ( ! isValidWordToInspect ( old ) ) return
23
26
24
27
this . ink . showBasicModal ( [ {
@@ -28,7 +31,7 @@ class Refactor {
28
31
} ] ) . then ( items => {
29
32
// check the new name is a valid identifier
30
33
const _new = items [ 'Rename' ]
31
- if ( ! isValidWordToInspect ( _new ) || _new . match ( wordRegex ) != _new ) {
34
+ if ( ! isValidWordToInspect ( _new ) || _new . match ( wordRegexWithoutDotAccessor ) != _new ) {
32
35
atom . notifications . addWarning ( 'Julia Client: Rename Refactor' , {
33
36
description : `\`${ _new } \` is not a valid identifier`
34
37
} )
0 commit comments