File tree Expand file tree Collapse file tree 1 file changed +10
-3
lines changed
packages/schema/src/utils Expand file tree Collapse file tree 1 file changed +10
-3
lines changed Original file line number Diff line number Diff line change @@ -30,7 +30,7 @@ import {
3030 Mutable ,
3131 Reference ,
3232} from 'langium' ;
33- import { isAbsolute } from 'node:path' ;
33+ import path from 'node:path' ;
3434import { URI , Utils } from 'vscode-uri' ;
3535import { findNodeModulesFile } from './pkg-utils' ;
3636
@@ -184,9 +184,16 @@ export function resolveImportUri(imp: ModelImport): URI | undefined {
184184
185185 if (
186186 ! imp . path . startsWith ( '.' ) && // Respect relative paths
187- ! isAbsolute ( imp . path ) // Respect Absolute paths
187+ ! path . isAbsolute ( imp . path ) // Respect Absolute paths
188188 ) {
189- imp . path = findNodeModulesFile ( imp . path ) ?? imp . path ;
189+ // use the current model's path as the search context
190+ const contextPath = imp . $container . $document
191+ ? path . dirname ( imp . $container . $document . uri . fsPath )
192+ : process . cwd ( ) ;
193+ imp . path = findNodeModulesFile ( imp . path , contextPath ) ?? imp . path ;
194+ if ( imp . path ) {
195+ console . log ( 'Loaded import from:' , imp . path ) ;
196+ }
190197 }
191198
192199 const dirUri = Utils . dirname ( getDocument ( imp ) . uri ) ;
You can’t perform that action at this time.
0 commit comments