Skip to content

Commit b617d88

Browse files
committed
'View Others' fixes
1 parent 29dd574 commit b617d88

File tree

1 file changed

+33
-2
lines changed

1 file changed

+33
-2
lines changed

src/commands/viewOthers.ts

Lines changed: 33 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -93,12 +93,25 @@ export async function viewOthers(forceEditable = false): Promise<void> {
9393
return info.result.content[0].others;
9494
};
9595

96+
const methodLangIsCOS = (line: string): boolean => {
97+
let result = true;
98+
const keywordsmatch: RegExpMatchArray = line.slice(line.indexOf("[")).match(/language += +([a-z]+)/i);
99+
if (keywordsmatch !== null && keywordsmatch[1] !== "objectscript") {
100+
result = false;
101+
}
102+
return result;
103+
};
104+
96105
const api = new AtelierAPI(file.uri);
97106
let indexarg: string = file.name;
98107
const cursorpos: vscode.Position = vscode.window.activeTextEditor.selection.active;
99108
const fileExt: string = file.name.split(".").pop().toLowerCase();
100109

101-
if (api.config.apiVersion >= 4 && (fileExt === "cls" || fileExt === "mac" || fileExt === "int")) {
110+
if (
111+
api.config.apiVersion >= 4 &&
112+
(fileExt === "cls" || fileExt === "mac" || fileExt === "int") &&
113+
!/^%sqlcq/i.test(indexarg)
114+
) {
102115
// Send the server the current position in the document appended to the name if it supports it
103116
let symbols: vscode.DocumentSymbol[] = await vscode.commands.executeCommand(
104117
"vscode.executeDocumentSymbolProvider",
@@ -127,6 +140,7 @@ export async function viewOthers(forceEditable = false): Promise<void> {
127140
// The current position is in a symbol that we can convert into a label+offset that the server understands
128141
let offset: number = cursorpos.line - currentSymbol.selectionRange.start.line;
129142

143+
let isObjectScript = true;
130144
if (fileExt === "cls") {
131145
// Need to find the actual start of the method
132146
const currentdoc: vscode.TextDocument = vscode.window.activeTextEditor.document;
@@ -139,13 +153,30 @@ export async function viewOthers(forceEditable = false): Promise<void> {
139153
if (methodlinetext.endsWith("{")) {
140154
// This is the last line of the method definition, so count from here
141155
offset = cursorpos.line - methodlinenum;
156+
157+
// Look for the Language compiler keyword
158+
if (methodlinetext.indexOf("[") !== -1) {
159+
// Compiler keywords are on this line
160+
isObjectScript = methodLangIsCOS(methodlinetext);
161+
} else {
162+
// Check the previous line for compiler keywords
163+
const prevlinetext: string = currentdoc.lineAt(methodlinenum - 1).text.trim();
164+
if (prevlinetext.indexOf("[") !== -1) {
165+
// Compiler keywords are on this line
166+
isObjectScript = methodLangIsCOS(prevlinetext);
167+
}
168+
}
169+
142170
break;
143171
}
144172
}
145173
}
146174

147175
offset = offset < 0 ? 0 : offset;
148-
indexarg = indexarg + ":" + currentSymbol.name + "+" + offset;
176+
if (isObjectScript) {
177+
// Only provide label+offset if method language is ObjectScript
178+
indexarg = indexarg + ":" + currentSymbol.name + "+" + offset;
179+
}
149180
}
150181
}
151182
}

0 commit comments

Comments
 (0)