Skip to content

Commit

Permalink
Merge branch 'main' into not-diagnostic-about-static-member-in-object…
Browse files Browse the repository at this point in the history
…-expression
  • Loading branch information
edgarfgp authored Nov 20, 2023
2 parents 423d8d4 + 156e5d3 commit 8457b4b
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 27 deletions.
30 changes: 30 additions & 0 deletions .github/workflows/check_release_notes.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
name: Check release notes
on:
pull_request:
types: [opened, synchronize, reopened, labeled, unlabeled]
branches:
- 'main'
- 'release/*'
permissions:
issues: write
pull-requests: write
jobs:
check_release_notes:
permissions:
issues: write
pull-requests: write
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
runs-on: ubuntu-latest
steps:
- name: Get github ref
uses: actions/github-script@v3
id: get-pr
with:
script: |
const result = await github.pulls.get({
pull_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
});
return { "pr_number": context.issue.number, "ref": result.data.head.ref, "repository": result.data.head.repo.full_name};
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ open Microsoft.VisualStudio.Editor
open Microsoft.VisualStudio.PlatformUI
open Microsoft.VisualStudio.Shell
open Microsoft.VisualStudio.Shell.Interop
open Microsoft.Internal.VisualStudio.Shell.Interop
open Microsoft.VisualStudio.Language.StandardClassification
open Microsoft.VisualStudio.Text.Classification
open Microsoft.VisualStudio.Utilities
Expand Down Expand Up @@ -91,23 +90,7 @@ module internal ClassificationDefinitions =
[<Import(typeof<SVsServiceProvider>)>] serviceProvider: IServiceProvider
) =

let (|LightTheme|DarkTheme|UnknownTheme|) id =
if
id = KnownColorThemes.Light
|| id = KnownColorThemes.Blue
|| id = Guids.blueHighContrastThemeId
then
LightTheme
elif id = KnownColorThemes.Dark then
DarkTheme
else
UnknownTheme

let getCurrentThemeId () =
let themeService =
serviceProvider.GetService(typeof<SVsColorThemeService>) :?> IVsColorThemeService

themeService.CurrentTheme.ThemeId
let mutable isDarkBackground = false

let customColorData =
[
Expand Down Expand Up @@ -143,7 +126,16 @@ module internal ClassificationDefinitions =
|}
]

let setIsDarkBackground () =
isDarkBackground <-
VSColorTheme
.GetThemedColor(EnvironmentColors.ToolWindowBackgroundColorKey)
.GetBrightness() < 0.5f

let setColors _ =

setIsDarkBackground ()

let fontAndColorStorage =
serviceProvider.GetService(typeof<SVsFontAndColorStorage>) :?> IVsFontAndColorStorage

Expand Down Expand Up @@ -172,10 +164,10 @@ module internal ClassificationDefinitions =
let oldProps = formatMap.GetTextProperties(ict)

let newProps =
match getCurrentThemeId () with
| LightTheme -> oldProps.SetForeground item.LightThemeColor
| DarkTheme -> oldProps.SetForeground item.DarkThemeColor
| UnknownTheme -> oldProps
if isDarkBackground then
oldProps.SetForeground item.DarkThemeColor
else
oldProps.SetForeground item.LightThemeColor

formatMap.SetTextProperties(ict, newProps)

Expand All @@ -187,15 +179,13 @@ module internal ClassificationDefinitions =

do VSColorTheme.add_ThemeChanged handler

do setIsDarkBackground ()

member _.GetColor(ctype) =
match customColorData |> List.tryFindV (fun item -> item.ClassificationName = ctype) with
| ValueSome item ->
let light, dark = item.LightThemeColor, item.DarkThemeColor

match getCurrentThemeId () with
| LightTheme -> Nullable light
| DarkTheme -> Nullable dark
| UnknownTheme -> Nullable()
if isDarkBackground then Nullable dark else Nullable light
| ValueNone -> Nullable()

interface ISetThemeColors with
Expand Down

0 comments on commit 8457b4b

Please sign in to comment.