Skip to content

Commit 28ca990

Browse files
committed
Merge branch 'feature/enhance_packages_doc'
Adds a new "Troubleshooting" page in the extensibility section.
2 parents 2089603 + 4a2e1eb commit 28ca990

File tree

4 files changed

+174
-29
lines changed

4 files changed

+174
-29
lines changed

docs/.vitepress/config.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,7 @@ export default defineConfig({
133133
},
134134
{ text: 'Snippets', link: '/guide/extensibility/snippets.md' },
135135
{ text: 'Syntax Definitions', link: '/guide/extensibility/syntaxdefs.md' },
136+
{ text: 'Troubleshooting', link: '/guide/extensibility/troubleshooting.md' },
136137
],
137138
},
138139
{
6.22 KB
Loading

docs/guide/extensibility/packages.md

Lines changed: 21 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -72,10 +72,12 @@ Typical resources found in packages include:
7272
- key maps (`.sublime-keymap`)
7373
- macros (`.sublime-macro`)
7474
- menus (`.sublime-menu`)
75+
- commands (`.sublime-commands`)
7576
- metadata (`.tmPreferences`)
7677
- mouse maps (`.sublime-mousemap`)
7778
- plugins (`.py`)
7879
- settings (`.sublime-settings`)
80+
- completions (`.sublime-completions`)
7981
- snippets (`.sublime-snippet`)
8082
- syntax definitions (`.sublime-syntax`, `.tmLanguage`)
8183
- themes (`.sublime-theme`)
@@ -101,7 +103,7 @@ and you don't need to learn it.
101103
while others enhance Sublime Text
102104
to support common programming languages out of the box.
103105

104-
Examples: Default, Python, Java, C++, Markdown.
106+
Examples: Default, Python, Java, C++, Markdown, reStructuredText, YAML
105107

106108
Located in `Shipped Packages`.
107109

@@ -241,6 +243,7 @@ If you want to stop using a shipped package,
241243

242244

243245
## Customizing or Overriding Packages
246+
244247
[overriding]: #customizing-or-overriding-packages
245248

246249
Since packages in `.sublime-package` zip archives
@@ -255,30 +258,38 @@ To create an override package,
255258
create a new folder under `Packages`
256259
and name it after the `.sublime-package` file
257260
you want to override, excluding the extension.
258-
Any file you create in this package
259-
will take precedence over any identically named file
261+
262+
Any file you create in this package directory
263+
will replace any identically named (and path-ed) file
260264
in the original package.
265+
Sublime Text will completely ignore the same-named file inside the `.sublime-package`
266+
and use your replacement for all purposes.
267+
Note that this is unlike the effect of placing files in the `User` Package,
268+
where, for certain JSON file types like settings,
269+
Sublime Text [merges][merging] them into global data structures.
261270

262271
Python plugins in override packages
263272
are able to use relative imports
264273
for accessing other modules in the corresponding `.sublime-package` file
265274
as if they were part of it.
266275

267276
::: warning
268-
Files in override packages override entire files.
269-
If the overridden file in the corresponding `.sublime-package` is updated,
270-
you will not be notified.
277+
Files in override packages override the *entire file*.
278+
If the overridden file in the corresponding `.sublime-package` is updated,
279+
you will not be notified.
271280

272-
The [OverrideAudit][] package provides monitoring of override files
273-
and will notify you
274-
when the file it overrides has been updated.
281+
The [OverrideAudit][] package provides monitoring of override files
282+
and will notify you
283+
when the file it overrides has been updated.
275284

276-
[OverrideAudit]: https://github.com/OdatNurd/OverrideAudit
285+
[OverrideAudit]: https://github.com/OdatNurd/OverrideAudit
277286
:::
278287

279288

280289
## Merging and Order of Precedence
281290

291+
[merging]: #merging-and-order-of-precedence
292+
282293
Package precedence is important for merging certain resources,
283294
for example, `.sublime-keymap` and `.sublime-settings` files,
284295
and for loading plugins (`.py` files).
@@ -299,22 +310,3 @@ Sublime Text loads packages in this order:
299310
1. `Packages/User`
300311

301312

302-
## Reverting Sublime Text to Its Default Configuration
303-
304-
Reverting Sublime Text to a fresh state
305-
solves many problems
306-
that appear to be bugs in Sublime Text
307-
but are in fact caused by misbehaving
308-
packages and plugins.
309-
310-
<!-- TODO --safe-mode -->
311-
To revert Sublime Text to its default configuration
312-
and remove all your settings and configurations,
313-
delete the [Data directory](../getting-started/basic-concepts.md#the-data-directory)
314-
and restart the editor.
315-
Keep in mind
316-
that the `Installed Packages` folder will be deleted too,
317-
so you'll lose all your installed packages.
318-
319-
Always make sure to back up your data
320-
before taking an extreme measure like this one!
Lines changed: 152 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,152 @@
1+
## Troubleshooting
2+
3+
Because Sublime Text is so customizable,
4+
it is possible for third-party packages and/or local customization
5+
to interfere with one another or cause other problems.
6+
You might see this, for example,
7+
as Python exceptions that don't make sense in the Console Panel,
8+
or certain functionality isn't behaving as you expect.
9+
10+
### Safe Mode
11+
12+
![Safe Mode Announcement](./images/safe_mode_announcement.png)
13+
14+
Starting with version 4,
15+
you can launch Sublime Text in *Safe Mode*
16+
via the Command Line Interface:
17+
18+
```sh
19+
subl --safe-mode
20+
```
21+
22+
Additionally on Windows and Mac,
23+
holding a modifier key while starting the application
24+
will open it in Safe Mode:
25+
26+
* **Windows**: <Key k="shift+alt" />
27+
* **Mac**: <Key k="option" />
28+
29+
When launched this way,
30+
Sublime Text uses an alternate [Data directory][],
31+
thus disabling all third-party packages and local customizations,
32+
as well as not loading any previously opened sessions.
33+
This will help you to verify whether the behavior you are observing
34+
is or is not coming from Sublime Text itself
35+
or one of its shipped packages.
36+
37+
The alternate Data directory used is:
38+
39+
* **Windows**: `%APPDATA%\Sublime Text (Safe Mode)\`
40+
* **macOS**: `~/Library/Application Support/Sublime Text (Safe Mode)/`
41+
* **Linux**: `~/.config/sublime-text-safe-mode/`
42+
43+
Another nice aspect about Safe Mode is
44+
that you can perform experimental customizations
45+
or packages you think might have caused problems
46+
without affect Sublime Text's ability
47+
to start and behave normally,
48+
because:
49+
50+
- such packages will be installed in the alternate Data directory,
51+
thus not impacting normal sessions, and
52+
- each time Sublime Text starts in Safe Mode,
53+
it deletes any content in the Safe Mode Data directory,
54+
so it "doesn't hurt" if a package installed there
55+
did something it wasn't supposed to.
56+
57+
::: warning Caution
58+
**Do not store anything important in the Safe-Mode Data directory!**
59+
The data will be removed latest on the next Safe Mode start.
60+
61+
**Do not install suspicious packages with Python plugins even in Safe Mode!**
62+
Python plugins still have access to the full Python library
63+
and can access your file system
64+
as if they were running natively on your system.
65+
:::
66+
67+
After attempting to reproduce the behavior you observed previously in Safe Mode,
68+
you were either successful or not.
69+
70+
**Reproducible in Safe Mode**
71+
: If the behavior is still being exhibited,
72+
it could be caused by a corrupted shipped Package file,
73+
which can be remedied by re-installing Sublime Text,
74+
or a bug.
75+
You can look for already reported bugs
76+
on the [official issue tracker][issue tracker]
77+
or report a new one
78+
if no existing one matches your situation.
79+
80+
[issue tracker]: https://github.com/sublimehq/sublime_text/issues
81+
82+
**Not Reproducible in Safe Mode**
83+
: If the behavior disappears,
84+
then you know it was caused by something in your Data directory.
85+
Follow the section below to narrow down the cause further.
86+
87+
88+
### Diagnosing Trouble from the Data Directory
89+
90+
If you have reached the conclusion
91+
that the trouble you are experiencing has come from the Data directory
92+
(third-party packages and/or local customization),
93+
you can discover the source of the problem by following these steps.
94+
Knowing *when* the problem started is also an asset,
95+
because the cause will most likely have occurred
96+
just before the problem started.
97+
98+
1. Close Sublime Text if it is running.
99+
1. Rename the [Data directory][] to another name
100+
to keep it as a backup and reference about
101+
what packages you installed and what customizations you made.
102+
1. Re-start Sublime Text.
103+
104+
When Sublime Text starts, it will create a fresh new Data directory.
105+
106+
::: tip Note
107+
In subsequent steps,
108+
it is recommended to keep
109+
the contents of the renamed problematic Data directory unaltered
110+
for the sake of preserving the evidence.
111+
This is so that if your first attempt at isolating the problem isn't successful,
112+
you can repeat it
113+
as many times as needed
114+
using smaller or different steps
115+
until you have isolated the problem.
116+
:::
117+
118+
#### Diagnosis by Isolating Packages
119+
120+
Now you can re-install third-party packages you had in place
121+
(and were working correctly)
122+
well before the problem started.
123+
You can install each package individually
124+
or multiple (related) packages in a group
125+
to speed up the process.
126+
127+
Verify whether the problem is occurring after each increment.
128+
129+
**The problem is *not* occurring**
130+
: Continue re-adding more packages
131+
until the behavior returns.
132+
133+
**The problem *is* occurring**
134+
: Now you know the problem is somewhere in that group of packages,
135+
and you can take steps to further isolate the source
136+
by reverting and repeating this step
137+
with only half of the packages in the group.
138+
Keep dividing the group until you have isolated the source
139+
ideally to a single package.
140+
141+
#### Diagnosis by Isolating Customizations
142+
143+
If you have re-installed all third-party packages
144+
and the problem has not returned,
145+
now you can add your own customizations back in,
146+
one at a time,
147+
until the problem resurfaces.
148+
If/When you encounter the problem again,
149+
you will know where to investigate further to remedy,
150+
or, as the case may be, what *not* to do.
151+
152+
[Data directory]: ../getting-started/basic-concepts.md#the-data-directory

0 commit comments

Comments
 (0)