Skip to content
This repository has been archived by the owner on Jul 15, 2023. It is now read-only.

Differentiate between interfaces and structs in outline #2114

Merged
merged 9 commits into from
Nov 21, 2018
Merged

Differentiate between interfaces and structs in outline #2114

merged 9 commits into from
Nov 21, 2018

Conversation

karthikraobr
Copy link
Contributor

This PR fixes the code outline from erroneously displaying structs as interfaces.

Before
screenshot 2018-11-11 at 00 29 59

After
screenshot 2018-11-11 at 00 31 02

@karthikraobr
Copy link
Contributor Author

@ramya-rao-a No idea why the test failed :(

@karthikraobr karthikraobr changed the title Differentiate between interface and struct in outline Differentiate between interfaces and structs in outline Nov 11, 2018
Copy link
Contributor

@ramya-rao-a ramya-rao-a left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using document.getText(range).includes('struct') can give us false positives.
Instead fetch just the first line and use a regular expression to check struct definition.

src/goOutline.ts Outdated Show resolved Hide resolved
@ramya-rao-a
Copy link
Contributor

@karthikraobr I think I am missing something here...

Below is the screenshot from using the latest Go extension

image

The interface and struct are appearing separately for me without the changes in this PR.

What am I missing?

@karthikraobr
Copy link
Contributor Author

karthikraobr commented Nov 13, 2018

@ramya-rao-a I am on the latest version of vscode and the plugin as well. But doesn't work for me. Moreover, a struct being displayed as a class is wrong. Finally, I might be wrong , but there is no code to detect classes right? Are you using a beta?

@ramya-rao-a
Copy link
Contributor

Weird, I don't see that anymore..
Must have been some other extension.

I have pushed a commit to make the regex cover scenarios with extra spaces and make it stricter to match the current struct only.

Can you update the test case?

@karthikraobr
Copy link
Contributor Author

@ramya-rao-a Thanks a ton for fixing the regex. I have added tests for struct outline. Let me know if I need to add more tests.

@karthikraobr
Copy link
Contributor Author

This PR also fixes breadcrumbs for go files.

@ramya-rao-a ramya-rao-a merged commit f4a6c67 into microsoft:master Nov 21, 2018
@ramya-rao-a
Copy link
Contributor

Thanks @karthikraobr!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants