summaryrefslogtreecommitdiffstats
path: root/src/DocGen
diff options
context:
space:
mode:
authorRowan Goemans <RB.Goemans@student.han.nl>2017-10-15 03:24:28 +0200
committerRowan Goemans <RB.Goemans@student.han.nl>2017-10-15 03:24:28 +0200
commita9cc9c28dbff2048ffb99c04b4c8f3271c48e2d8 (patch)
tree18e45b8b64f0140aedfb06503648aa929851bd59 /src/DocGen
parent6c8a34a542e1e79903886368da19613b4ce3b237 (diff)
downloaddoxdocgen-a9cc9c28dbff2048ffb99c04b4c8f3271c48e2d8.tar.gz
-- Fixed issue in setting the cursor if no brief was specified. Cursor is new set to the first DoxyGen command in the comment.
Diffstat (limited to 'src/DocGen')
-rw-r--r--src/DocGen/CGen.ts24
1 files changed, 17 insertions, 7 deletions
diff --git a/src/DocGen/CGen.ts b/src/DocGen/CGen.ts
index 72bcfe0..e281c45 100644
--- a/src/DocGen/CGen.ts
+++ b/src/DocGen/CGen.ts
@@ -57,8 +57,8 @@ export default class CGen implements IDocGen {
editBuilder.replace(rangeToReplace, comment); // Insert the comment
});
- // Set cursor after brief command
- this.setCursorToBrief(rangeToReplace.start.line, rangeToReplace.start.character);
+ // Set cursor to first DoxyGen command.
+ this.moveCursurToFirstDoxyCommand(comment, rangeToReplace.start.line, rangeToReplace.start.character);
}
/***************************************************************************
@@ -158,15 +158,25 @@ export default class CGen implements IDocGen {
return comment;
}
- protected setCursorToBrief(line: number, character: number) {
- // If there was a first line defined the brief is on the next line.
+ protected moveCursurToFirstDoxyCommand(comment: string, baseLine: number, baseCharacter) {
+ // Find first offset of a new line in the comment. Since that's when the line where the first param starts.
+ let line: number = baseLine;
+ let character: number = comment.indexOf("\n");
+
+ // If a first line is included find the 2nd line with a newline.
if (this.firstLine.trim().length !== 0) {
line++;
+ const oldCharacter: number = character;
+ character = comment.indexOf("\n", oldCharacter + 1) - oldCharacter;
}
- character += this.commentPrefix.length + this.briefTemplate.length;
+ // If newline is not found means no first param was found so Set to base position.
+ if (character < 0) {
+ line = baseLine;
+ character = baseCharacter;
+ }
- const move: Selection = new Selection(line, character, line, character);
- this.activeEditor.selection = move;
+ const moveTo: Position = new Position(line, character);
+ this.activeEditor.selection = new Selection(moveTo, moveTo);
}
}