提交 851ed825 编写于 作者: C Christof Marti

Let walkThroughSnippet scheme go through to tsserver

上级 6d17c2c1
......@@ -178,9 +178,6 @@ export default class BufferSyncSupport {
if (!this.modeIds[document.languageId]) {
return;
}
if (document.isUntitled) {
return;
}
let resource = document.uri;
let filepath = this.client.asAbsolutePath(resource);
if (!filepath) {
......
......@@ -76,7 +76,7 @@ export default class TypeScriptReferencesCodeLensProvider implements CodeLensPro
!(reference.start.line === codeLens.range.start.line + 1
&& reference.start.offset === codeLens.range.start.character + 1))
.map(reference =>
new Location(Uri.file(reference.file),
new Location(this.client.asUrl(reference.file),
new Range(
new Position(reference.start.line - 1, reference.start.offset - 1),
new Position(reference.end.line - 1, reference.end.offset - 1))));
......
......@@ -113,7 +113,7 @@ class LanguageProvider {
private _validate: boolean;
constructor(client: TypeScriptServiceClient, description: LanguageDescription) {
constructor(private client: TypeScriptServiceClient, description: LanguageDescription) {
this.description = description;
this.extensions = Object.create(null);
description.extensions.forEach(extension => this.extensions[extension] = true);
......@@ -121,7 +121,7 @@ class LanguageProvider {
this.bufferSyncSupport = new BufferSyncSupport(client, description.modeIds, {
delete: (file: string) => {
this.currentDiagnostics.delete(Uri.file(file));
this.currentDiagnostics.delete(client.asUrl(file));
}
}, this.extensions);
this.syntaxDiagnostics = Object.create(null);
......@@ -167,7 +167,7 @@ class LanguageProvider {
}
this.description.modeIds.forEach(modeId => {
let selector: DocumentFilter = { scheme: 'file', language: modeId };
let selector: DocumentFilter = modeId;
languages.registerCompletionItemProvider(selector, this.completionItemProvider, '.');
languages.registerHoverProvider(selector, hoverProvider);
languages.registerDefinitionProvider(selector, definitionProvider);
......@@ -316,11 +316,11 @@ class LanguageProvider {
delete this.syntaxDiagnostics[file];
diagnostics = syntaxMarkers.concat(diagnostics);
}
this.currentDiagnostics.set(Uri.file(file), diagnostics);
this.currentDiagnostics.set(this.client.asUrl(file), diagnostics);
}
public configFileDiagnosticsReceived(file: string, diagnostics: Diagnostic[]): void {
this.currentDiagnostics.set(Uri.file(file), diagnostics);
this.currentDiagnostics.set(this.client.asUrl(file), diagnostics);
}
}
......
......@@ -79,6 +79,9 @@ interface MyMessageItem extends MessageItem {
export default class TypeScriptServiceClient implements ITypescriptServiceClient {
private static readonly WALK_THROUGH_SNIPPET_SCHEME = 'walkThroughSnippet';
private static readonly WALK_THROUGH_SNIPPET_SCHEME_COLON = `${TypeScriptServiceClient.WALK_THROUGH_SNIPPET_SCHEME}:`;
private host: ITypescriptServiceClientHost;
private storagePath: string | undefined;
private globalState: Memento;
......@@ -550,6 +553,9 @@ export default class TypeScriptServiceClient implements ITypescriptServiceClient
}
public asAbsolutePath(resource: Uri): string | null {
if (resource.scheme === TypeScriptServiceClient.WALK_THROUGH_SNIPPET_SCHEME) {
return resource.toString();
}
if (resource.scheme !== 'file') {
return null;
}
......@@ -562,6 +568,9 @@ export default class TypeScriptServiceClient implements ITypescriptServiceClient
}
public asUrl(filepath: string): Uri {
if (filepath.startsWith(TypeScriptServiceClient.WALK_THROUGH_SNIPPET_SCHEME_COLON)) {
return Uri.parse(filepath);
}
return Uri.file(filepath);
}
......
......@@ -68,7 +68,7 @@ It's very common to want to work with the entire text in a line we provide a set
### Rename Refactoring
It's easy to rename a symbol such as a function name or variable name. Hit kb(editor.action.rename) while in the symbol `Book` to rename all instances - this will occur across all files in a project. You can also see refactoring in the right click context menu.
```ts
```js
// Reference the function
Book("War of the Worlds", "H G Wells");
Book("The Martian", "Andy Weir");
......@@ -122,7 +122,7 @@ In a large file it can often be useful to collapse sections of code to increase
### Errors and Warnings
Errors and warnings are highlighted as you edit your code with `squiggles`. In the sample below you can see a number of syntax errors. By pressing kb(editor.action.marker.next) you can navigate across them in sequence and see the detailed error message. As you correct them the `squiggles` and `scrollbar indicators` will update.
```ts
```js
// This code has a few syntax errors
Console.log(add(1, 1.5));
......
......@@ -140,7 +140,7 @@ export class WalkThroughPart extends BaseEditor {
model.snippets.forEach(snippet => {
const model = snippet.textEditorModel;
const id = `snippet-${model.uri.fragment}`;
const div = this.content.querySelector(`#${id}`) as HTMLElement;
const div = this.content.querySelector(`#${id.replace(/\./g, '\\.')}`) as HTMLElement;
var options: IEditorOptions = {
scrollBeyondLastLine: false,
......
......@@ -96,7 +96,7 @@ export class WalkThroughInput extends EditorInput {
let i = 0;
const renderer = new marked.Renderer();
renderer.code = (code, lang) => {
const resource = this.resource.with({ scheme: WALK_THROUGH_SNIPPET_SCHEME, fragment: String(i++) });
const resource = this.resource.with({ scheme: WALK_THROUGH_SNIPPET_SCHEME, fragment: `${i++}.${lang}` });
snippets.push(this.textModelResolverService.createModelReference(resource));
return '';
};
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册