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 {
30
30
Mutable ,
31
31
Reference ,
32
32
} from 'langium' ;
33
- import { isAbsolute } from 'node:path' ;
33
+ import path from 'node:path' ;
34
34
import { URI , Utils } from 'vscode-uri' ;
35
35
import { findNodeModulesFile } from './pkg-utils' ;
36
36
@@ -184,9 +184,16 @@ export function resolveImportUri(imp: ModelImport): URI | undefined {
184
184
185
185
if (
186
186
! imp . path . startsWith ( '.' ) && // Respect relative paths
187
- ! isAbsolute ( imp . path ) // Respect Absolute paths
187
+ ! path . isAbsolute ( imp . path ) // Respect Absolute paths
188
188
) {
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
+ }
190
197
}
191
198
192
199
const dirUri = Utils . dirname ( getDocument ( imp ) . uri ) ;
You can’t perform that action at this time.
0 commit comments