Skip to content

Commit 405f826

Browse files
committed
better messaging & suppress field renaming
1 parent 53f0d0b commit 405f826

File tree

2 files changed

+28
-9
lines changed

2 files changed

+28
-9
lines changed

lib/package/commands.coffee

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ module.exports =
5555
'julia-client:rename-refactor': =>
5656
@withInk ->
5757
boot()
58-
juno.runtime.refactor.refactor()
58+
juno.runtime.refactor.renameRefactor()
5959
# @NOTE: `'clear-workspace'` is now not handled by Atom.jl
6060
# 'julia-client:reset-workspace': =>
6161
# requireClient 'reset the workspace', ->

lib/runtime/refactor.js

Lines changed: 27 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,15 @@ import modules from './modules'
55
import { getWordRangeAtBufferPosition, isValidWordToInspect } from '../misc/words'
66
import { getLocalContext } from '../misc/blocks'
77

8-
const { refactor: _refactor } = client.import(['refactor'])
8+
const renamerefactor = client.import('renamerefactor')
99
const wordRegexWithoutDotAccessor = /@?[\u00A0-\uFFFF\w_!´]+/
1010

1111
class Refactor {
1212
activate (ink) {
1313
this.ink = ink
1414
}
1515

16-
refactor () {
16+
renameRefactor () {
1717
const editor = atom.workspace.getActiveTextEditor()
1818
const bufferPosition = editor.getCursorBufferPosition()
1919

@@ -24,6 +24,9 @@ class Refactor {
2424
const old = editor.getTextInBufferRange(range)
2525
if (!isValidWordToInspect(old)) return
2626

27+
const rangeFull = getWordRangeAtBufferPosition(editor, bufferPosition)
28+
const full = editor.getTextInBufferRange(rangeFull)
29+
2730
this.ink.showBasicModal([{
2831
name: 'Rename',
2932
defaultText: old,
@@ -46,8 +49,9 @@ class Refactor {
4649
const currentModule = modules.current()
4750
const mod = currentModule ? currentModule : 'Main'
4851

49-
_refactor({
52+
renamerefactor({
5053
old,
54+
full,
5155
new: _new,
5256
path: editor.getPath(),
5357
// local context
@@ -58,15 +62,30 @@ class Refactor {
5862
// module context
5963
mod,
6064
}).then(result => {
61-
if (result.error) {
65+
// local refactoring
66+
if (result.text) {
67+
editor.setTextInBufferRange(range, result.text)
68+
}
69+
if (result.info) {
70+
atom.notifications.addInfo('Julia Client: Rename Refactor', {
71+
description: result.info,
72+
dismissable: true
73+
})
74+
}
75+
if (result.warning) {
6276
atom.notifications.addWarning('Julia Client: Rename Refactor', {
77+
description: result.warning
78+
})
79+
}
80+
if (result.error) {
81+
atom.notifications.addError('Julia Client: Rename Refactor', {
6382
description: result.error
6483
})
65-
return
6684
}
67-
// local refactoring
68-
if (result.text) {
69-
editor.setTextInBufferRange(range, result.text)
85+
if (result.success) {
86+
atom.notifications.addSuccess('Julia Client: Rename Refactor', {
87+
description: result.success
88+
})
7089
}
7190
})
7291
}).catch((err) => {

0 commit comments

Comments
 (0)