From 516675facd3c16bd2f42f78783a1da0f9c9e1866 Mon Sep 17 00:00:00 2001 From: Christoph Schlosser Date: Thu, 1 Mar 2018 18:19:47 +0100 Subject: Dont select negative values --- src/Lang/Cpp/CppDocGen.ts | 4 ++-- src/test/CppTests/Con-AndDestructor.test.ts | 2 ++ 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/Lang/Cpp/CppDocGen.ts b/src/Lang/Cpp/CppDocGen.ts index a7994eb..b825570 100644 --- a/src/Lang/Cpp/CppDocGen.ts +++ b/src/Lang/Cpp/CppDocGen.ts @@ -311,8 +311,8 @@ export class CppDocGen implements IDocGen { line = baseLine; character = baseCharacter; } - - const from: Position = new Position(line, character - this.smartTextLength - 1); + const start = character - this.smartTextLength - 1; + const from: Position = new Position(line, (start > 0 ? start : 0)); const to: Position = new Position(line, character); this.activeEditor.selection = new Selection(from, to); } diff --git a/src/test/CppTests/Con-AndDestructor.test.ts b/src/test/CppTests/Con-AndDestructor.test.ts index 6bf3242..7858c30 100644 --- a/src/test/CppTests/Con-AndDestructor.test.ts +++ b/src/test/CppTests/Con-AndDestructor.test.ts @@ -15,6 +15,8 @@ import TestSetup from "./TestSetup"; suite("C++ - Con- and Destructor Tests", () => { const testSetup: TestSetup = new TestSetup("void foo();"); + testSetup.cfg.generateSmartText = false; + // Tests test("Normal Constructor", () => { const result = testSetup.SetLine("Foo(int a);").GetResult(); -- cgit v1.2.3