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

Fixing multiple issues in CSS code hints extension (in getHints and insertHint APIs) #2686

Merged
merged 3 commits into from
Jan 29, 2013

Conversation

RaymondLim
Copy link
Contributor

This fixes issue #2626, #2628 and #2682.

@kjgorman
Copy link
Contributor

Should this situation: |font-size: 14px (where | is the cursor) insert rather than replace, as you aren't yet 'within' the token?
example
Not sure if you can see that well, but I would expect an insert in this case? Maybe L155 should check || this.info.offset === 0 also?

@RaymondLim
Copy link
Contributor Author

@kjgorman Thanks for reviewing and posting question!

Our code hints implementation considers the cursor position before the first and after the last as part of the current string (ie. inclusive). You can see this behavior in the way Tag hints and attribute hints works in Brackets. So we're replacing here for CSS hints as well. Otherwise, we will have to auto append a whitespace, which I think is a bad design.

@kjgorman
Copy link
Contributor

Ah I see, what I was looking at was |<html (which doesn't allow forcing the hint popup with C^space) when <|html does so I wasn't certain if the < is considered part of the current token (and I guess it does make sense for it not to be). HTML attributes are more obviously analogous to CSS properties in a text layout sense so I probably should have looked at them first!

@ghost ghost assigned dangoor Jan 28, 2013
keepHints = true;
end.ch = start.ch;
} else {
// It's a replacement of an existing one or just typed in properety.
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: typo: should be "property"

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Nice catch!

@dangoor
Copy link
Contributor

dangoor commented Jan 28, 2013

The changes look good overall, and this was a good chance for me to dig in and learn a bit about this part of the code.

It would be nice to also see unit tests for the changes to the behavior here.

@RaymondLim
Copy link
Contributor Author

Changes for review feedback are pushed. Ready for re-review.

if (TokenUtils.moveSkippingWhitespace(TokenUtils.moveNextToken, ctx) && ctx.token.string === ":") {
adjustCursor = true;
newCursor = cursor;
newCursor.ch = cursor.ch + (hint.length - this.info.name.length);
Copy link
Contributor

Choose a reason for hiding this comment

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

This isn't copying cursor into newCursor (after this line of code, newCursor.ch === cursor.ch) and I'd be worried about some bit of code being added later on below that uses cursor after it has been modified.

You could eliminate newCursor and make it obvious that you are modifying cursor here, or you could make newCursor a true copy of cursor (newCursor = {line: cursor.line, ch: cursor.ch};)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed.

@dangoor
Copy link
Contributor

dangoor commented Jan 29, 2013

Sorry if you got some email churn... I put my comments in the wrong place (on the commit rather than the changed files...)

The new behavior looks good!

@RaymondLim
Copy link
Contributor Author

Ready for another review.

@dangoor
Copy link
Contributor

dangoor commented Jan 29, 2013

Looks good to me. Merging.

dangoor added a commit that referenced this pull request Jan 29, 2013
Fixing multiple issues in CSS code hints extension (in getHints and insertHint APIs)
@dangoor dangoor merged commit 51005dd into master Jan 29, 2013
@dangoor dangoor deleted the rlim/css-hint-issues branch January 29, 2013 17:51
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.

3 participants