Skip to content
This repository has been archived by the owner on Sep 6, 2021. It is now read-only.

CSS code hints improvements #6242

Merged
merged 5 commits into from
Dec 20, 2013
Merged

CSS code hints improvements #6242

merged 5 commits into from
Dec 20, 2013

Conversation

YuAo
Copy link
Contributor

@YuAo YuAo commented Dec 13, 2013

Select the initial hint on backspace key press

Problem: When you input "col", the code hint plugin will present hints like "color","column-count",etc, with the initial item "color" selected. But, after you press backspace key once, nothing is selected on the hints list.

This patch set the selectInitial = true on implicitChar === null, making the first hint selected on backspace key press.

Clear hints when nothing's left

Problem: When you input "co", then press backspace twice to delete the CSS property, the code hints list remains open with hints like "align-content","align-items",etc.

This patch fixed the problem by returning null for the hints list when this.info.offset === 0.

@ghost ghost assigned redmunds Dec 17, 2013
if (this.info.offset === 0) {
return null;
}

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@YuAo I saw your pull request, but I misread it and thought it was a bug report. Good catch!

So I fixed this in this commit while I was fixing #6231 . Note that I moved this code a bit in pull request #6258, so your change will have to be merged. I backed out my change for this fix after I noticed that this was actually a pull request :)

The gist of my fix is to also select initial item if any code has been typed (i.e. needle !== ""):

            if (this.primaryTriggerKeys.indexOf(implicitChar) !== -1 ||
                    needle !== "") {
                 selectInitial = true;
            }

But, this fix is not quite right because it prevents Ctrl+space from invoking css property hints when nothing has been typed.

Let me know if you'd like to continue with this, or if I should just fix it.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@redmunds Oh, I didn't notice that. Because my Ctrl+Space is occupied by the input method switch.

I don't think that a code hint is helpful when nothing has been typed. It's better to having no code hint than having a not so useful code hint list floating around.

However, I think we can still fix this by checking the lastContext.

If lastContext is not null, we know that the user has previously typed something and have some hints. So we can get ride of the hint list this time.

If lastContext is null, we know that the user didn't get any hints the last time. We can now show him some hints anyway, if he requires (i.e. pressed Ctrl+Space).

I've added a commit.

@redmunds
Copy link
Contributor

@YuAo My pull request #6270 that was merged last night conflicts with your code. Sorry about that. You'll have to merge with the latest master before I can review your latest changes. Let me know if you have any questions about the code change.

Conflicts:
	src/extensions/default/CSSCodeHints/main.js

"Select the initial hint on backspace key press" has been done by @redmunds on master, fixed conflicts
@YuAo
Copy link
Contributor Author

YuAo commented Dec 20, 2013

@redmunds That's all right. All fixed now.

@redmunds
Copy link
Contributor

Thanks. Nice fix. Merging.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants