Skip to content

Commit ce44e29

Browse files
committed
fix(ls): correct error position reported
additional: formatting
1 parent 89e9b8c commit ce44e29

File tree

4 files changed

+38
-35
lines changed

4 files changed

+38
-35
lines changed

client/package.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,10 @@
1111
"Languages"
1212
],
1313
"activationEvents": [
14-
"onLanguage:ng-template"
14+
"onLanguage:ng-template",
15+
"onLanguage:html"
1516
],
16-
"main": "./out/extension",
17+
"main": "./out/extension",
1718
"contributes": {
1819
"languages": [
1920
{

client/src/extension.ts

Lines changed: 33 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -6,36 +6,37 @@ import { workspace, Disposable, ExtensionContext } from 'vscode';
66
import { LanguageClient, LanguageClientOptions, SettingMonitor, ServerOptions, TransportKind } from 'vscode-languageclient';
77

88
export function activate(context: ExtensionContext) {
9-
// The server is implemented in node
10-
let serverModule = context.asAbsolutePath(path.join('server', 'server.js'));
11-
// The debug options for the server
12-
let debugOptions = { execArgv: ["--nolazy", "--debug=6004"] };
13-
14-
// If the extension is launched in debug mode then the debug server options are used
15-
// Otherwise the run options are used
16-
let serverOptions: ServerOptions = {
17-
run : { module: serverModule, transport: TransportKind.ipc },
18-
debug: { module: serverModule, transport: TransportKind.ipc, options: debugOptions }
19-
}
20-
21-
// Options to control the language client
22-
let clientOptions: LanguageClientOptions = {
23-
// Register the server for plain text documents
24-
documentSelector: ['ng-template'],
25-
synchronize: {
26-
fileEvents: [
27-
workspace.createFileSystemWatcher('**/tsconfig.json'),
28-
workspace.createFileSystemWatcher('**/*.ts')
29-
],
30-
textDocumentFilter: document => document.fileName.endsWith('.ts')
31-
},
32-
}
33-
34-
// Create the language client and start the client.
35-
let disposable = new LanguageClient('Angular Language Service', serverOptions, clientOptions, true).start();
36-
37-
// Push the disposable to the context's subscriptions so that the
38-
// client can be deactivated on extension deactivation
39-
context.subscriptions.push(disposable);
9+
// The server is implemented in node
10+
let serverModule = context.asAbsolutePath(path.join('server', 'server.js'));
11+
// The debug options for the server
12+
let debugOptions = { execArgv: ["--nolazy", "--debug=6004"] };
13+
14+
// If the extension is launched in debug mode then the debug server options are used
15+
// Otherwise the run options are used
16+
let serverOptions: ServerOptions = {
17+
run : { module: serverModule, transport: TransportKind.ipc },
18+
debug: { module: serverModule, transport: TransportKind.ipc, options: debugOptions }
19+
}
20+
21+
// Options to control the language client
22+
let clientOptions: LanguageClientOptions = {
23+
// Register the server for Angular templates
24+
documentSelector: ['ng-template', 'html'],
25+
26+
// Information in the TypeScript project is necessary to generate Angular template completions
27+
synchronize: {
28+
fileEvents: [
29+
workspace.createFileSystemWatcher('**/tsconfig.json'),
30+
workspace.createFileSystemWatcher('**/*.ts')
31+
],
32+
textDocumentFilter: document => document.fileName.endsWith('.ts')
33+
},
34+
}
35+
36+
// Create the language client and start the client.
37+
let disposable = new LanguageClient('Angular Language Service', serverOptions, clientOptions, true).start();
38+
39+
// Push the disposable to the context's subscriptions so that the
40+
// client can be deactivated on extension deactivation
41+
context.subscriptions.push(disposable);
4042
}
41-

server/.vscode/settings.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,6 @@
22
{
33
"typescript.tsdk": "./node_modules/typescript/lib",
44
"editor.useTabStops": false,
5+
"editor.insertSpaces": true,
56
"editor.tabSize": 2
67
}

server/src/documents.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,7 @@ export class TextDocuments {
193193

194194
public offsetsToPositions(document: TextDocumentIdentifier, offsets: number[]): Position[] {
195195
const file = uriToFileName(document.uri);
196-
return this.projectService.positionsToLineOffsets(file, offsets).map(lineOffset => Position.create(lineOffset.line, lineOffset.col));
196+
return this.projectService.positionsToLineOffsets(file, offsets).map(lineOffset => Position.create(lineOffset.line - 1, lineOffset.col - 1));
197197
}
198198

199199
public getNgService(document: TextDocumentIdentifier): LanguageService | undefined {

0 commit comments

Comments
 (0)