Permalink
Browse files

When renaming backquoted identifiers, exclude the `` in the linked re…

…gions.

The problem is that all linked regions need to have the same length, so
if I have two occurrences of an identifier, one of them enclosed in ``,
we need to exclude the ``. Fixes #1000637.
  • Loading branch information...
misto committed Oct 5, 2011
1 parent 33088eb commit ef52a59a12145cf08d4ba79aebfcba5ae7ac7ab6
@@ -36,9 +36,21 @@ class LocalRenameAction extends RefactoringAction {
def runInlineRename(r: RenameScalaIdeRefactoring) {
import r.refactoring._
- import r.selection.selectedSymbolTree
+ import r.selection.selectedSymbolTree
- val positions = index.occurences(selectedSymbolTree.get.symbol) map (_.namePosition) map (pos => (pos.start, pos.end - pos.start))
+ val positions = for {
+ // there's always a selected tree, otherwise
+ // the refactoring won't be called.
+ selected <- selectedSymbolTree.toList
+ t <- index.occurences(selected.symbol)
+ } yield {
+ val pos = t.namePosition
+ if(pos.source.content(pos.start) == '`') {
+ (pos.start + 1, pos.end - pos.start - 2)
+ } else {
+ (pos.start, pos.end - pos.start)
+ }
+ }
EditorHelpers.enterLinkedModeUi(positions)
}

0 comments on commit ef52a59

Please sign in to comment.