-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Add Open in Editor support for template paths #2198
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
base: main
Are you sure you want to change the base?
Changes from 1 commit
75c29be
50a1c71
6ab36e1
04a30a0
c0b56f7
7275ba1
e57dd87
86c146c
0e10c2e
023144f
1d6349f
118e94c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
- Loading branch information
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -22,6 +22,7 @@ def _is_running_tests(): | |
| "debug_toolbar.panels.profiling.ProfilingPanel", | ||
| "debug_toolbar.panels.redirects.RedirectsPanel", | ||
| }, | ||
| "EDITOR": "vscode", | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't think there should be a default. I'd rather have the feature disabled by default.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think defaulting to enabled with vscode is reasonable.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Isn't JetBrains a big sponsor? If we're giving special treatment, let's make it community-friendly. However, I was going for default OFF. I don't have VSCode installed, so I would get an error.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm for the off by default, no spécial traitment. And if a special traitment there is it should be the most used ide in the django community. Dunno how to find this info.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @codingjoe as far as I can tell, it doesn't error. It's a no-op in the browser. If we want, we're safe picking something as the default. However, we should consider how to make this setting a bit more obvious. I'll push a commit that adds the note and a link to the setting in the docs.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should be resolved in 1d6349f |
||
| "INSERT_BEFORE": "</body>", | ||
| "IS_RUNNING_TESTS": _is_running_tests(), | ||
| "OBSERVE_REQUEST_CALLBACK": "debug_toolbar.toolbar.observe_request", | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -415,3 +415,28 @@ def get_csp_nonce(request) -> str | None: | |
| return csp_nonce | ||
| # Django's built-in CSP support uses get_nonce(request) | ||
| return compat.get_nonce(request) | ||
|
|
||
|
|
||
| def get_editor_url(file: str, line: int = 1) -> str | None: | ||
| formats = { | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This would be a great application for the all new template strings. |
||
| "cursor": "cursor://file/{file}:{line}", | ||
| "emacs": "emacs://open?url=file://{file}&line={line}", | ||
| "espresso": "x-espresso://open?filepath={file}&lines={line}", | ||
| "idea": "idea://open?file={file}&line={line}", | ||
| "idea-remote": "javascript:(()=>{let r=new XMLHttpRequest; r.open('get','http://localhost:63342/api/file/?file={file}&line={line}');r.send();})()", | ||
| "macvim": "mvim://open/?url=file://{file}&line={line}", | ||
| "nova": "nova://open?path={file}&line={line}", | ||
| "pycharm": "pycharm://open?file={file}&line={line}", | ||
|
tim-schilling marked this conversation as resolved.
|
||
| "pycharm-remote": "javascript:(()=>{let r=new XMLHttpRequest; r.open('get','http://localhost:63342/api/file/{file}:{line}');r.send();})()", | ||
| "sublime": "subl://open?url=file://{file}&line={line}", | ||
| "vscode": "vscode://file/{file}:{line}", | ||
| "vscode-insiders": "vscode-insiders://file/{file}:{line}", | ||
| "vscode-remote": "vscode://vscode-remote/{file}:{line}", | ||
| "vscode-insiders-remote": "vscode-insiders://vscode-remote/{file}:{line}", | ||
| "vscodium": "vscodium://file/{file}:{line}", | ||
| "windsurf": "windsurf://file/{file}:{line}", | ||
| } | ||
| template = formats.get(dt_settings.get_config()["EDITOR"]) | ||
| if template is None: | ||
| return None | ||
| return template.format(file=file, line=line) | ||
|
tim-schilling marked this conversation as resolved.
Outdated
|
||

Uh oh!
There was an error while loading. Please reload this page.