Skip to content
This repository has been archived by the owner on Jun 1, 2023. It is now read-only.

Issues with completion on some files #85

Closed
faustinoaq opened this issue Apr 9, 2018 · 15 comments
Closed

Issues with completion on some files #85

faustinoaq opened this issue Apr 9, 2018 · 15 comments

Comments

@faustinoaq
Copy link
Member

faustinoaq commented Apr 9, 2018

@laginha87 I knew I had some issues with auto-completion feature and I have found them, sometimes the completion is broken in projects with sub directories. And keep working only in the main project file.

In the example below, I tried scry master and tested completion on all files, (baz.cr, bar.cr and foo.cr) and no one works but only console.cr. No matter where I put them, completion just work on one file, the main file console.cr for the project console

vokoscreen-2018-04-09_15-39-07

Full logs here: https://gist.github.com/faustinoaq/65b39e810dc1e4a6a3456bb0286d48e6

@faustinoaq faustinoaq added this to To do in Crystal Tools via automation Apr 9, 2018
@faustinoaq
Copy link
Member Author

BTW, There's no errors in that project and also I reloaded VSCode before trying to use auto-completion

@faustinoaq
Copy link
Member Author

Also, if you see the logs, scry is logging something like: Couldn't find type ..., Why? 😅

@laginha87
Copy link
Contributor

hmm that is weird, I'll look into it.
The couldn't find type is thrown when it can't find the type in the dependencies of the file you're on.

@faustinoaq
Copy link
Member Author

So, looks like some of my files are not being included in the auto-completion database because some strange reason 😅

@faustinoaq
Copy link
Member Author

screenshot_20180410_102641

@laginha87 I checked the logs and the file file:///home/main/Projects/console/src/console/baz.cr was included successfully in the dependency graph, although completion doesn't work in that file as you can see in my gif.

@faustinoaq
Copy link
Member Author

Seems there is something wrong with these lines:

graph.each.reject { |e| e == prelude_node.not_nil!.value }.each do |key, _|
graph[key].connections << prelude_node.not_nil!
end

@faustinoaq
Copy link
Member Author

@laginha87 Can you reproduce this issue? 😅

@faustinoaq
Copy link
Member Author

I did some test, this bugs seems to be related to the require system and sub directory structure of the project, (maybe names mismatch).

If a try a new clean crystal project crystal init app bar, then auto-completion only works on src/bar.cr:

screenshot_20180410_183804

but not on src/bar/version.cr

screenshot_20180410_183829

Surprisingly If a try an amber project, auto-completion feature work without problems in all files: (even in files outside src folder)

screenshot_20180410_183943

screenshot_20180410_184006

screenshot_20180410_184602

So, I really don't know what is happening here 😅 I think we need to review this code:

@lookup_paths
.map { |e| File.join(File.expand_path(e), "**", "*.cr") }
.uniq
.flat_map { |d| Dir.glob(d) }
.each { |file| process_requires(file, graph) }
prelude_node = graph[/src\/prelude.cr$/]
Log.logger.debug("Finished building the dependancy graph got these nodes:#{graph.each.to_a.map(&.first)}")
return graph if prelude_node.nil?
graph.each.reject { |e| e == prelude_node.not_nil!.value }.each do |key, _|
graph[key].connections << prelude_node.not_nil!
end

@faustinoaq
Copy link
Member Author

Surprisingly If a try an amber project, auto-completion feature work without problems in all files

I checked again and seems in some files auto-completion doesn't work:

screenshot_20180410_185654

@faustinoaq
Copy link
Member Author

faustinoaq commented Apr 11, 2018

@laginha87 here are the scry logs for crystal init app bar

auto-completion inside src/bar/version.cr doesn't work

screenshot_20180410_183829

Sorry for so many comments and Thank you for your help! 😅 👍

@laginha87
Copy link
Contributor

No worries, sorry I haven't had time to look at these yet.

@faustinoaq
Copy link
Member Author

Hi @laginha87 I guess I fixed something in #92

Std lib Completion for all crystal files is working now, even in untitled files 🎉

screenshot_20180423_103742
screenshot_20180423_103945

@faustinoaq
Copy link
Member Author

Wow, I think #92 fixes this definitely, see my comment: #92 (comment)

@laginha87
Copy link
Contributor

It's very odd, cause in that case reload would have fixed issue (temporarily at least)

@faustinoaq
Copy link
Member Author

@laginha87 maybe this issue was caused by #59 and #91, so when the Missing hash key was fixed in #92 then this issue got fixed as well.

@bcardiff bcardiff closed this as completed Jun 1, 2023
Crystal Tools automation moved this from To do to Done Jun 1, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
Crystal Tools
  
Done
Development

No branches or pull requests

3 participants