- /**
- * Weird situation: Invert flag used black foreground and white background results
- * in invalid background color, positioned at the 256 index of the 256 terminal
- * color map. Pin the colors manually in such a case.
- *
- * Source: https://github.com/sourcelair/xterm.js/issues/57
- */
- if (flags & FLAGS.INVERSE) {
- if (bg === 257) {
- bg = 15;
- }
- if (fg === 256) {
- fg = 0;
- }
+ // If inverse flag is on, then swap the foreground and background variables.
+ if (flags & FLAGS.INVERSE) {
+ let temp = bg;
+ bg = fg;
+ fg = temp;
+ // Should inverse just be before the above boldColors effect instead?
+ if ((flags & 1) && fg < 8) {
+ fg += 8;