##// END OF EJS Templates
Improve auto_match for quotes...
Lucy McPhail -
Show More
@@ -139,12 +139,24 b' def create_ipython_shortcuts(shell):'
139 event.current_buffer.insert_text("{}")
139 event.current_buffer.insert_text("{}")
140 event.current_buffer.cursor_left()
140 event.current_buffer.cursor_left()
141
141
142 @kb.add('"', filter=focused_insert & auto_match & following_text(r"[,)}\]]|$"))
142 @kb.add(
143 '"',
144 filter=focused_insert
145 & auto_match
146 & preceding_text(r'^([^"]+|"[^"]*")*$')
147 & following_text(r"[,)}\]]|$"),
148 )
143 def _(event):
149 def _(event):
144 event.current_buffer.insert_text('""')
150 event.current_buffer.insert_text('""')
145 event.current_buffer.cursor_left()
151 event.current_buffer.cursor_left()
146
152
147 @kb.add("'", filter=focused_insert & auto_match & following_text(r"[,)}\]]|$"))
153 @kb.add(
154 "'",
155 filter=focused_insert
156 & auto_match
157 & preceding_text(r"^([^']+|'[^']*')*$")
158 & following_text(r"[,)}\]]|$"),
159 )
148 def _(event):
160 def _(event):
149 event.current_buffer.insert_text("''")
161 event.current_buffer.insert_text("''")
150 event.current_buffer.cursor_left()
162 event.current_buffer.cursor_left()
@@ -186,16 +198,6 b' def create_ipython_shortcuts(shell):'
186 event.current_buffer.insert_text("{}" + dashes)
198 event.current_buffer.insert_text("{}" + dashes)
187 event.current_buffer.cursor_left(len(dashes) + 1)
199 event.current_buffer.cursor_left(len(dashes) + 1)
188
200
189 @kb.add('"', filter=focused_insert & auto_match & preceding_text(r".*(r|R)$"))
190 def _(event):
191 event.current_buffer.insert_text('""')
192 event.current_buffer.cursor_left()
193
194 @kb.add("'", filter=focused_insert & auto_match & preceding_text(r".*(r|R)$"))
195 def _(event):
196 event.current_buffer.insert_text("''")
197 event.current_buffer.cursor_left()
198
199 # just move cursor
201 # just move cursor
200 @kb.add(")", filter=focused_insert & auto_match & following_text(r"^\)"))
202 @kb.add(")", filter=focused_insert & auto_match & following_text(r"^\)"))
201 @kb.add("]", filter=focused_insert & auto_match & following_text(r"^\]"))
203 @kb.add("]", filter=focused_insert & auto_match & following_text(r"^\]"))
General Comments 0
You need to be logged in to leave comments. Login now