Skip to content

Commit 43c0df3

Browse files
committed
Fix most spurious find definition queries when pressing the Command (macOS) or Control (Windows, Linux) keys with the cursor over some random (but not selected) text
1 parent 805a026 commit 43c0df3

File tree

3 files changed

+9
-2
lines changed

3 files changed

+9
-2
lines changed

CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
* Update readme section on "Go To References" support
66
* Fix spurious find definition queries when the text under the cursor is a variable
7+
* Fix most spurious find definition queries when pressing the Command (macOS) or Control (Windows, Linux) keys with the cursor over some random (but not selected) text
78

89
## [0.33.0]
910

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -373,7 +373,7 @@ VSCode doesn't support disabling menu items that are not supported by language e
373373

374374
When the "Run and Debug" pane is closed, selecting the "Run" menu "New Breakpoint > Function Breakpoint..." item doesn't open the pane to show the new breakpoint text insertion box.
375375

376-
VSCode triggers the "Go to Definition" computations if the cursor happens to be over some text when typing the command (macOS) or control (Windows, Linux) keys to type any keyboard command shortcut without waiting for or requiring cursor movement. It also doesn't allow overriding using the command/control keys as a keyboard shortcut for going to a definition. As a consequence, when no Logtalk terminal session exists, one is automatically created as code navigation features, including "Go to Definition", require compiling and loading the source code.
376+
VSCode triggers the "Go to Definition" computations if the cursor happens to be over some text when typing the command (macOS) or control (Windows, Linux) keys to type any keyboard command shortcut without waiting for or requiring cursor movement. It also doesn't allow overriding using the command/control keys as a keyboard shortcut for going to a definition. As a consequence, when some random text is selected and no Logtalk terminal session exists, one may be automatically created as code navigation features, including "Go to Definition", require compiling and loading the source code.
377377

378378
## Development
379379

src/features/definitionProvider.ts

+7-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@ import {
66
Location,
77
Position,
88
TextDocument,
9-
Uri
9+
Uri,
10+
window
1011
} from "vscode";
1112
import LogtalkTerminal from "./logtalkTerminal";
1213
import { Utils } from "../utils/utils";
@@ -26,6 +27,11 @@ export class LogtalkDefinitionProvider implements DefinitionProvider {
2627
return null;
2728
}
2829

30+
const text = window.activeTextEditor.document.getText(window.activeTextEditor.selection);
31+
if (text.length === 0) {
32+
return null;
33+
}
34+
2935
await LogtalkTerminal.getDefinition(doc, position, call);
3036

3137
const dir = path.dirname(doc.uri.fsPath);

0 commit comments

Comments
 (0)