Skip to content

Commit

Permalink
GLSP-1441: Fix NavigationTargetResolver uri handling (#403)
Browse files Browse the repository at this point in the history
Normalize source and target uris by striping a potential file:// prefix before
comparing

Part of: eclipse-glsp/glsp#1441
  • Loading branch information
tortmayr authored Dec 6, 2024
1 parent 7ea979a commit 8de5d13
Showing 1 changed file with 6 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
*
* SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
********************************************************************************/
import { inject, injectable } from 'inversify';
import {
IActionDispatcher,
ILogger,
Expand All @@ -23,6 +22,7 @@ import {
SetResolvedNavigationTargetAction,
TYPES
} from '@eclipse-glsp/sprotty';
import { inject, injectable } from 'inversify';
import { IDiagramOptions } from '../../base/model/diagram-loader';

/**
Expand Down Expand Up @@ -51,9 +51,12 @@ export class NavigationTargetResolver {
target: NavigationTarget
): Promise<SetResolvedNavigationTargetAction | undefined> {
const targetUri = decodeURIComponent(target.uri);
if (sourceUri && sourceUri !== targetUri && `file://${sourceUri}` !== targetUri) {
const normalizedSourceUri = sourceUri?.replace(/^file:\/\//, '');
const normalizedTargetUri = targetUri.replace(/^file:\/\//, '');

if (normalizedSourceUri && normalizedSourceUri !== normalizedTargetUri) {
// different URI, so we can't resolve it locally
this.logger.info("Source and Target URI are different. Can't resolve locally.", sourceUri, targetUri);
this.logger.info("Source and Target URI are different. Can't resolve locally.", normalizedSourceUri, normalizedTargetUri);
return undefined;
}
if (NavigationTarget.getElementIds(target).length > 0) {
Expand Down

0 comments on commit 8de5d13

Please sign in to comment.