@@ -58,49 +58,50 @@ def vscode_get_setting_with_fallback(
58
58
"""
59
59
try :
60
60
return actions .user .vscode_get_setting (key , default_value ), False
61
- except Exception as e :
61
+ except Exception :
62
62
print (fallback_message )
63
63
traceback .print_exc ()
64
64
return fallback_value , True
65
65
66
66
67
- def pick_path (paths : list [Path ]):
67
+ def pick_path (paths : list [Path ]) -> Path :
68
68
existing_paths = [path for path in paths if path .exists ()]
69
69
return max (existing_paths , key = lambda path : path .stat ().st_mtime )
70
70
71
71
72
72
@mac_ctx .action_class ("user" )
73
73
class MacUserActions :
74
74
def vscode_settings_path () -> Path :
75
+ application_support = Path .home () / "Library/Application Support"
75
76
return pick_path (
76
77
[
77
- Path (
78
- f"{ os .environ ['HOME' ]} /Library/Application Support/Code/User/settings.json"
79
- ),
80
- Path (
81
- f"{ os .environ ['HOME' ]} /Library/Application Support/VSCodium/User/settings.json"
82
- ),
78
+ application_support / "Code/User/settings.json" ,
79
+ application_support / "VSCodium/User/settings.json" ,
83
80
]
84
81
)
85
82
86
83
87
84
@linux_ctx .action_class ("user" )
88
85
class LinuxUserActions :
89
86
def vscode_settings_path () -> Path :
87
+ xdg_config_home = Path (
88
+ os .environ .get ("XDG_CONFIG_HOME" , Path .home () / ".config" )
89
+ )
90
90
return pick_path (
91
91
[
92
- Path ( f" { os . environ [ 'HOME' ] } /.config/ Code/User/settings.json") ,
93
- Path ( f" { os . environ [ 'HOME' ] } /.config/ VSCodium/User/settings.json") ,
92
+ xdg_config_home / " Code/User/settings.json" ,
93
+ xdg_config_home / " VSCodium/User/settings.json" ,
94
94
]
95
95
)
96
96
97
97
98
98
@windows_ctx .action_class ("user" )
99
99
class WindowsUserActions :
100
100
def vscode_settings_path () -> Path :
101
+ appdata = Path (os .environ ["APPDATA" ])
101
102
return pick_path (
102
103
[
103
- Path ( f" { os . environ [ 'APPDATA' ] } / Code/User/settings.json") ,
104
- Path ( f" { os . environ [ 'APPDATA' ] } / VSCodium/User/settings.json") ,
104
+ appdata / " Code/User/settings.json" ,
105
+ appdata / " VSCodium/User/settings.json" ,
105
106
]
106
107
)
0 commit comments