jupyterlab_vscode_icons_extension 1.0.60 → 1.0.63

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/lib/index.js +33 -21
  2. package/package.json +1 -1
  3. package/src/index.ts +34 -28
package/lib/index.js CHANGED
@@ -456,12 +456,12 @@ const plugin = {
456
456
  }
457
457
 
458
458
  /* Color shell script icons - JupyterLab orange for Linux shells (.sh, .bash, .zsh) */
459
- .jp-DirListing-item[data-shell-type="linux"] .jp-DirListing-itemIcon svg {
459
+ .jp-DirListing-item[data-file-type="vscode-file-type-shell"][data-shell-type="linux"] .jp-DirListing-itemIcon svg {
460
460
  filter: brightness(0) saturate(100%) invert(58%) sepia(76%) saturate(3113%) hue-rotate(1deg) brightness(101%) contrast(101%);
461
461
  }
462
462
 
463
463
  /* Color shell script icons - pale blue for Windows shells (.bat, .cmd) */
464
- .jp-DirListing-item[data-shell-type="windows"] .jp-DirListing-itemIcon svg {
464
+ .jp-DirListing-item[data-file-type="vscode-file-type-shell"][data-shell-type="windows"] .jp-DirListing-itemIcon svg {
465
465
  filter: hue-rotate(180deg) saturate(0.6) brightness(1.2);
466
466
  }
467
467
 
@@ -472,21 +472,23 @@ const plugin = {
472
472
  `;
473
473
  // Add a MutationObserver to mark special files in the file browser
474
474
  const markSpecialFiles = () => {
475
- // Clear all special attributes from ALL items first (to handle DOM element reuse)
475
+ // Process ALL items - clear wrong attributes and set correct ones
476
476
  const allItems = document.querySelectorAll('.jp-DirListing-item');
477
477
  allItems.forEach(item => {
478
- item.removeAttribute('data-claude-md');
479
- item.removeAttribute('data-readme-md');
480
- item.removeAttribute('data-jupytext-py');
481
- item.removeAttribute('data-jupytext-md');
482
- item.removeAttribute('data-shell-type');
483
- });
484
- // Mark Jupytext files (.py and .md notebooks) and CLAUDE.md
485
- const notebookItems = document.querySelectorAll('.jp-DirListing-item[data-file-type="notebook"]');
486
- notebookItems.forEach(item => {
487
478
  const nameSpan = item.querySelector('.jp-DirListing-itemText');
488
- if (nameSpan && nameSpan.textContent) {
489
- const name = nameSpan.textContent.trim();
479
+ const fileType = item.getAttribute('data-file-type');
480
+ if (!nameSpan || !nameSpan.textContent || !fileType) {
481
+ return;
482
+ }
483
+ const name = nameSpan.textContent.trim();
484
+ // Handle notebook files (Jupytext and special markdown)
485
+ if (fileType === 'notebook') {
486
+ // Clear all notebook attributes first
487
+ item.removeAttribute('data-claude-md');
488
+ item.removeAttribute('data-readme-md');
489
+ item.removeAttribute('data-jupytext-py');
490
+ item.removeAttribute('data-jupytext-md');
491
+ // Set the correct attribute based on filename
490
492
  if (name === 'CLAUDE.md') {
491
493
  item.setAttribute('data-claude-md', 'true');
492
494
  }
@@ -500,19 +502,29 @@ const plugin = {
500
502
  item.setAttribute('data-jupytext-md', 'true');
501
503
  }
502
504
  }
503
- });
504
- // Mark shell script files for different coloring
505
- const shellItems = document.querySelectorAll('.jp-DirListing-item[data-file-type="vscode-file-type-shell"]');
506
- shellItems.forEach(item => {
507
- const nameSpan = item.querySelector('.jp-DirListing-itemText');
508
- if (nameSpan && nameSpan.textContent) {
509
- const name = nameSpan.textContent.trim();
505
+ else {
506
+ // Not a notebook - clear notebook attributes
507
+ item.removeAttribute('data-claude-md');
508
+ item.removeAttribute('data-readme-md');
509
+ item.removeAttribute('data-jupytext-py');
510
+ item.removeAttribute('data-jupytext-md');
511
+ }
512
+ // Handle shell script files - ONLY set attribute if BOTH conditions match
513
+ if (fileType === 'vscode-file-type-shell') {
510
514
  if (name.endsWith('.sh') || name.endsWith('.bash') || name.endsWith('.zsh')) {
511
515
  item.setAttribute('data-shell-type', 'linux');
512
516
  }
513
517
  else if (name.endsWith('.bat') || name.endsWith('.cmd')) {
514
518
  item.setAttribute('data-shell-type', 'windows');
515
519
  }
520
+ else {
521
+ // Shell file type but wrong extension - clear attribute
522
+ item.removeAttribute('data-shell-type');
523
+ }
524
+ }
525
+ else {
526
+ // Not a shell file - always clear shell-type attribute
527
+ item.removeAttribute('data-shell-type');
516
528
  }
517
529
  });
518
530
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "jupyterlab_vscode_icons_extension",
3
- "version": "1.0.60",
3
+ "version": "1.0.63",
4
4
  "description": "Jupyterlab extension with a shameless rip-off of the vscode-icons into our beloved environment",
5
5
  "keywords": [
6
6
  "jupyter",
package/src/index.ts CHANGED
@@ -504,12 +504,12 @@ const plugin: JupyterFrontEndPlugin<void> = {
504
504
  }
505
505
 
506
506
  /* Color shell script icons - JupyterLab orange for Linux shells (.sh, .bash, .zsh) */
507
- .jp-DirListing-item[data-shell-type="linux"] .jp-DirListing-itemIcon svg {
507
+ .jp-DirListing-item[data-file-type="vscode-file-type-shell"][data-shell-type="linux"] .jp-DirListing-itemIcon svg {
508
508
  filter: brightness(0) saturate(100%) invert(58%) sepia(76%) saturate(3113%) hue-rotate(1deg) brightness(101%) contrast(101%);
509
509
  }
510
510
 
511
511
  /* Color shell script icons - pale blue for Windows shells (.bat, .cmd) */
512
- .jp-DirListing-item[data-shell-type="windows"] .jp-DirListing-itemIcon svg {
512
+ .jp-DirListing-item[data-file-type="vscode-file-type-shell"][data-shell-type="windows"] .jp-DirListing-itemIcon svg {
513
513
  filter: hue-rotate(180deg) saturate(0.6) brightness(1.2);
514
514
  }
515
515
 
@@ -521,26 +521,29 @@ const plugin: JupyterFrontEndPlugin<void> = {
521
521
 
522
522
  // Add a MutationObserver to mark special files in the file browser
523
523
  const markSpecialFiles = () => {
524
- // Clear all special attributes from ALL items first (to handle DOM element reuse)
524
+ // Process ALL items - clear wrong attributes and set correct ones
525
525
  const allItems = document.querySelectorAll('.jp-DirListing-item');
526
526
  allItems.forEach(item => {
527
- item.removeAttribute('data-claude-md');
528
- item.removeAttribute('data-readme-md');
529
- item.removeAttribute('data-jupytext-py');
530
- item.removeAttribute('data-jupytext-md');
531
- item.removeAttribute('data-shell-type');
532
- });
533
-
534
- // Mark Jupytext files (.py and .md notebooks) and CLAUDE.md
535
- const notebookItems = document.querySelectorAll(
536
- '.jp-DirListing-item[data-file-type="notebook"]'
537
- );
538
- notebookItems.forEach(item => {
539
527
  const nameSpan = item.querySelector(
540
528
  '.jp-DirListing-itemText'
541
529
  ) as HTMLElement;
542
- if (nameSpan && nameSpan.textContent) {
543
- const name = nameSpan.textContent.trim();
530
+ const fileType = item.getAttribute('data-file-type');
531
+
532
+ if (!nameSpan || !nameSpan.textContent || !fileType) {
533
+ return;
534
+ }
535
+
536
+ const name = nameSpan.textContent.trim();
537
+
538
+ // Handle notebook files (Jupytext and special markdown)
539
+ if (fileType === 'notebook') {
540
+ // Clear all notebook attributes first
541
+ item.removeAttribute('data-claude-md');
542
+ item.removeAttribute('data-readme-md');
543
+ item.removeAttribute('data-jupytext-py');
544
+ item.removeAttribute('data-jupytext-md');
545
+
546
+ // Set the correct attribute based on filename
544
547
  if (name === 'CLAUDE.md') {
545
548
  item.setAttribute('data-claude-md', 'true');
546
549
  } else if (name === 'README.md') {
@@ -550,24 +553,27 @@ const plugin: JupyterFrontEndPlugin<void> = {
550
553
  } else if (name.endsWith('.md')) {
551
554
  item.setAttribute('data-jupytext-md', 'true');
552
555
  }
556
+ } else {
557
+ // Not a notebook - clear notebook attributes
558
+ item.removeAttribute('data-claude-md');
559
+ item.removeAttribute('data-readme-md');
560
+ item.removeAttribute('data-jupytext-py');
561
+ item.removeAttribute('data-jupytext-md');
553
562
  }
554
- });
555
563
 
556
- // Mark shell script files for different coloring
557
- const shellItems = document.querySelectorAll(
558
- '.jp-DirListing-item[data-file-type="vscode-file-type-shell"]'
559
- );
560
- shellItems.forEach(item => {
561
- const nameSpan = item.querySelector(
562
- '.jp-DirListing-itemText'
563
- ) as HTMLElement;
564
- if (nameSpan && nameSpan.textContent) {
565
- const name = nameSpan.textContent.trim();
564
+ // Handle shell script files - ONLY set attribute if BOTH conditions match
565
+ if (fileType === 'vscode-file-type-shell') {
566
566
  if (name.endsWith('.sh') || name.endsWith('.bash') || name.endsWith('.zsh')) {
567
567
  item.setAttribute('data-shell-type', 'linux');
568
568
  } else if (name.endsWith('.bat') || name.endsWith('.cmd')) {
569
569
  item.setAttribute('data-shell-type', 'windows');
570
+ } else {
571
+ // Shell file type but wrong extension - clear attribute
572
+ item.removeAttribute('data-shell-type');
570
573
  }
574
+ } else {
575
+ // Not a shell file - always clear shell-type attribute
576
+ item.removeAttribute('data-shell-type');
571
577
  }
572
578
  });
573
579
  };