seongjaelee / nvatom

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

Uncaught TypeError in lunr.js #32

Closed 0thernet closed 8 years ago

0thernet commented 9 years ago

This errors pops up when searching regardless of whether "Enable Lunr Pipeline" is on.

Atom Version: 1.0.13 System: Mac OS X 10.10.5 Thrown From: nvatom package, v0.8.1

Stack Trace

Uncaught TypeError: Cannot read property 'tf' of undefined

At /Users/bg/.atom/packages/nvatom/node_modules/docquery/node_modules/lunr/lunr.js:1150

TypeError: Cannot read property 'tf' of undefined
    at [object Object].lunr.Index.documentVector (/Users/bg/.atom/packages/nvatom/node_modules/docquery/node_modules/lunr/lunr.js:1150:53)
    at [object Object].<anonymous> (/Users/bg/.atom/packages/nvatom/node_modules/docquery/node_modules/lunr/lunr.js:1122:61)
    at Array.map (native)
    at [object Object].lunr.SortedSet.map (/Users/bg/.atom/packages/nvatom/node_modules/docquery/node_modules/lunr/lunr.js:622:24)
    at [object Object].lunr.Index.search (/Users/bg/.atom/packages/nvatom/node_modules/docquery/node_modules/lunr/lunr.js:1121:6)
    at DocQuery.search (/Users/bg/.atom/packages/nvatom/node_modules/docquery/lib/DocQuery.js:119:31)
    at NotationalVelocityView.module.exports.NotationalVelocityView.filter (/Users/bg/.atom/packages/nvatom/lib/notational-velocity-view.coffee:66:22)
    at NotationalVelocityView.module.exports.NotationalVelocityView.populateList (/Users/bg/.atom/packages/nvatom/lib/notational-velocity-view.coffee:141:22)
    at /Applications/Atom.app/Contents/Resources/app.asar/node_modules/atom-space-pen-views/lib/select-list-view.js:350:26

Commands

     -0:01.0 nvatom:toggle (atom-text-editor.editor.is-focused.vim-mode.normal-mode)

Config

{
  "core": {
    "audioBeep": false,
    "projectHome": "/Users/bg/temp",
    "themes": [
      "one-dark-ui",
      "base16-tomorrow-dark-theme"
    ],
    "disabledPackages": [
      "minimap",
      "merge-conflicts",
      "git-blame"
    ]
  },
  "nvatom": {
    "directory": "/Users/bg/Notes",
    "enableLunrPipeline": false
  }
}

Installed Packages

# User
file-icons, v1.6.9
linter-rubocop, v0.3.4
nvatom, v0.8.1
pretty-json, v0.4.1
vim-mode, v0.60.0

# Dev
No dev packages
seongjaelee commented 9 years ago

This happens when we have an empty note undeleted (so if you want to avoid this problem right now, remove empty notes). Thanks for reporting it.

0thernet commented 9 years ago

looks like that worked, thanks!

seongjaelee commented 9 years ago

Ah that was a hack to avoid the bug. I'll reopen the issue and fix it in a right way. Thanks!

seongjaelee commented 9 years ago

When "Enable Lunr Pipeline" is off, and when the body is empty, the error occurs.

lunr.js.

  this._fields.forEach(function (field) {
    var fieldTokens = this.pipeline.run(lunr.tokenizer(doc[field.name]))
    console.log(fieldTokens); // when body is empty, it gives [""], not [].

    docTokens[field.name] = fieldTokens
    lunr.SortedSet.prototype.add.apply(allDocumentTokens, fieldTokens)
  }, this)
seongjaelee commented 9 years ago

https://github.com/olivernn/lunr.js/issues/178

seongjaelee commented 8 years ago

44 Duplicated.

seongjaelee commented 8 years ago

https://github.com/jonmagic/docquery/pull/9