Skip to content

Commit 2c770df

Browse files
committed
Fix to content dot content assist
Signed-off-by: Liam Barry Allan <mrliamallan@live.co.uk>
1 parent 0eaf6a9 commit 2c770df

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

server/src/providers/completionItem.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ export default async function completionItemProvider(handler: CompletionParams):
3030

3131
// This means we're just looking for subfields in the struct
3232
if (trigger === `.`) {
33-
let currentPosition = Position.create(handler.position.line, handler.position.character - 1);
33+
let currentPosition = Position.create(handler.position.line, handler.position.character - 2);
3434
let preWord = getWordRangeAtPosition(document, currentPosition);
3535

3636
// Uh oh! Maybe we found dim struct?
@@ -49,15 +49,15 @@ export default async function completionItemProvider(handler: CompletionParams):
4949
if (currentProcedure && currentProcedure.scope) {
5050
const procScop = currentProcedure.scope;
5151

52-
possibleStruct = currentProcedure.subItems.find(subitem => subitem.name.toUpperCase() === word && subitem.subItems.length > 0);
52+
possibleStruct = currentProcedure.subItems.find(subitem => subitem.name.toUpperCase() === preWord && subitem.subItems.length > 0);
5353

5454
if (!possibleStruct) {
55-
possibleStruct = procScop.structs.find(struct => struct.name.toUpperCase() === word);
55+
possibleStruct = procScop.structs.find(struct => struct.name.toUpperCase() === preWord);
5656
}
5757
}
5858

5959
if (!possibleStruct) {
60-
possibleStruct = doc.structs.find(struct => struct.name.toUpperCase() === word);
60+
possibleStruct = doc.structs.find(struct => struct.name.toUpperCase() === preWord);
6161
}
6262

6363
if (possibleStruct && possibleStruct.keyword[`QUALIFIED`]) {

server/src/providers/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,5 +39,5 @@ export function getWordRangeAtPosition(document: TextDocument, position: Positio
3939
if (startChar === endChar)
4040
return undefined;
4141
else
42-
return document.getText(Range.create(line, Math.max(0, startChar), line, endChar+1));
42+
return document.getText(Range.create(line, Math.max(0, startChar), line, endChar+1)).replace(/(\r\n|\n|\r)/gm, "");
4343
}

0 commit comments

Comments
 (0)