mirror of
https://github.com/atom/atom.git
synced 2026-02-09 22:24:59 -05:00
When ( [ { ' or " is inserted, insert the matching character after the cursor
This commit is contained in:
@@ -4,15 +4,22 @@ _ = require 'underscore'
|
||||
|
||||
module.exports =
|
||||
class LanguageMode
|
||||
matchingCharacters:
|
||||
'(': ')'
|
||||
'[': ']'
|
||||
'{': '}'
|
||||
'"': '"'
|
||||
"'": "'"
|
||||
|
||||
constructor: (@editSession) ->
|
||||
@buffer = @editSession.buffer
|
||||
@aceMode = @requireAceMode()
|
||||
@aceAdaptor = new AceAdaptor(@editSession)
|
||||
|
||||
_.adviseBefore @editSession, 'insertText', (text) ->
|
||||
if text == '('
|
||||
@insertText '()'
|
||||
@moveCursorLeft()
|
||||
_.adviseBefore @editSession, 'insertText', (text) =>
|
||||
if matchingCharacter = @matchingCharacters[text]
|
||||
@editSession.insertText text + matchingCharacter
|
||||
@editSession.moveCursorLeft()
|
||||
false
|
||||
|
||||
requireAceMode: (fileExtension) ->
|
||||
|
||||
Reference in New Issue
Block a user