atom-autocomplete-modules icon indicating copy to clipboard operation
atom-autocomplete-modules copied to clipboard

Uncaught TypeError: Cannot read property 'substring' of undefined

Open dead-claudia opened this issue 5 years ago • 3 comments

[Enter steps to reproduce:]

  1. Open up a new, unsaved file in an active, non-empty repo (it need not be persisted)
  2. Type in const foo = require("../mod")
  3. Start to change foo to {bar}

Atom: 1.32.2 x64 Electron: 2.0.9 OS: Mac OS X 10.13.6 Thrown From: autocomplete-modules package 2.2.5

Stack Trace

Uncaught TypeError: Cannot read property 'substring' of undefined

At /Users/isiahmeadows/.atom/packages/autocomplete-modules/lib/lookups/export/local.js:17

TypeError: Cannot read property 'substring' of undefined
    at LocalLookup.getList (/packages/autocomplete-modules/lib/lookups/export/local.js:17:27)
    at relevantLookups.reduce (/packages/autocomplete-modules/lib/lookups/index.js:25:16)
    at Array.reduce (<anonymous>)
    at LookupApi.filterList (/packages/autocomplete-modules/lib/lookups/index.js:23:28)
    at CompletionProvider.getSuggestions (/packages/autocomplete-modules/lib/completion-provider.js:64:34)
    at n.forEach.t (/Applications/Atom.app/Contents/Resources/app/static/<embedded>:11:644623)
    at Array.forEach (<anonymous>)
    at AutocompleteManager.getSuggestionsFromProviders (/Applications/Atom.app/Contents/Resources/app/static/<embedded>:11:644139)
    at AutocompleteManager.findSuggestions (/Applications/Atom.app/Contents/Resources/app/static/<embedded>:11:643877)
    at AutocompleteManager.requestNewSuggestions (/Applications/Atom.app/Contents/Resources/app/static/<embedded>:11:652407)
    at AutocompleteManager.showOrHideSuggestionListForBufferChanges (/Applications/Atom.app/Contents/Resources/app/static/<embedded>:11:653498)
    at Function.simpleDispatch (/Applications/Atom.app/Contents/Resources/app/static/<embedded>:11:1186984)
    at Emitter.emit (/Applications/Atom.app/Contents/Resources/app/static/<embedded>:11:1188425)
    at TextBuffer.emitDidChangeTextEvent (/Applications/Atom.app/Contents/Resources/app/static/<embedded>:11:501342)
    at TextBuffer.transact (/Applications/Atom.app/Contents/Resources/app/static/<embedded>:11:489600)
    at TextEditor.transact (/Applications/Atom.app/Contents/Resources/app/static/<embedded>:11:24215)
    at mergeIntersectingSelections (/Applications/Atom.app/Contents/Resources/app/static/<embedded>:11:16150)
    at TextEditor.mergeSelections (/Applications/Atom.app/Contents/Resources/app/static/<embedded>:11:39529)
    at TextEditor.mergeIntersectingSelections (/Applications/Atom.app/Contents/Resources/app/static/<embedded>:11:39038)
    at TextEditor.mutateSelectedText (/Applications/Atom.app/Contents/Resources/app/static/<embedded>:11:16113)
    at TextEditor.insertText (/Applications/Atom.app/Contents/Resources/app/static/<embedded>:11:15662)
    at TextEditor.e.(anonymous function) [as insertText] (/Applications/Atom.app/Contents/Resources/app/static/<embedded>:11:256932)
    at TextEditorComponent.didTextInput (/Applications/Atom.app/Contents/Resources/app/static/<embedded>:11:93579)

Commands

     -0:17.5.0 core:close (atom-pane.pane)
     -0:14.1.0 find-and-replace:select-next (input.hidden-input)
  2x -0:07.3.0 core:undo (input.hidden-input)

Non-Core Packages

atom-beautify 0.33.4 
atom-typescript 12.6.3 
auto-detect-indentation 1.3.0 
autocomplete-modules 2.2.5 
autocomplete-paths 2.12.2 
autocomplete-racer 0.1.3 
build 0.70.0 
build-cargo 2.0.0 
busy-signal 1.4.3 
color-picker 2.3.0 
docblockr 0.13.7 
emmet 2.4.3 
eval-javascript 1.2.0 
figlet 0.5.4 
file-icons 2.1.26 
git-plus 8.1.0 
intentions 1.1.5 
language-babel 2.85.0 
language-batch 0.4.0 
language-haskell 1.17.8 
language-kotlin 0.5.0 
language-livescript 0.0.3 
language-ocaml 1.9.5 
language-pegjs 0.5.0 
language-pug 0.0.22 
language-rust 0.4.12 
language-scala 1.1.9 
language-stylus 0.2.0 
language-webassembly 1.0.1 
language-x86-64-assembly 2.2.11 
linter 2.2.0 
linter-eslint 8.4.1 
linter-tslint 1.9.1 
linter-ui-default 1.7.1 
minimap 4.29.9 
minimap-cursorline 0.2.0 
minimap-git-diff 4.3.1 
minimap-linter 2.2.1 
prettier-atom 0.55.2 
project-manager 3.3.6 
sort-lines 0.18.0 
sync-settings 0.8.6 

dead-claudia avatar Nov 12 '18 09:11 dead-claudia

Hi. You mentioned it's an unsaved file. Atom can't infer where the relative path is from the file as it's still in memory and not in an exact location.

What should be considered is a safe way for it to have its exception caught.

jonyeezs avatar Nov 12 '18 11:11 jonyeezs

I get that. It still should at least tolerate an in-memory file, though.

IMHO, I feel it should just not attempt to resolve non-native modules (or at least non-global modules) if it hasn't been saved yet. fs is okay, but it shouldn't offer completions for ../lib/foo, for example. You could go either way with something like lodash, however.

dead-claudia avatar Nov 13 '18 01:11 dead-claudia

yes. I agree. Will need to manage that.

On Tue., 13 Nov. 2018, 11:11 am Isiah Meadows, [email protected] wrote:

I get that. It still should at least tolerate an in-memory file, though.

IMHO, I feel it should just not attempt to resolve non-native modules (or at least non-global modules) if it hasn't been saved yet. fs is okay, but it shouldn't offer completions for ../lib/foo, for example. You could go either way with something like lodash, however.

— You are receiving this because you commented.

Reply to this email directly, view it on GitHub https://github.com/nkt/atom-autocomplete-modules/issues/125#issuecomment-438088955, or mute the thread https://github.com/notifications/unsubscribe-auth/AKXAhrzuIn2j1LlLC4ZKc_iGglvFOgmiks5uuhqzgaJpZM4YZOfm .

jonyeezs avatar Nov 13 '18 01:11 jonyeezs