From bf6a8086dc9164d2849fa2a7bf11825f017e816a Mon Sep 17 00:00:00 2001 From: maziac Date: Sat, 21 Nov 2020 11:21:22 +0100 Subject: [PATCH] Fix for #9: C-style comments --- CHANGELOG.md | 3 +++ package-lock.json | 2 +- package.json | 2 +- src/HoverUtils.ts | 13 ++++++++++--- 4 files changed, 15 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ea8e159..b227c93 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,8 @@ # Changelog +## 1.0.2 +- Allowed for "//" C-style comments (fix by oxidaan) + ## 1.0.1 - Added donate button. diff --git a/package-lock.json b/package-lock.json index bc56a87..8865fa7 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "z80-instruction-set", - "version": "1.0.1", + "version": "1.0.2", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/package.json b/package.json index 47a0aef..129ba7c 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "z80-instruction-set", "displayName": "Z80 Instruction Set", - "version": "1.0.1", + "version": "1.0.2", "publisher": "maziac", "description": "Provides documentation of the Z80 instructions on hovering.", "author": { diff --git a/src/HoverUtils.ts b/src/HoverUtils.ts index 2dd66d1..6d714e5 100644 --- a/src/HoverUtils.ts +++ b/src/HoverUtils.ts @@ -19,11 +19,18 @@ export function extractInstruction(line: string, index: number): string { pos++; let rightString = line.substr(pos); - // Now find end of instruction, i.e. until ";" or ":" - let len = 0; + // Now find end of instruction, i.e. until ";", "//" or ":" + let len=0; + let prev=''; for (const ch of rightString) { - if (ch == ';' || ch == ':') + if (ch==';' || ch==':') break; + if (ch=='/' && prev=='/') { + // C-style comment "//" // // is c++ style comment + len--; + break; + } + prev=ch; len++; } let rawInstruction = rightString.substr(0, len).trim().toUpperCase();