hax / refactor

Refactoring support in Atom.
https://atom.io/packages/refactor
MIT License
36 stars 8 forks source link

Can we have a different color for read and write occurrences? #18

Closed Redsandro closed 8 years ago

Redsandro commented 8 years ago

The highlighting is very convenient, even if you don't want to refactor. I was wondering if it's possible to have a different highlight style for read (e.g. green) and write (e.g. red) occurrences?

hax commented 8 years ago

The new version has implemented this idea. Note: it need language packages give the information of references. Up to now only latest js-refactor support this.

Redsandro commented 8 years ago

@hax I would like to have a read and write occurance highlight, not just an underline. This makes it quicker to spot. Is there a way I can configure this?

hax commented 8 years ago

@Redsandro You can customize it in your stylesheet (menu Atom->stylesheet...). See https://github.com/hax/refactor/blob/master/styles/refactor.less#L15-L23 for current styles.

To add highlight like old version, just:

  .refactor-ref .region,
  .refactor-mut .region,
  .refactor-decl .region {
      border-radius: 2px;
      box-sizing: border-box;
      background-color: rgba(54, 175, 144, 0.2);
      border: 1px solid rgba(54, 175, 144, 0.3);
  }
Redsandro commented 8 years ago

@hax thanks, it works very nice. :+1:

Reference:

// To style other content in the text editor's shadow DOM, use the ::shadow expression
atom-text-editor::shadow {
  // Refactor read write occurances
  .refactor-ref .region {
    background-color: rgba(0, 132, 0, 0.4);
    border-bottom: 2px solid green;
  }
  .refactor-mut .region {
    background-color: rgba(192, 0, 0, 0.4);
    border-bottom: 2px solid red;
  }
  .refactor-decl .region {
    background-color: rgba(132, 132, 0, 0.4);
    border-bottom: 2px solid orange;
  }
}