-
Notifications
You must be signed in to change notification settings - Fork 790
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
Add editor formatting service to auto-deindent closing brackets #3313
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is great. Just have two suggestions. Not sure if the scenario implied by them is realistic though.
asyncMaybe { | ||
let! options = optionsOpt | ||
|
||
let line = sourceText.Lines.[sourceText.Lines.IndexOf position] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure if this is realistic or would ever get hit, but max 0 (sourceText.Lines.IndexOf position)
would be useful.
Perhaps this is just me being paranoid after #3180.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IndexOf throws if the position isn't within the text, but as Roslyn has already supplied us with the position I think it's impossible that we can't find the line in the source text (also supplied by Roslyn).
|> Seq.takeWhile ((=) ' ') | ||
|> Seq.length | ||
|
||
let startIndent = indentChars sourceText.Lines.[sourceText.Lines.IndexOf leftSpan.Start] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same as above, or perhaps check this before hand if a startIndent
of 0
would cause trouble?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tested with startIndent 0 and everything's fine :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
Also, perhaps making this be driven by an editor option (and on by default) would also be good if that's possible. I imagine some people would like to turn it off if they prefer a more plain editor. |
Phillip I've set it so that smart indentation is only done if the indentation style is set to 'Smart' in the editor settings. However I think by default it's set to 'Block' and I think we should move everyone over to this style by default - any thoughts as to how we could do this? |
I'm for as smart style as possible by default. After writing some Kotlin in Inellij F# VS editor feels annoyingly dumb. |
@dotnet-bot test this please |
Phillip it's shown as an option but it's not the default |
Ah, I was mistaken in thinking this was what should also set it. Clearly not the case based on the docs for that. I've no idea where this would be set. Isn't there a common place where we're setting some of the newer settings which were added? |
This is great. Is this something that other editors can use as well? /cc @Krzysztof-Cieslak |
Ok everything is in vsintegration. So that's a no. ;-( |
I'm still waiting when anything from Code can be used in VS. |
Most of the fable, react, react native tooling is develop in code. That stuff will flow to VS in vnext. Also a lot of the paket / netcore integration stuff. It's all done so that all editors benefit |
I'm still waiting for features be implemented in FCS instead of being coupled with VS. At least in our case features are shared between xplat editors using FSAC. |
@Krzysztof-Cieslak I've a WIP integration of a large amount of work into the FCS repo , where we will do final testing on FCS (which actually caught some issues), add some documentation and a release. After this integration the whole test/release process should be easier. We will also accept contributions directly to FCS and cherry-pick them into VS if people have a strong preference to contribute them directly to FCS. |
@jasonmalinowski do you know how to set the default value for indenting for a language service to "Smart"? |
@dsyme, I think I do understand the workflow ;) My point was about the fact that whole logic of this feature (and many others) is implemented in Anyway, great feature. 💯 |
I meant that VF(P)T -> Ionide should not be one way road. If you like this feature be available in Ionide, make a PR here, moving the logic to FCS. People here don't care about Ionide, just as you don't care about VS. |
You don't care about Ionide. Pretty sure lot of contributors and maintainers of this repo care about xplat tooling |
OK, it's me who don't care :) Anyway, what about the PR?.. |
I care about Ionide, very very much. I use it all the time and am slowly trying to learn how to contribute to it. You don't have to care about Visual Studio IDE Tools to contribute to F# bits in this repo (except to make sure they continue to compile and pass CI tests as part of your PR).
I agree with this |
@vasily-kirichenko @Krzysztof-Cieslak @dsyme. I would love to have a plan where Ionide and VS Tools shared code. However, I am not smart enough or knowledgeable enough to figure out how that would work. Perhaps one day we will get there ... for sure Ionide is something we care about. |
FYI - asked around about how to set this as the default. Lots of folks taking vacations this time of year, but I'll follow up on that again. I'm fine with taking this for now and then creating a separate issue for Smart Indent being the default. |
Thanks Phillip. I'm also on vacation now so I can't get around to fixing the tests until week after next. |
Sounds good. I'll flag this for follow-up ~1.5 weeks for now. Have a good time! |
It's worth noting we need a way to move everyone's 'Tab Style' to 'Smart' (as C# does) - otherwise people won't get any kind of auto indentation. Note that then we'd match C#'s behaviour. |
cc @KevinRansom @cartermp see comment above |
@saul without enabling by default, discovery will be hard, so I agree it should probably be the default. However, people often dislike default changes, even when the change is useful stuff. Does that make sense? |
It's not a default change per se as the current behaviour will be moved to only act that way if 'Smart' is enabled. So to the end user indentation will work exactly the same, except it will de-indent too (that's what this PR is adding). |
@saul I'm sorry I misunderstood the question. Making the auto de-indent "smart indent only" only seems right. I think we should consider making smart the default, when we are sure the experience is solid. Does that help? |
The question is how we do that. It's the default for me on a fresh installation of VS, and I've never gone in to set it myself, which is why that setting is confusing to me. The experience with this PR (and @xuanduc987's) is great, IMO. The editor feels smart. |
It's a VS setting thingy ... there's some way of setting defaults in the internal VS codebase. I seem to remember Lincoln working it out ages ago, in order to ensure that tabs as spaces is set. I expect Johnathan or Brett know the magic goo. |
@dotnet-bot Windows_NT Release_ci_part1 Build please |
@KevinRansom I know about the failing test cases. Also I think there's a way that we can make Jenkins outside more readable - is there a reason why we aren't parsing the NUnit test report XML? I may open a new PR that makes reading CI failures palpable. |
I'm very in favor of having better build output. But usually we only fix
the current issue to be displayed better. All bigger efforts to change
things more fundamentally never made it in.
Displaying nunit errors im CI should be a good small move. But don't forget
that a big part of the test suite is not nunit.
Am 24.08.2017 10:10 vorm. schrieb "Saul Rennison" <notifications@github.com
…:
@KevinRansom <https://github.com/kevinransom> I know about the failing
test cases.
Also I think there's a way that we can make Jenkins outside more readable
- is there a reason why we aren't parsing the NUnit test report XML? I may
open a new PR that makes reading CI failures palpable.
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#3313 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AADgNA7M3LFORXm8FjLjstkGkz8eY4udks5sbS_jgaJpZM4ORXN8>
.
|
This looks super useful, @saul is this in such a state that I can safely install it 😝 ? |
Indeed it is!
…________________________________
From: Victor Peter Rouven Müller <notifications@github.com>
Sent: Thursday, August 24, 2017 10:00:27 AM
To: Microsoft/visualfsharp
Cc: Saul Rennison; Mention
Subject: Re: [Microsoft/visualfsharp] Add editor formatting service to auto-deindent closing brackets (#3313)
This looks super useful, @saul<https://github.com/saul> is this in such a state that I can safely install it 😝 ?
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub<#3313 (comment)>, or mute the thread<https://github.com/notifications/unsubscribe-auth/AAD8jp47-465F0jdSBx4JzoONCUHc2rCks5sbTurgaJpZM4ORXN8>.
|
@dotnet-bot Windows_NT Release_ci_part1 Build please Timeout on the CI server... |
@saul An error in the log here:
|
Still WIP, other tests still broken
@cartermp when this goes green it's ready to merge. |
@dotnet-bot please test Windows_NT Release_ci_part2 |
@KevinRansom @cartermp this is ready to merge |
@saul Kevin |
…et#3313) * Add editor formatting service for auto-deindent * Minor refactor of the indentation service - do not indent after 'function' * Only use smart indentation if indent style is set to 'Smart' * Fix broken unit test build * Implement review comments, fix build * Fix some broken brace matching tests Still WIP, other tests still broken * Fix failing indentation tests * Add formatting service tests * Add more brace matching tests Fixes dotnet#2092
At no point in this GIF do I Shift-Tab to de-indent. Closing braces automatically deindent to the same indentation level as that of the opening brace.
It performs the de-indent check on Enter, and when one of ), ] or } is pressed.