seongjaelee / nvatom

nvatom (unpublished from atom.io)
MIT License
75 stars 14 forks source link

Uncaught SyntaxError: Invalid regular expression: /^sloterdijk, P. (2$/: Unterminated group #28

Closed zettler closed 9 years ago

zettler commented 9 years ago

[Enter steps to reproduce below:]

  1. ...
  2. ...

Atom Version: 1.0.11 System: KFK Thrown From: nvatom package, v0.8.0

Stack Trace

Uncaught SyntaxError: Invalid regular expression: /^sloterdijk, P. (2$/: Unterminated group

At /C:/Users/Franz/.atom/packages/nvatom/lib/notational-velocity-view.coffee:85

SyntaxError: Invalid regular expression: /^sloterdijk, P. (2$/: Unterminated group
  at new RegExp (native)
  at RegExp (native)
  at NotationalVelocityView.module.exports.NotationalVelocityView.selectItem (C:\Users\Franz\.atom\packages\nvatom\lib\notational-velocity-view.coffee:45:30)
  at NotationalVelocityView.module.exports.NotationalVelocityView.populateList (C:\Users\Franz\.atom\packages\nvatom\lib\notational-velocity-view.coffee:153:8)
  at C:\Users\Franz\AppData\Local\atom\app-1.0.11\resources\app.asar\node_modules\atom-space-pen-views\lib\select-list-view.js:350:26

Commands

     -1:06.1.0 core:paste (atom-text-editor#nvatom.directory.editor.mini.is-focused)
     -0:51 application:new-file (ul.list-inline.tab-bar.inset-panel)
     -0:49.1.0 command-palette:toggle (atom-text-editor.editor.is-focused)
     -0:46.9.0 core:confirm (atom-text-editor.editor.mini.is-focused)
     -0:46.9.0 nvatom:toggle (atom-text-editor.editor)
  3x -0:41.6.0 core:backspace (atom-text-editor.editor.mini.is-focused)
     -0:40.3.0 core:select-all (atom-text-editor.editor.mini.is-focused)
  3x -0:37.4.0 core:backspace (atom-text-editor.editor.mini.is-focused)
     -0:34.7.0 core:select-all (atom-text-editor.editor.mini.is-focused)
     -0:34.1.0 core:backspace (atom-text-editor.editor.mini.is-focused)
     -0:31.5.0 core:select-all (atom-text-editor.editor.mini.is-focused)
 24x -0:29.7.0 core:backspace (atom-text-editor.editor.mini.is-focused)
     -0:16.3.0 core:select-all (atom-text-editor.editor.mini.is-focused)
  3x -0:14.6.0 core:backspace (atom-text-editor.editor.mini.is-focused)
     -0:12.2.0 core:select-all (atom-text-editor.editor.mini.is-focused)
 16x -0:07.9.0 core:backspace (atom-text-editor.editor.mini.is-focused)

Config

{
  "core": {
    "themes": [
      "atom-light-ui",
      "one-light-syntax"
    ],
    "disabledPackages": [
      "notational-windows",
      "notational-velocity"
    ],
    "excludeVcsIgnoredPaths": false
  },
  "nvatom": {
    "directory": "C:/Users/Franz/OneDrive/Dokumente/THS/Resoph",
    "extensions": [
      ".txt"
    ]
  }
}

Installed Packages

# User
default-encoding, v0.8.0
event-watch, v3.7.11
file-watcher, v0.3.1
html-entities, v0.4.0
linter-tidy, v1.0.1
nvatom, v0.8.0
planner, v0.3.2
revert-buffer, v0.5.0
save-session, v0.15.7
stopwatch, v0.3.0

# Dev
No dev packages
zettler commented 9 years ago

While typing into the nvatom search field, sometimes the package seems to autocomplete words while typing. When I press backspace to delete the letters added, it doesn't work, only more letters get added. This does occur with some words (Slo / ka ... and others, not all).

seongjaelee commented 9 years ago

Invalid regular expression

Regular expression-related exception is fixed in v0.8.1.

While typing into the nvatom search field, sometimes the package seems to autocomplete words while typing.

Autocompleting search query is a feature. It should autocomplete the query if there is a title that starts with the given query. If you want to ignore that, you can just continue typing. For example, let's say that you have a document name "dragon.md", and if want to type "dragging" on the query window. If you typed "dra", then it will autocomplete to "dra[gon]". At this point, the cursor is between 'a' and 'g', with "gon" highlighted, so if you type 'g', then the query will be back to "drag".

This autocomplete may happen sparsingly due to lunr pipeline. You can fully enable this autocomplete if you check "Enable lunr pipeline" option in the nvatom settings. (Even though it seems like you are not a fan of this autocomplete feature...)

When I press backspace to delete the letters added, it doesn't work, only more letters get added.

However, this behavior is never expected, and I have no idea how this can happen. Could you update nvatom and let me know if this behavior keeps happening?

zettler commented 9 years ago

Hi, the autocomplete problem persists. With your example: When I want to type dragging, e.g., I can't, as soon as I type dra (not pressing Enter or anything), "gon" is added automatically - I don't have the choice not to type it, so to speak. I recorded a screencast with audio, so you can hear me pressing my keys - I type "Sl" and it autocompletes to Sloterdijk without letting me a choice, pressing backspace doesn't help, it just completes even more of the proposed word. This is not true for all words however, for example, Leviathan and many others work, but e.g. Sloterdijk and "kann" (a frequent German word) don't. For all of the sample words, I have several notes containing them, so I don't know what makes the difference.

http://screencast-o-matic.com/watch/coQblbfKYv

seongjaelee commented 9 years ago

Thanks very much for the recording. It really helped me to understand the symptom.

I think the problem is caused from here. https://github.com/seongjaelee/nvatom/blob/master/lib/notational-velocity-view.coffee#L57

So it fills the title and then highlights the string from the end to the current cursor position, moving the cursor position back to the current position. Computing the lengths has some problem on either 1) very very long title or 2) non-alphabets. I'll be investigating more on this. If you have more clue on this, please let me know.

If it really bothers you (until I fix it), you can just make the function selectItem to do nothing.

seongjaelee commented 9 years ago

Since this autocomplete issue is separate from regular expression error, I'll create a separate issue #29. I'll close this issue when #29 is resolved, since @zettler is following this thread.

zettler commented 9 years ago

Hi, I've done a few more tests, and

Keeping the backspace pressed allows re-editing what was typed and completed, but automatic re-adding occurs from time to time, it's sort of uncontrollable and difficult to handle.

seongjaelee commented 9 years ago

I cannot reproduce the result from my local machine. Could you let me the problematic note's title? I suspect there might be some problem computing the string length for some unicode characters.

I tried this, but I couldn't reproduce your problem. "sloterdijk, P. (2014). Die schrecklichen Kinder der Neuzeit: Über das anti-genealogische Experiment der Moderne (suhrkamp taschenbuch)"

zettler commented 9 years ago

It's "Sloterdijk, P. (2014). Die schrecklichen Kinder der Neuzeit. Über das anti-genealogische Experiment der Moderne (2nd ed.). Berlin%3A Suhrkamp.%3A Aus Geschichte lernen - Grund zum Optimismus%3F.txt"

seongjaelee commented 9 years ago

Hmm, I still cannot reproduce the result from my local machine (OSX).

This is not true for all words however, for example, Leviathan and many others work, but e.g. Sloterdijk and "kann" (a frequent German word) don't. For all of the sample words, I have several notes containing them, so I don't know what makes the difference.

  • Could you give me more filenames?
  • What OS are you using?

You can further help me by debugging the code by yourself. Go to .atom/packages/nvatom/lib/notational-velocity-view.coffee, and add a line to make

        editor.setText(filterQuery + item.title.slice(filterQuery.length))
        editor.selectLeft(item.title.length - filterQuery.length)

to the following:

        editor.setText(filterQuery + item.title.slice(filterQuery.length))
        editor.selectLeft(item.title.length - filterQuery.length)
        atom.notifications.addInfo("#{item.title.length}, #{filterQuery.length}, #{filterQuery}")

And then restart Atom, and use nvatom as before. You will see some texts infobox whenever it does autocomplete. Giving me the number would futher help debugging.

zettler commented 9 years ago

OS: Windows 10.

When typing sl, it autocompletes [no choice] to sloter+rest[optional], further typing/pressing backspace leads to:

When typing „je“ => autocompletes to „jesu[white, no choice] and then in blue [optional] the rest of the title.

Title of the note:

„Jesus%3A Wer Vater oder Mutter mehr qqq liebt, der ist mein nicht wert; und wer Sohn oder Tochter mehr liebt denn mich, der ist mein nicht wert. qqq.txt"

Typing „al“ => all [no choice] ]+rest[optional]

Title: „Alles was zum Wohl der Heimat beitragen kann, qqqist wesentlich an mein Glueck gebundenqqq.txt

Typing tou

autocompletes tou => tourn[no choice]+rest[optional]

“tourner en dérision; dans une autre colonne l'accusation selon laquelle ceux qui seraient contre la guerre en Irak seraient antiaméricains est tournées en dérision.txt”

Can I disable autocomplete but keep auto-selection of the note being the best current search result? In what way would I have to change the code?

zettler commented 9 years ago

I re-installed Atom and all packages twice, at first without deleting the temporary files in AppData, the error was reproducable, then with deleting the temporary files. Now everything works like a charm.

Unfortunately it seems like I can't do any further testing now to find out what exactly produced the error, but the most important thing is that it works :) .

seongjaelee commented 9 years ago
  1. First of all, it's good that it is fixed so that you can use it.
  2. I should have introduced a local fix so that you can use it at the first time I saw this issue.
  3. It is VERY odd that #{item.title.length} is changing.

Since we cannot reproduce it, I'll close this issue. If it comes up, please let me know so that I can fix it. Thanks very much for giving detailed examples.