Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Uncaught TypeError: Cannot create property 'reversed' on string '' #176

Open
ekoepplin opened this issue Dec 17, 2017 · 12 comments · May be fixed by #180
Open

Uncaught TypeError: Cannot create property 'reversed' on string '' #176

ekoepplin opened this issue Dec 17, 2017 · 12 comments · May be fixed by #180

Comments

@ekoepplin
Copy link

[Enter steps to reproduce:]

I just wanted, as I did in the past, to put $ $ around some mathematical notation. Basically I can put $ $ and then add some content $A_1$ or I can A_1 and then put $A_1$ using, as usual, SHIFT 4. The second approach returns an error.

Atom: 1.23.1 x64
Electron: 1.6.15
OS: Mac OS X 10.12.5
Thrown From: latextools package 0.8.5

Stack Trace

Uncaught TypeError: Cannot create property 'reversed' on string ''

At /Applications/Atom.app/Contents/Resources/app/src/selection.js:94

TypeError: Cannot create property 'reversed' on string ''
    at Selection.setBufferRange (/Applications/Atom.app/Contents/Resources/app/src/selection.js:94:58)
    at mergeIntersectingSelections (/Applications/Atom.app/Contents/Resources/app/src/text-editor.js:2766:31)
    at TextEditor.mergeSelections (/Applications/Atom.app/Contents/Resources/app/src/text-editor.js:3191:53)
    at TextEditor.mergeIntersectingSelections (/Applications/Atom.app/Contents/Resources/app/src/text-editor.js:3165:42)
    at TextEditor.setSelectedBufferRanges (/Applications/Atom.app/Contents/Resources/app/src/text-editor.js:2761:16)
    at TextEditor.setSelectedBufferRange (/Applications/Atom.app/Contents/Resources/app/src/text-editor.js:2741:23)
    at SnippetManager.module.exports.SnippetManager.dollarSign (/packages/latextools/lib/snippet-manager.coffee:157:10)
    at /packages/latextools/lib/latextools.coffee:274:23)
    at CommandRegistry.handleCommandEvent (/Applications/Atom.app/Contents/Resources/app/src/command-registry.js:388:36)
    at KeymapManager.module.exports.KeymapManager.dispatchCommandEvent (/Applications/Atom.app/Contents/Resources/app/node_modules/atom-keymap/lib/keymap-manager.js:621:22)
    at KeymapManager.module.exports.KeymapManager.handleKeyboardEvent (/Applications/Atom.app/Contents/Resources/app/node_modules/atom-keymap/lib/keymap-manager.js:412:28)
    at WindowEventHandler.handleDocumentKeyEvent (/Applications/Atom.app/Contents/Resources/app/src/window-event-handler.js:108:40)

Commands

     -0:56.8.0 latextools:dollar-sign (input.hidden-input)
 19x -0:55.2.0 core:move-right (input.hidden-input)
  2x -0:51.7.0 core:backspace (input.hidden-input)
     -0:50.7.0 latextools:dollar-sign (input.hidden-input)
     -0:41.4.0 core:backspace (input.hidden-input)
  2x -0:40.8.0 core:move-right (input.hidden-input)
     -0:40 core:backspace (input.hidden-input)
     -0:35 latextools:dollar-sign (input.hidden-input)
     -0:29.6.0 core:cut (input.hidden-input)
     -0:28.8.0 core:paste (input.hidden-input)
     -0:27.5.0 core:backspace (input.hidden-input)
  9x -0:25.5.0 core:move-right (input.hidden-input)
  2x -0:23.6.0 core:move-left (input.hidden-input)
     -0:15.1.0 latextools:ref-cite-keypress (input.hidden-input)
  3x -0:11.3.0 core:backspace (input.hidden-input)
     -0:04.8.0 latextools:dollar-sign (input.hidden-input)

Non-Core Packages

advanced-open-file 0.16.7 
ask-stack 2.2.0 
atom-beautify 0.30.9 
atom-python-run 0.9.5 
auto-encoding 0.7.0 
auto-update-packages 1.0.1 
autocomplete-paths 2.12.1 
autocomplete-python 1.10.5 
browser-plus 0.0.98 
build 0.69.0 
build-rscript 0.6.2 
busy 0.7.0 
busy-signal 1.4.3 
data-atom 0.26.2 
Ensime 0.41.0 
gist 1.1.0 
git-projects 1.17.0 
git-time-machine 1.5.9 
highlight-selected 0.13.1 
Hydrogen 2.1.1 
hyperclick 0.1.5 
intentions 1.1.5 
keybinding-cheatsheet 0.1.1 
kite 0.58.0 
language-latex 1.1.1 
language-markdown 0.25.1 
language-mongodb 0.3.1 
language-pgsql 0.2.3 
language-r 0.4.2 
language-scala 1.1.9 
language-sql-mysql 0.3.1 
latex 0.49.0 
latex-autocomplete 1.1.1 
latextools 0.8.5 
linter 2.2.0 
linter-ui-default 1.6.10 
MagicPython 1.0.12 
markdown-pdf 2.1.0 
markdown-preview-plus 2.4.16 
markdown-writer 2.7.3 
minimap-highlight-selected 4.6.1 
open-html-in-browser 0.2.1 
open-recent 5.0.0 
pandoc 0.2.2 
pdf-view 0.61.0 
platformio-ide-terminal 2.7.0 
pretty-json 1.6.4 
project-manager 3.3.5 
python-debugger 0.2.0 
python-indent 1.1.4 
python-tools 0.6.9 
qolor 0.4.2 
quick-query 0.12.2 
r-exec 0.5.0 
sbt 0.13.0 
scala-format 0.1.8 
script 3.17.3 
sync-settings 0.8.3 
tasks 2.9.1 
todo-show 2.1.0 
@nicola-gigante
Copy link

To me it also happens where doing CMD+L+E to start an environment.

@sheljohn
Copy link

sheljohn commented Dec 24, 2017

+1: Similar thing (quotes) started happening to me on OSX Sierra (10.12.6) using Atom 1.23.1 x86 with LatexTools 0.8.5.

Steps to reproduce:

  • Save document as tex file
  • Type text, select word(s), and type "
  • Error is triggered, linking to this issue.

Happy to provide more details if needed (eg package-list, console log, etc).

@gmendesb
Copy link

Same here. Not sure how to fix that

@contefranz
Copy link

I can confirm that the bug is still there. I am using Atom 1.23.3 on High Sierra 10.13.3. It affects the dollars $, as well as single quote ', double quote ", two single quotes '' and the backtick `. It is getting frustrating now...any ideas on how to fix it?

@nicola-gigante
Copy link

nicola-gigante commented Feb 21, 2018

This bug is nearly a showstopper for the plugin and has been open for months. It's getting embarrassing on top of frustrating...

@af-ayala
Copy link

It is the same for Atom 1.24.0, I've tried reinstalling, however the problem is still there.. and it's been there since late 2017... really frustrating..

@findlayjy
Copy link

Still here in April, with Atom 1.25.0. Really frustrating!

@nicola-gigante
Copy link

Still here in May, with Atom 1.26. Is this plugin maintained at all? If authors do not care about fixing embarrassing bugs they could just flag the package as unmaintained or deprecated so we can move on.

@oaroldan
Copy link

oaroldan commented May 28, 2018

I found a workaround.

  • Go to: settings (mac:cmd+, Windows-Linux:Ctrl+,) > Open Config Folder (in the left panel)
  • open: packages/latextools/lib/snippet-manager.coffee

case 1: for the $-matcher, find and comment the code:

    if text =  te.getSelect edText()
      text = text.replace(/\\/g, "\\\\")
      range = te.getSelectedBufferRange()
      te.setSelectedBufferRange(range, '')
      @snippetService.insertSnippet("\$#{text}\$")
      return

replace it by:

    range = te.getSelectedBufferRange()
    text = te.getTextInBufferRange(range)
    text = text.replace(/\\/g, "\\\\")
    if text
      @snippetService.insertSnippet("\$#{text}\$")
      return

case 2: for the ' and "-matcher, find and comment the code:

    if text =  te.getSelectedText()
      text = text.replace(/\\/g, "\\\\")
      range = te.getSelectedBufferRange()
      te.setSelectedBufferRange(range, '')
      # Use snippet to leave selection on (same as ST)
      @snippetService.insertSnippet("#{left}${1:#{text}}#{right}")
      return

replace it by:

    range = te.getSelectedBufferRange()
    text = te.getTextInBufferRange(range)
    text = text.replace(/\\/g, "\\\\")
    if text
      @snippetService.insertSnippet("#{left}${1:#{text}}#{right}")
      return

Caveats

any update of the latextools package will delete your editings

@findlayjy
Copy link

What a hero! This is working for me, but I had issues with indenting to start with, so make sure it all matches up if you're having trouble.

Thank you, oaroldan! <3

@oaroldan
Copy link

@findlayjy Nice to know that it helped you! Thanks for let me know about the indenting issue (I updated my post to include this)

@contefranz
Copy link

contefranz commented May 29, 2018

@oaroldan Thank you so much! It worked for me too!
Shall we close the issue or leave it open hoping that someone fix this thing once and for all?

aplett98 pushed a commit to aplett98/atom-latextools that referenced this issue Feb 28, 2019
@aplett98 aplett98 linked a pull request Feb 28, 2019 that will close this issue
asinghvi17 added a commit to asinghvi17/atom-latextools that referenced this issue Nov 16, 2019
cortner pushed a commit to cortner/atom-latextools that referenced this issue Feb 10, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

8 participants