Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #26 from scala-ide/issue/auto-indenter-get-confuse…
…d-1000688 Created a new indenter strategy that will automatically add a closing bracket
- Loading branch information
Showing
2 changed files
with
18 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
16 changes: 16 additions & 0 deletions
16
org.scala-ide.sdt.core/src/scala/tools/eclipse/ui/AutoCloseBracketStrategy.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
package scala.tools.eclipse.ui | ||
|
||
import org.eclipse.jface.text.DocumentCommand | ||
import org.eclipse.jface.text.IAutoEditStrategy | ||
import org.eclipse.jface.text.IDocument | ||
|
||
/** Automatically adds a matching closing bracket whenever the user enters a left bracket. */ | ||
class AutoCloseBracketStrategy extends IAutoEditStrategy { | ||
def customizeDocumentCommand(document: IDocument, command: DocumentCommand) { | ||
if (command.text == "{") { | ||
command.text = command.text + "}" | ||
command.caretOffset = command.offset + 1 | ||
command.shiftsCaret = false | ||
} | ||
} | ||
} |