Skip to content

Commit 76eaf2a

Browse files
committed
Start work on highlighting
1 parent 5381e37 commit 76eaf2a

File tree

1 file changed

+19
-63
lines changed

1 file changed

+19
-63
lines changed

src/extension.ts

Lines changed: 19 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -124,17 +124,6 @@ function runExtension(isModal: boolean) {
124124
elsedVersions[nestingLevel] = "NOT " + match[2];
125125
}
126126
}
127-
128-
// For debugging purposes only TODO: DELETE THIS:
129-
// let lineNumber = parseInt((new Error().stack?.split('\n')[1].match(/:(\d+):\d+\)$/)?.[1]) || '') + 1;
130-
// console.log("\n-----------\nOn line " + lineNumber +
131-
// ":\ncursorPosition: " + cursorPosition.line + ", " + cursorPosition.character +
132-
// "\ntagCounter: " + tagCounter +
133-
// "\nnestingLevel: " + nestingLevel +
134-
// "\ncurrentTagStart: " + currentTagStart.line + ", " + currentTagStart.character +
135-
// "\ncurrentTagEnd: " + currentTagEnd.line + ", " + currentTagEnd.character
136-
// );
137-
138127
}
139128
else if (match[1] === "elsif" && beforeCursor) {
140129
currentTagSpan[nestingLevel] = tagSetID[nestingLevel]; // The cursor may be within this tag
@@ -158,7 +147,6 @@ function runExtension(isModal: boolean) {
158147
nestingLevel--; // Decrement the nesting level
159148
}
160149

161-
162150
// For each tag:
163151
// Add the details of the current version tag to the versionTags array.
164152
// Each element of the array is an object containing the following properties:
@@ -169,70 +157,38 @@ function runExtension(isModal: boolean) {
169157
positionVersionTagEnd: currentTagEnd
170158
});
171159

172-
// For debugging purposes only TODO: DELETE THIS:
173-
// let lineNumber = parseInt((new Error().stack?.split('\n')[1].match(/:(\d+):\d+\)$/)?.[1]) || '') + 1;
174-
// console.log("\n================================\nOn line " + lineNumber +
175-
// ":\ncursorPosition: " + cursorPosition.line + ", " + cursorPosition.character +
176-
// ":\nbeforeCursor: " + beforeCursor +
177-
// "\ntagCounter: " + tagCounter +
178-
// "\nnestingLevel: " + nestingLevel +
179-
// "\ncurrentTagStart: " + currentTagStart.line + ", " + currentTagStart.character +
180-
// "\ncurrentTagEnd: " + currentTagEnd.line + ", " + currentTagEnd.character +
181-
// "\nversionTags.length: " + versionTags.length
182-
// );
160+
} // End of the tag parsing loop
183161

184162

185-
// For debugging purposes only TODO: DELETE THIS:
186-
// lineNumber = parseInt((new Error().stack?.split('\n')[1].match(/:(\d+):\d+\)$/)?.[1]) || '') + 1;
187-
// //console.log("\n-----------\nOn line " + lineNumber + "\nversionTags:");
188-
// let lastTag = versionTags[versionTags.length - 1];
189-
// console.log("tagID: " + lastTag.tagID);
190-
// console.log("tagSet: " + lastTag.tagSet);
191-
// console.log("positionVersionTagStart: " + JSON.stringify(lastTag.positionVersionTagStart));
192-
// console.log("positionVersionTagEnd: " + JSON.stringify(lastTag.positionVersionTagEnd));
193-
// console.log("match[1]: " + match[1]);
194-
// console.log("versionDescription[" + (tagCounter -1) + "]: " + versionDescription[tagCounter -1]);
163+
// Identify and highlight the version tags for the current cursor position:
164+
highlightVersionTags(activeEditor, currentTagSpan);
195165

196-
} // End of the tag parsing loop
166+
// Prepare and display the message with versioning information:
167+
displayVersionMessage(isModal, cursorPosition, versionDescription);
197168

169+
} // End of runExtension() function
198170

199171

200-
// Prepare and display the popup message with versioning information
201-
// let message = "";
202-
// versionArray = versionArray.map(tag => tag.trim()); // Remove leading and trailing spaces
203-
// if (versionArray.length === 0) {
204-
// message = "There is no inline versioning " + positionString + ".";
205-
// }
206-
// else {
207-
// message = "The inline versioning " + positionString + " is:\n\n" + versionArray.join("\nAND ");
208-
// }
209172

210-
// if (isModal) {
211-
// vscode.window.showInformationMessage(
212-
// message,
213-
// { modal: true } // Make the popup modal rather than a "toast" notification
214-
// );
215-
// } else {
216-
// vscode.window.showInformationMessage(
217-
// message,
218-
// "OK" // Show a "toast" notification with an "OK" button
219-
// );
220-
// }
173+
// --------------------------------
174+
// highlightVersionTags() function
175+
// --------------------------------
176+
function highlightVersionTags(activeEditor: vscode.TextEditor | undefined, currentTagSpan: number[]) {
221177

222178

223-
// Identify and highlight the version tags for the current cursor position:
224-
//ORIGINALLY:
225-
//highlightVersionTags(activeEditor, versionTags, currentIfVersionId, level);
179+
// Create an array to hold the ranges of text to be highlighted
180+
const ranges: vscode.Range[] = [];
226181

227-
// Prepare and display the popup message with versioning information
228-
//ORIGINALLY:
229-
//displayVersionMessage(isModal, versionArray, positionString);
182+
for (let elementNumber = currentTagSpan.length - 1; elementNumber >= 0; elementNumber--) {
230183

184+
// For debugging purposes only TODO: DELETE THIS:
185+
let lineNumber = parseInt((new Error().stack?.split('\n')[1].match(/:(\d+):\d+\)$/)?.[1]) || '') + 1;
186+
console.log(`\n-----------\nOn line ${lineNumber}:\n currentTagSpan[${elementNumber}]: ${currentTagSpan[elementNumber]}`);
231187

232-
// Note we add 1 to nestingLevel because
233-
displayVersionMessage(isModal, cursorPosition, versionDescription);
188+
}
234189

235-
} // End of runExtension() function
190+
191+
}
236192

237193

238194

0 commit comments

Comments
 (0)