Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clicking through function takes you to top of file first #8955

Closed
danieltomasku opened this issue Jan 15, 2021 · 3 comments · Fixed by #9004
Closed

Clicking through function takes you to top of file first #8955

danieltomasku opened this issue Jan 15, 2021 · 3 comments · Fixed by #9004
Labels
bug bugs found in the application editor issues related to the editor

Comments

@danieltomasku
Copy link
Contributor

Bug Description:

Ctrl + clicking on a function takes you to the top of the file and then to the location of the function definition, instead of taking you directly to the location of the function definition. This causes problems when using the Go > Back functionality since it takes you to the top of the file, not your previous location. You have to do Go > Back one more time before you go to your actual previous location.

theia-click-through-bug

Note that jumping to a function definition within a file works as expected. This seems to only occur when jumping to a different file.

Steps to Reproduce:

  1. Ctrl + click on a function that opens up a new file
  2. Use Go > Back
  3. Notice that it sends you to the top of the file, not the previous location.

Additional Information

  • Operating System: RHEL7
  • Theia Version: 1.9.0
@vince-fugnitto
Copy link
Member

The unit-test for it seems to pass (we include the range as part of the location), so it might be that it is not respected when actually opening the editor:

it('should return with the location of the last modification even if the pointer is not on the head', async () => {
const modificationLocation = NavigationLocation.create('file://path/to/file', {
text: '',
range: { start: { line: 300, character: 0 }, end: { line: 500, character: 0 } },
rangeLength: 0
});
const expected = NavigationLocation.create('file://path/to/file', {
text: '',
range: { start: { line: 700, character: 0 }, end: { line: 800, character: 0 } },
rangeLength: 0
});
stack.register(
createCursorLocation(),
modificationLocation,
createCursorLocation({ line: 100, character: 100 }),
expected
);
await stack.back();
await stack.back();
expect(stack.currentLocation()).to.be.deep.equal(modificationLocation);
expect(stack.lastEditLocation()).to.be.deep.equal(expected);
});

@colin-grant-work
Copy link
Contributor

It looks like the test is right, but the way editor add new navigation locations to the stacks is to blame. It seems that no matter how you open an editor - I've tried code navigation and the search-in-workspace widget - the top of the file is added to the navigation stack.

@colin-grant-work
Copy link
Contributor

colin-grant-work commented Jan 18, 2021

This code seems to solve the problem, but it isn't very clean. The data flow is currently a bit muddled, and I haven't found one place to intervene that prevents the initial position from being registered with the service that tracks the location stack - the events handling new editors are lumped in with events handling changes of editor.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug bugs found in the application editor issues related to the editor
Projects
None yet
3 participants