Skip to content

Commit f44c918

Browse files
committed
try a lightweight fix for uri comparison
1 parent 1ce8fc3 commit f44c918

File tree

5 files changed

+12
-17
lines changed

5 files changed

+12
-17
lines changed

atest/03_Notebook.robot

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -14,22 +14,15 @@ Python
1414

1515
Foreign Extractors
1616
${file} = Set Variable Foreign extractors.ipynb
17-
# #288: this would need to be restored for latex
18-
#
19-
# Configure JupyterLab Plugin {"language_servers": {"texlab": {"serverSettings": {"latex.lint.onChange": true}}}}
20-
#
17+
Configure JupyterLab Plugin {"language_servers": {"texlab": {"serverSettings": {"latex.lint.onChange": true}}}}
2118
Setup Notebook Python ${file}
2219
# if mypy and pyflakes will fight over `(N|n)ame 'valid'`, just hope for the best
2320
@{diagnostics} = Create List
2421
... Failed to parse expression # bash
2522
... ame 'valid' # python
2623
... Trailing whitespace is superfluous. # r
2724
... `frob` is misspelt # markdown
28-
#
29-
# #288: once configured, diagnostics are coming back over the wire, but not displaying
30-
#
31-
# ... Command terminated with space # latex
32-
#
25+
... Command terminated with space # latex
3326
FOR ${diagnostic} IN @{diagnostics}
3427
Wait Until Page Contains Element css:.cm-lsp-diagnostic[title*\="${diagnostic}"] timeout=35s
3528
Capture Page Screenshot 0x-${diagnostic}.png

packages/jupyterlab-lsp/src/adapters/codemirror/features/diagnostics.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { Menu } from '@lumino/widgets';
44
import { PositionConverter } from '../../../converter';
55
import { IVirtualPosition, IEditorPosition } from '../../../positioning';
66
import { diagnosticSeverityNames } from '../../../lsp';
7-
import { DefaultMap } from '../../../utils';
7+
import { DefaultMap, uris_equal } from '../../../utils';
88
import { CodeMirrorLSPFeature, IFeatureCommand } from '../feature';
99
import { MainAreaWidget } from '@jupyterlab/apputils';
1010
import {
@@ -217,7 +217,7 @@ export class Diagnostics extends CodeMirrorLSPFeature {
217217
}
218218

219219
public handleDiagnostic = (response: lsProtocol.PublishDiagnosticsParams) => {
220-
if (response.uri !== this.virtual_document.document_info.uri) {
220+
if (!uris_equal(response.uri, this.virtual_document.document_info.uri)) {
221221
return;
222222
}
223223

packages/jupyterlab-lsp/src/adapters/codemirror/features/highlights.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import { documentHighlightKindNames } from '../../../lsp';
44
import { VirtualDocument } from '../../../virtual/document';
55
import { IRootPosition } from '../../../positioning';
66
import { CodeMirrorLSPFeature, IFeatureCommand } from '../feature';
7+
import { uris_equal } from '../../../utils';
78

89
export class Highlights extends CodeMirrorLSPFeature {
910
name = 'Highlights';
@@ -49,7 +50,7 @@ export class Highlights extends CodeMirrorLSPFeature {
4950
items: lsProtocol.DocumentHighlight[],
5051
documentUri: string
5152
) => {
52-
if (documentUri !== this.virtual_document.document_info.uri) {
53+
if (!uris_equal(documentUri, this.virtual_document.document_info.uri)) {
5354
return;
5455
}
5556
this.clear_markers();

packages/jupyterlab-lsp/src/adapters/codemirror/features/hover.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { getModifierState } from '../../../utils';
1+
import { getModifierState, uris_equal } from '../../../utils';
22
import {
33
IRootPosition,
44
is_equal,
@@ -96,7 +96,7 @@ export class Hover extends CodeMirrorLSPFeature {
9696
}
9797

9898
public handleHover = (response: lsProtocol.Hover, documentUri: string) => {
99-
if (documentUri !== this.virtual_document.document_info.uri) {
99+
if (!uris_equal(documentUri, this.virtual_document.document_info.uri)) {
100100
return;
101101
}
102102
this.hide_hover();

packages/jupyterlab-lsp/src/utils.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -97,15 +97,16 @@ export function server_root_uri() {
9797
/**
9898
* compare two URIs, discounting:
9999
* - drive capitalization
100+
* - uri encoding
100101
* TODO: probably use vscode-uri
101102
*/
102103
export function uris_equal(a: string, b: string) {
103104
const win_paths = is_win_path(a) && is_win_path(b);
104105
if (win_paths) {
105-
return normalize_win_path(a) === normalize_win_path(b);
106-
} else {
107-
return a === b;
106+
a = normalize_win_path(a);
107+
b = normalize_win_path(b);
108108
}
109+
return a === b || decodeURI(a) === decodeURI(b);
109110
}
110111

111112
/**

0 commit comments

Comments
 (0)