Skip to content

Commit

Permalink
update to #651
Browse files Browse the repository at this point in the history
  • Loading branch information
aviatesk committed Nov 9, 2019
1 parent c6600ab commit b016785
Showing 1 changed file with 14 additions and 12 deletions.
26 changes: 14 additions & 12 deletions lib/runtime/refactor.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,24 +19,26 @@ class Refactor {

if (!client.isActive()) return

const range = getWordRangeAtBufferPosition(editor, bufferPosition, wordRegexWithoutDotAccessor)
const range = getWordRangeAtBufferPosition(editor, bufferPosition, {
wordRegex: wordRegexWithoutDotAccessor
})
if (range.isEmpty()) return
const old = editor.getTextInBufferRange(range)
if (!isValidWordToInspect(old)) return
const oldWord = editor.getTextInBufferRange(range)
if (!isValidWordToInspect(oldWord)) return

const rangeFull = getWordRangeAtBufferPosition(editor, bufferPosition)
const full = editor.getTextInBufferRange(rangeFull)
const fullWord = editor.getTextInBufferRange(rangeFull)

this.ink.showBasicModal([{
name: 'Rename',
defaultText: old,
message: `Enter an new name to which \`${old}\` will be renamed.`
defaultText: oldWord,
message: `Enter an new name to which \`${oldWord}\` will be renamed.`
}]).then(items => {
// check the new name is a valid identifier
const _new = items['Rename']
if (!isValidWordToInspect(_new) || _new.match(wordRegexWithoutDotAccessor) != _new) {
const newWord = items['Rename']
if (!isValidWordToInspect(newWord) || newWord.match(wordRegexWithoutDotAccessor) != newWord) {
atom.notifications.addWarning('Julia Client: Rename Refactor', {
description: `\`${_new}\` isn't a valid identifier`
description: `\`${newWord}\` isn't a valid identifier`
})
return
}
Expand All @@ -50,9 +52,9 @@ class Refactor {
const mod = currentModule ? currentModule : 'Main'

renamerefactor({
old,
full,
new: _new,
oldWord,
fullWord,
newWord,
// local context
column: column + 1,
row: row + 1,
Expand Down

0 comments on commit b016785

Please sign in to comment.