Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
asinghvi17 authored Nov 16, 2019
1 parent f4d6c61 commit e4455c7
Showing 1 changed file with 8 additions and 9 deletions.
17 changes: 8 additions & 9 deletions lib/snippet-manager.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -151,10 +151,10 @@ class SnippetManager extends LTool
te = atom.workspace.getActiveTextEditor()

# First, check if there is a selection, and if so, add $..$ around it
if text = te.getSelectedText()
text = text.replace(/\\/g, "\\\\")
range = te.getSelectedBufferRange()
te.setSelectedBufferRange(range, '')
range = te.getSelectedBufferRange()
text = te.getTextInBufferRange(range)
text = text.replace(/\\/g, "\\\\")
if text
@snippetService.insertSnippet("\$#{text}\$")
return

Expand Down Expand Up @@ -186,11 +186,10 @@ class SnippetManager extends LTool
te = atom.workspace.getActiveTextEditor()

# First, check if there is a selection, and if so, add quotes around it
if text = te.getSelectedText()
text = text.replace(/\\/g, "\\\\")
range = te.getSelectedBufferRange()
te.setSelectedBufferRange(range, '')
# Use snippet to leave selection on (same as ST)
range = te.getSelectedBufferRange()
text = te.getTextInBufferRange(range)
text = text.replace(/\\/g, "\\\\")
if text
@snippetService.insertSnippet("#{left}${1:#{text}}#{right}")
return

Expand Down

0 comments on commit e4455c7

Please sign in to comment.