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

autocomplete for log should be first console.log #49308

Closed
caub opened this issue May 6, 2018 · 11 comments
Closed

autocomplete for log should be first console.log #49308

caub opened this issue May 6, 2018 · 11 comments
Assignees
Labels
emmet Emmet related issues info-needed Issue requires more information from poster javascript JavaScript support issues

Comments

@caub
Copy link

caub commented May 6, 2018

I'm using Javascript React language mode by default, since I have jsx code anywhere in my .js files

I often need console.log but typing log then TAB always gives <log><log>, console.log comes in second position, which isn't handy.

since <log> isn't a valid HTML5 tag anyway, (and can't be a component since lower-cased, not even a web-component, is it possible to remove it? I tried to customize this, but didn't find a way

With Javascript language mode, it's fine of course, but as I said, I need Javascript React

  • VSCode Version: 1.22.2
  • OS Version: Lubuntu 18.04

Does this issue occur when all extensions are disabled?: Yes

@vscodebot vscodebot bot assigned mjbvz May 6, 2018
@vscodebot vscodebot bot added the javascript JavaScript support issues label May 6, 2018
@mjbvz mjbvz added the emmet Emmet related issues label May 7, 2018
@mjbvz
Copy link
Contributor

mjbvz commented May 7, 2018

This suggestion comes from emmet. You can set "editor.snippetSuggestions": "top" to force the log snippet to the top of the list, or disable emmet in javascript react files by setting: "emmet.excludeLanguages": ["javascriptreact"]

Adding @ramya-rao-a to see if there's anything we should tweak about when emmet completions show up

@caub
Copy link
Author

caub commented May 7, 2018

@mjbvz Thanks

Talking about Emmet, I'll keep it for tags autocompletion, something else I'd like is that suggestions work both from, for example, div and <div (as I tend to put the < by reflex, sublime text works that way also)

@ramya-rao-a
Copy link
Contributor

I often need console.log but typing log then TAB always gives , console.log comes in second position, which isn't handy.

When I type log in an empty .js file, the first item in the suggestion list is for the console.log snippet

image

I get the same result even after changing the mode to javascriptreact

Can you share a screen shot where <log></log> from emmet is the first item in the suggestion list and console.log snippet is the second? Also include any emmet related settings you have added.

I am using VS Code version 1.23

@ramya-rao-a ramya-rao-a added the info-needed Issue requires more information from poster label May 7, 2018
@caub
Copy link
Author

caub commented May 8, 2018

@ramya-rao-a Thanks, I should have made the captures first sorry

First how it was initially:
peek 2018-05-08 08-54
Indeed, like you say, console.log comes first, but then, in between lines, the emmet <log> will come as you can see

Second, I put "editor.snippetSuggestions": "top" like @mjbvz suggested, then it works in a convenient way for me:
peek 2018-05-08 09-00

Full settings:

{
	"explorer.openEditors.visible": 0,
	"editor.tabSize": 2,
	"editor.wordWrap": "on",
	"editor.formatOnSave": true,
	// "eslint.autoFixOnSave": true,
	"javascript.format.insertSpaceAfterOpeningAndBeforeClosingNonemptyBraces": false,
	"[javascript]": {
		"editor.formatOnSave": true
	},
	"[json]": {
		// "editor.formatOnSave": true
	},
	"[typescript]": {
		"editor.formatOnSave": true
	},
	"files.associations": {
		"*.js": "javascriptreact"
	},
	"editor.snippetSuggestions": "top",
	"prettier.singleQuote": true,
	"prettier.trailingComma": "all",
	"prettier.printWidth": 110,
	"prettier.requireConfig": true,
	"prettier.ignorePath": "/home/caub/.prettierignore",
	"code-runner.saveAllFilesBeforeRun": true,
	"code-runner.runInTerminal": false,
	"code-runner.clearPreviousOutput": true,
	"code-runner.defaultLanguage": "shellscript",
	"code-runner.enableAppInsights": false,
	"code-runner.showExecutionMessage": true,
	"code-runner.executorMap": {
		"sql": "psql postgres://postgres:pg@localhost:5432/postgres -f",
		"bash": "bash",
		"javascript": "node",
		"javascriptreact": "babel-node --presets ~/.npm-global/lib/node_modules/@babel/preset-env",
	},
	"launch": {
		"version": "0.2.0",
		"configurations": [
			{
				"type": "node",
				"request": "launch",
				"name": "Launch Program",
				"program": "${file}"
				// "cwd": "${workspaceFolder}"
			}
		]
	},
	"editor.multiCursorModifier": "ctrlCmd",
	"docker.showExplorer": false,
	"emmet.triggerExpansionOnTab": true,
	"emmet.syntaxProfiles": {
		"javascript": "jsx"
	},
	"workbench.startupEditor": "newUntitledFile",
	"files.exclude": {
		"**/.git": true,
		"**/.svn": true,
		"**/.hg": true,
		"**/.DS_Store": true,
		"**/package-lock.json": true,
		"**/yarn.lock": true,
		"**/.nyc_output": true,
		"**/coverage": true,
		"**/node_modules": true
	},
	"files.autoSave": "off",
	"git.ignoreLimitWarning": true,
	"explorer.confirmDragAndDrop": false,
	"window.zoomLevel": 0,
	"explorer.confirmDelete": false,
	"search.exclude": {
		"**/node_modules": true,
		"**/node_modules/**": true,
		"**/bower_components": true,
		"**/build": true,
		"**/dist": true
	},
	"extensions.ignoreRecommendations": false,
	"files.watcherExclude": {
		"**/.git/objects/**": true,
		"**/.git/subtree-cache/**": true,
		"**/node_modules/**": true,
		"**/node_modules": true,
		"**/dist": true,
		"**/build": true
	},
	"window.newWindowDimensions": "inherit"
}

@ramya-rao-a
Copy link
Contributor

@mjbvz In the below screenshot, do you know from where is the first entry coming? The second is a snippet.

screen shot 2018-05-08 at 8 36 22 pm

@caub So the <log></log> is being added only after you hit tab once you are out of the auto-completion mode. This is because of the emmet.triggerExpansionOnTab setting that you have enabled. This makes the tab key trigger emmet. As far as emmet is concerned, any word is a valid abbreviation and so gets expanded to html tags.

You mentioned that lowercase words are not valid react component or web component. Is there any documentation you can point us to that says the same?

@caub
Copy link
Author

caub commented May 9, 2018

@ramya-rao-a Thanks, sure:

Yes, I was using tab for completion, because that's how I like to trigger it. I'm not so familiar with the concept of emmet, even if I tried to learn it. I'd prefer like I said previously, a way to distinguish clearly JSX/HTML completion, by just putting the opening <

example I type:

<foo

then the key for completion (TAB) here, will propose to complete it to <foo>|</foo>

This would really great for me, honestly

Thanks again much for this wonderful editor and your efforts

@ramya-rao-a
Copy link
Contributor

Yes, I was using tab for completion, because that's how I like to trigger it.

Its common to use tab for selecting an item from the auto-completion list, not to trigger the completion itself.

I'm not so familiar with the concept of emmet

In this case, I would suggest to remove the setting emmet.triggerExpansionOnTab

I'd prefer like I said previously, a way to distinguish clearly JSX/HTML completion, by just putting the opening <

Emmet abbreviations don't work that way. For emmet in general see https://emmet.io.

For your purpose, I would suggest the extension auto close tag

@caub
Copy link
Author

caub commented May 10, 2018

Thanks, I wish this feature was handled in vscode core, because this extension, after 1 day of intense usage, has some issues, and made vscode process overclock a CPU. I couldn't reproduce those issues deterministically though, when I will, I'll report along with the many other pending issues, and probably try to help

closing. I still wish a more reliable way for tags autocomplete/close in the future

@caub caub closed this as completed May 10, 2018
@ramya-rao-a
Copy link
Contributor

@caub In html files we do have the autocomplete the close tag feature coming from the core.
@mjbvz Do you want to consider supporting the same for tags in jsx?

@caub
Copy link
Author

caub commented May 10, 2018

Thanks, that would be great, the difficulty can come with typescript generics for example, but it's surely possible to distinguish them with context

@caub
Copy link
Author

caub commented May 19, 2018

I'm trying to fix auto-close-tag extension: formulahendry/vscode-auto-close-tag#86

But it's quite nasty to use regexes there, vscode core has surely an AST, and could do this pretty easily

cc: @formulahendry

@vscodebot vscodebot bot locked and limited conversation to collaborators Jun 24, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
emmet Emmet related issues info-needed Issue requires more information from poster javascript JavaScript support issues
Projects
None yet
Development

No branches or pull requests

3 participants