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
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion src/extensions/default/CSSCodeHints/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,10 @@ define(function (require, exports, module) {
// Clear the exclusion if the user moves the cursor with left/right arrow key.
this.updateExclusion(true);

if (this.info.offset === 0 && lastContext !== null) {
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.

if (context === CSSUtils.PROP_VALUE) {

// Always select initial value
Expand Down Expand Up @@ -262,7 +266,7 @@ define(function (require, exports, module) {
} else if (context === CSSUtils.PROP_NAME) {

// Select initial property if anything has been typed
if (this.primaryTriggerKeys.indexOf(implicitChar) !== -1) {
if (this.primaryTriggerKeys.indexOf(implicitChar) !== -1 || needle !== "") {
selectInitial = true;
}

Expand Down