[Initial review] Update rule label when selector is edited#5541
[Initial review] Update rule label when selector is edited#5541
Conversation
…t doesn't fire if boundaries don't actually change.
|
@peterflynn - might want to do a drive-by on df1d141 |
|
One thing that's a little skeezy about this is that the way we update the selector when you make an edit is different from how we collect the selectors originally. This is mainly because of the mismatch between what |
|
Hmmm...thinking about this again, I suppose this is a little more skeezy than I thought. For example, there could be a comment between the selector list and the beginning of the rule, and we would end up sucking that in. Doesn't seem super-likely, but it could happen... It also occurs to me that another edge case would be if you had multiple rules on the same line--since TextRange only tracks line numbers, not offsets within a line, we would grab the first selector on the line even if the rule were later on the same line. Again, doesn't seem super-likely (aside from minified files, which would be a mess in an inline editor anyway)...but adding that level of tracking to TextRange is definitely more work (though perhaps not terrible). Comments welcome... |
|
The code all looks fine for what I does. It would be good, I think, if the mechanism used for getting the updated selector was the same. I tried out the edge cases you pointed out, and they are a bit ugly. That said, these are edge cases and I don't know how likely it is that someone would hit them in real life. Do people really put multiple rules on the same line in source files? If it was quick and easy to change this, then I think we're better off fixing these edge cases now. If not, I think we should wait and see if anyone complains because it's entirely possible that we'd never hear a complaint about this. |
|
I think the only case for multiple lines on the same file is in a minified file. Other than that, I've never seen it. It seems like there are basically two separate things we would want to fix: (1) Use the real tokenizer to get the updated selector. I just realized that I could probably use |
|
That sounds like a good plan. |
|
@dangoor - I pushed up the change to make |
|
Looks good. Merging. |
[Initial review] Update rule label when selector is edited
@dangoor - note that this is branched off the
css-quick-edit-new-selectorbranch from #5532 (I didn't want to disturb your review there). The commits in this one (607b35d, df1d141, 73e7414) are semantic so can be reviewed individually.