11// The module 'vscode' contains the VS Code extensibility API
22// Import the module and reference it with the alias vscode in your code below
3- import { window , workspace , commands , Disposable ,
4- ExtensionContext , StatusBarAlignment , StatusBarItem ,
3+ import { window , workspace , commands , Disposable ,
4+ ExtensionContext , StatusBarAlignment , StatusBarItem ,
55 TextDocument , QuickPickItem , FileSystemWatcher , Uri ,
66 TextEditorEdit , TextEditor , Position } from 'vscode' ;
77import * as path from "path" ;
@@ -129,6 +129,18 @@ class RelativePath {
129129 }
130130 }
131131
132+ // Check if the current extension should be excluded
133+ private excludeExtensionsFor ( relativeUrl : string ) {
134+ const currentExtension = path . extname ( relativeUrl )
135+ if ( currentExtension === '' ) {
136+ return false ;
137+ }
138+
139+ return this . _configuration . excludedExtensions . some ( ( ext : string ) => {
140+ return ( ext . startsWith ( '.' ) ? ext : `.${ ext } ` ) . toLowerCase ( ) === currentExtension . toLowerCase ( ) ;
141+ } )
142+ }
143+
132144 // Get the picked item
133145 private returnRelativeLink ( item : QuickPickItem , editor : TextEditor ) : void {
134146 if ( item ) {
@@ -138,6 +150,8 @@ class RelativePath {
138150
139151 if ( this . _configuration . removeExtension ) {
140152 relativeUrl = relativeUrl . substring ( 0 , relativeUrl . lastIndexOf ( "." ) ) ;
153+ } else if ( this . excludeExtensionsFor ( relativeUrl ) ) {
154+ relativeUrl = relativeUrl . substring ( 0 , relativeUrl . lastIndexOf ( "." ) ) ;
141155 }
142156 if ( this . _configuration . removeLeadingDot && relativeUrl . startsWith ( "./../" ) ) {
143157 relativeUrl = relativeUrl . substring ( 2 , relativeUrl . length ) ;
0 commit comments