History

catch up with main

KCaverly committed 3 years ago

Commit b9fdfd62 parents afc4c10 192f74793 files · +3017 −761Browse files

Unified · Split

93 files
  1. .github/workflows/ci.yml +2 −2
  2. Cargo.lock +29 −19
  3. Cargo.toml +22 −0
  4. assets/keymaps/atom.json +1 −0
  5. assets/keymaps/default.json +8 −3
  6. assets/keymaps/jetbrains.json +2 −1
  7. assets/keymaps/sublime_text.json +1 −0
  8. assets/keymaps/textmate.json +1 −0
  9. assets/keymaps/vim.json +10 −9
  10. assets/settings/default.json +18 −1
  11. crates/collab/src/tests/integration_tests.rs +3 −3
  12. crates/collab_ui/src/contact_finder.rs +1 −1
  13. crates/command_palette/src/command_palette.rs +1 −1
  14. crates/db/src/db.rs +11 −89
  15. crates/editor/Cargo.toml +8 −9
  16. crates/editor/src/editor.rs +45 −9
  17. crates/editor/src/editor_tests.rs +2 −2
  18. crates/editor/src/element.rs +9 −5
  19. crates/editor/src/items.rs +32 −5
  20. crates/editor/src/link_go_to_definition.rs +9 −6
  21. crates/editor/src/selections_collection.rs +2 −2
  22. crates/feedback/src/feedback_editor.rs +31 −3
  23. crates/feedback/src/submit_feedback_button.rs +20 −2
  24. crates/file_finder/src/file_finder.rs +54 −36
  25. crates/fs/src/repository.rs +1 −0
  26. crates/gpui/src/app.rs +6 −6
  27. crates/gpui/src/app/window.rs +23 −18
  28. crates/gpui/src/gpui.rs +1 −1
  29. crates/gpui/src/keymap_matcher.rs +7 −4
  30. crates/gpui/src/keymap_matcher/binding.rs +2 −2
  31. crates/gpui/src/keymap_matcher/keymap.rs +358 −31
  32. crates/gpui/src/keymap_matcher/keymap_context.rs +1 −1
  33. crates/gpui/src/keymap_matcher/keystroke.rs +1 −1
  34. crates/gpui/src/platform/mac/platform.rs +1 −1
  35. crates/language/Cargo.toml +14 −12
  36. crates/language/src/buffer.rs +19 −15
  37. crates/language/src/buffer_tests.rs +115 −43
  38. crates/language/src/language.rs +2 −1
  39. crates/language/src/syntax_map.rs +101 −16
  40. crates/language/src/syntax_map/syntax_map_tests.rs +162 −73
  41. crates/language_selector/src/language_selector.rs +1 −1
  42. crates/language_tools/src/lsp_log.rs +12 −2
  43. crates/lsp/src/lsp.rs +4 −3
  44. crates/menu/src/menu.rs +1 −0
  45. crates/node_runtime/src/node_runtime.rs +16 −29
  46. crates/outline/src/outline.rs +1 −1
  47. crates/picker/src/picker.rs +13 −7
  48. crates/project/src/project.rs +2 −1
  49. crates/project/src/worktree.rs +6 −4
  50. crates/project_panel/src/project_panel.rs +27 −1
  51. crates/project_symbols/src/project_symbols.rs +7 −2
  52. crates/recent_projects/src/recent_projects.rs +1 −1
  53. crates/search/src/buffer_search.rs +199 −12
  54. crates/search/src/search.rs +2 −1
  55. crates/semantic_index/src/embedding.rs +7 −5
  56. crates/terminal/src/terminal.rs +16 −1
  57. crates/terminal_view/src/terminal_view.rs +12 −1
  58. crates/theme/src/theme.rs +4 −2
  59. crates/theme/src/theme_registry.rs +17 −5
  60. crates/theme/src/theme_settings.rs +31 −2
  61. crates/theme_selector/src/theme_selector.rs +1 −1
  62. crates/vcs_menu/src/lib.rs +10 −6
  63. crates/welcome/src/base_keymap_picker.rs +1 −1
  64. crates/workspace/src/item.rs +46 −0
  65. crates/workspace/src/pane.rs +106 −73
  66. crates/workspace/src/pane_group.rs +417 −38
  67. crates/workspace/src/persistence.rs +101 −54
  68. crates/workspace/src/persistence/model.rs +9 −7
  69. crates/workspace/src/searchable.rs +16 −3
  70. crates/workspace/src/workspace.rs +113 −25
  71. crates/zed/Cargo.toml +22 −19
  72. crates/zed/src/languages.rs +15 −1
  73. crates/zed/src/languages/heex/config.toml +1 −1
  74. crates/zed/src/languages/heex/highlights.scm +3 −3
  75. crates/zed/src/languages/php.rs +133 −0
  76. crates/zed/src/languages/php/config.toml +11 −0
  77. crates/zed/src/languages/php/highlights.scm +123 −0
  78. crates/zed/src/languages/php/injections.scm +3 −0
  79. crates/zed/src/languages/php/outline.scm +26 −0
  80. crates/zed/src/languages/php/tags.scm +40 −0
  81. crates/zed/src/languages/python/outline.scm +1 −1
  82. crates/zed/src/languages/svelte.rs +125 −0
  83. crates/zed/src/languages/svelte/config.toml +18 −0
  84. crates/zed/src/languages/svelte/folds.scm +9 −0
  85. crates/zed/src/languages/svelte/highlights.scm +42 −0
  86. crates/zed/src/languages/svelte/indents.scm +8 −0
  87. crates/zed/src/languages/svelte/injections.scm +28 −0
  88. crates/zed/src/main.rs +10 −2
  89. crates/zed/src/zed.rs +15 −11
  90. styles/src/style_tree/editor.ts +1 −1
  91. styles/src/style_tree/feedback.ts +5 −0
  92. styles/src/style_tree/search.ts +29 −0
  93. styles/src/style_tree/tab_bar.ts +14 −0
.github/workflows/ci.yml+2−2
@@ -148,8 +148,8 @@ jobs: · 147 unmodified lines
148148 - name: Create app bundle
149149 run: script/bundle
150150
151− - name: Upload app bundle to workflow run if main branch or specifi label
152− uses: actions/upload-artifact@v2
151+ - name: Upload app bundle to workflow run if main branch or specific label
152+ uses: actions/upload-artifact@v3
153153 if: ${{ github.ref == 'refs/heads/main' }} || contains(github.event.pull_request.labels.*.name, 'run-build-dmg') }}
154154 with:
155155 name: Zed_${{ github.event.pull_request.head.sha || github.sha }}.dmg
Cargo.lock+29−19
@@ -1243,9 +1243,9 @@ dependencies = [ · 1242 unmodified lines
12431243
12441244 [[package]]
12451245 name = "clap"
1246−version = "4.3.14"
1246+version = "4.3.15"
12471247 source = "registry+https://github.com/rust-lang/crates.io-index"
1248−checksum = "98330784c494e49850cb23b8e2afcca13587d2500b2e3f1f78ae20248059c9be"
1248+checksum = "8f644d0dac522c8b05ddc39aaaccc5b136d5dc4ff216610c5641e3be5becf56c"
12491249 dependencies = [
12501250 "clap_builder",
12511251 "clap_derive 4.3.12",
@@ -1254,9 +1254,9 @@ dependencies = [ · 2 unmodified lines
12541254
12551255 [[package]]
12561256 name = "clap_builder"
1257−version = "4.3.14"
1257+version = "4.3.15"
12581258 source = "registry+https://github.com/rust-lang/crates.io-index"
1259−checksum = "e182eb5f2562a67dda37e2c57af64d720a9e010c5e860ed87c056586aeafa52e"
1259+checksum = "af410122b9778e024f9e0fb35682cc09cc3f85cad5e8d3ba8f47a9702df6e73d"
12601260 dependencies = [
12611261 "anstream",
12621262 "anstyle",
@@ -2253,7 +2253,6 @@ dependencies = [ · 990 unmodified lines
22532253 "theme",
22542254 "tree-sitter",
22552255 "tree-sitter-html",
2256− "tree-sitter-javascript",
22572256 "tree-sitter-rust",
22582257 "tree-sitter-typescript 0.20.2 (git+https://github.com/tree-sitter/tree-sitter-typescript?rev=5d20856f34315b068c41edaee2ac8a100081d259)",
22592258 "unindent",
@@ -3750,15 +3749,16 @@ dependencies = [ · 1490 unmodified lines
37503749 "text",
37513750 "theme",
37523751 "tree-sitter",
3752+ "tree-sitter-elixir 0.1.0 (git+https://github.com/elixir-lang/tree-sitter-elixir?rev=4ba9dab6e2602960d95b2b625f3386c27e08084e)",
37533753 "tree-sitter-embedded-template",
3754+ "tree-sitter-heex",
37543755 "tree-sitter-html",
3755− "tree-sitter-javascript",
3756− "tree-sitter-json 0.19.0",
3756+ "tree-sitter-json 0.20.0",
37573757 "tree-sitter-markdown",
37583758 "tree-sitter-python",
37593759 "tree-sitter-ruby",
37603760 "tree-sitter-rust",
3761− "tree-sitter-typescript 0.20.2 (registry+https://github.com/rust-lang/crates.io-index)",
3761+ "tree-sitter-typescript 0.20.2 (git+https://github.com/tree-sitter/tree-sitter-typescript?rev=5d20856f34315b068c41edaee2ac8a100081d259)",
37623762 "unicase",
37633763 "unindent",
37643764 "util",
@@ -8083,16 +8083,6 @@ dependencies = [ · 4318 unmodified lines
80838083 "tree-sitter",
80848084 ]
80858085
8086−[[package]]
8087−name = "tree-sitter-javascript"
8088−version = "0.20.0"
8089−source = "registry+https://github.com/rust-lang/crates.io-index"
8090−checksum = "2490fab08630b2c8943c320f7b63473cbf65511c8d83aec551beb9b4375906ed"
8091−dependencies = [
8092− "cc",
8093− "tree-sitter",
8094−]
8095−
80968086 [[package]]
80978087 name = "tree-sitter-json"
80988088 version = "0.19.0"
@@ -8131,6 +8121,15 @@ dependencies = [ · 32 unmodified lines
81318121 "tree-sitter",
81328122 ]
81338123
8124+[[package]]
8125+name = "tree-sitter-php"
8126+version = "0.19.1"
8127+source = "git+https://github.com/tree-sitter/tree-sitter-php?rev=d43130fd1525301e9826f420c5393a4d169819fc#d43130fd1525301e9826f420c5393a4d169819fc"
8128+dependencies = [
8129+ "cc",
8130+ "tree-sitter",
8131+]
8132+
81348133 [[package]]
81358134 name = "tree-sitter-python"
81368135 version = "0.20.2"
@@ -8179,6 +8178,15 @@ dependencies = [ · 42 unmodified lines
81798178 "tree-sitter",
81808179 ]
81818180
8181+[[package]]
8182+name = "tree-sitter-svelte"
8183+version = "0.10.2"
8184+source = "git+https://github.com/Himujjal/tree-sitter-svelte?rev=697bb515471871e85ff799ea57a76298a71a9cca#697bb515471871e85ff799ea57a76298a71a9cca"
8185+dependencies = [
8186+ "cc",
8187+ "tree-sitter",
8188+]
8189+
81828190 [[package]]
81838191 name = "tree-sitter-toml"
81848192 version = "0.5.1"
@@ -9449,7 +9457,7 @@ name = "xtask" · 1264 unmodified lines
94499457 version = "0.1.0"
94509458 dependencies = [
94519459 "anyhow",
9452− "clap 4.3.14",
9460+ "clap 4.3.15",
94539461 "schemars",
94549462 "serde_json",
94559463 "theme",
@@ -9580,11 +9588,13 @@ dependencies = [ · 124 unmodified lines
95809588 "tree-sitter-json 0.20.0",
95819589 "tree-sitter-lua",
95829590 "tree-sitter-markdown",
9591+ "tree-sitter-php",
95839592 "tree-sitter-python",
95849593 "tree-sitter-racket",
95859594 "tree-sitter-ruby",
95869595 "tree-sitter-rust",
95879596 "tree-sitter-scheme",
9597+ "tree-sitter-svelte",
95889598 "tree-sitter-toml 0.5.1",
95899599 "tree-sitter-typescript 0.20.2 (git+https://github.com/tree-sitter/tree-sitter-typescript?rev=5d20856f34315b068c41edaee2ac8a100081d259)",
95909600 "tree-sitter-yaml",
Cargo.toml+22−0
@@ -107,6 +107,28 @@ tree-sitter = "0.20" · 106 unmodified lines
107107 unindent = { version = "0.1.7" }
108108 pretty_assertions = "1.3.0"
109109
110+tree-sitter-c = "0.20.1"
111+tree-sitter-cpp = "0.20.0"
112+tree-sitter-css = { git = "https://github.com/tree-sitter/tree-sitter-css", rev = "769203d0f9abe1a9a691ac2b9fe4bb4397a73c51" }
113+tree-sitter-elixir = { git = "https://github.com/elixir-lang/tree-sitter-elixir", rev = "4ba9dab6e2602960d95b2b625f3386c27e08084e" }
114+tree-sitter-embedded-template = "0.20.0"
115+tree-sitter-go = { git = "https://github.com/tree-sitter/tree-sitter-go", rev = "aeb2f33b366fd78d5789ff104956ce23508b85db" }
116+tree-sitter-heex = { git = "https://github.com/phoenixframework/tree-sitter-heex", rev = "2e1348c3cf2c9323e87c2744796cf3f3868aa82a" }
117+tree-sitter-json = { git = "https://github.com/tree-sitter/tree-sitter-json", rev = "40a81c01a40ac48744e0c8ccabbaba1920441199" }
118+tree-sitter-rust = "0.20.3"
119+tree-sitter-markdown = { git = "https://github.com/MDeiml/tree-sitter-markdown", rev = "330ecab87a3e3a7211ac69bbadc19eabecdb1cca" }
120+tree-sitter-php = { git = "https://github.com/tree-sitter/tree-sitter-php", rev = "d43130fd1525301e9826f420c5393a4d169819fc" }
121+tree-sitter-python = "0.20.2"
122+tree-sitter-toml = { git = "https://github.com/tree-sitter/tree-sitter-toml", rev = "342d9be207c2dba869b9967124c679b5e6fd0ebe" }
123+tree-sitter-typescript = { git = "https://github.com/tree-sitter/tree-sitter-typescript", rev = "5d20856f34315b068c41edaee2ac8a100081d259" }
124+tree-sitter-ruby = "0.20.0"
125+tree-sitter-html = "0.19.0"
126+tree-sitter-scheme = { git = "https://github.com/6cdh/tree-sitter-scheme", rev = "af0fd1fa452cb2562dc7b5c8a8c55551c39273b9"}
127+tree-sitter-svelte = { git = "https://github.com/Himujjal/tree-sitter-svelte", rev = "697bb515471871e85ff799ea57a76298a71a9cca"}
128+tree-sitter-racket = { git = "https://github.com/zed-industries/tree-sitter-racket", rev = "eb010cf2c674c6fd9a6316a84e28ef90190fe51a"}
129+tree-sitter-yaml = { git = "https://github.com/zed-industries/tree-sitter-yaml", rev = "f545a41f57502e1b5ddf2a6668896c1b0620f930"}
130+tree-sitter-lua = "0.0.14"
131+
110132 [patch.crates-io]
111133 tree-sitter = { git = "https://github.com/tree-sitter/tree-sitter", rev = "49226023693107fba9a1191136a4f47f38cdca73" }
112134 async-task = { git = "https://github.com/zed-industries/async-task", rev = "341b57d6de98cdfd7b418567b8de2022ca993a6e" }
assets/keymaps/atom.json+1−0
@@ -9,6 +9,7 @@ · 8 unmodified lines
99 "context": "Editor",
1010 "bindings": {
1111 "cmd-b": "editor::GoToDefinition",
12+ "alt-cmd-b": "editor::GoToDefinitionSplit",
1213 "cmd-<": "editor::ScrollCursorCenter",
1314 "cmd-g": [
1415 "editor::SelectNext",
assets/keymaps/default.json+8−3
@@ -13,6 +13,7 @@ · 12 unmodified lines
1313 "cmd-up": "menu::SelectFirst",
1414 "cmd-down": "menu::SelectLast",
1515 "enter": "menu::Confirm",
16+ "cmd-enter": "menu::SecondaryConfirm",
1617 "escape": "menu::Cancel",
1718 "ctrl-c": "menu::Cancel",
1819 "cmd-{": "pane::ActivatePrevItem",
@@ -194,8 +195,8 @@ · 175 unmodified lines
194195 {
195196 "context": "Editor && mode == auto_height",
196197 "bindings": {
197− "alt-enter": "editor::Newline",
198− "cmd-alt-enter": "editor::NewlineBelow"
198+ "shift-enter": "editor::Newline",
199+ "cmd-shift-enter": "editor::NewlineBelow"
199200 }
200201 },
201202 {
@@ -221,7 +222,8 @@ · 19 unmodified lines
221222 "escape": "buffer_search::Dismiss",
222223 "tab": "buffer_search::FocusEditor",
223224 "enter": "search::SelectNextMatch",
224− "shift-enter": "search::SelectPrevMatch"
225+ "shift-enter": "search::SelectPrevMatch",
226+ "alt-enter": "search::SelectAllMatches"
225227 }
226228 },
227229 {
@@ -242,6 +244,7 @@ · 14 unmodified lines
242244 "cmd-f": "project_search::ToggleFocus",
243245 "cmd-g": "search::SelectNextMatch",
244246 "cmd-shift-g": "search::SelectPrevMatch",
247+ "alt-enter": "search::SelectAllMatches",
245248 "alt-cmd-c": "search::ToggleCaseSensitive",
246249 "alt-cmd-w": "search::ToggleWholeWord",
247250 "alt-cmd-r": "search::ToggleRegex"
@@ -296,7 +299,9 @@ · 48 unmodified lines
296299 "shift-f8": "editor::GoToPrevDiagnostic",
297300 "f2": "editor::Rename",
298301 "f12": "editor::GoToDefinition",
302+ "alt-f12": "editor::GoToDefinitionSplit",
299303 "cmd-f12": "editor::GoToTypeDefinition",
304+ "alt-cmd-f12": "editor::GoToTypeDefinitionSplit",
300305 "alt-shift-f12": "editor::FindAllReferences",
301306 "ctrl-m": "editor::MoveToEnclosingBracket",
302307 "alt-cmd-[": "editor::Fold",
assets/keymaps/jetbrains.json+2−1
@@ -46,8 +46,9 @@ · 45 unmodified lines
4646 "alt-f7": "editor::FindAllReferences",
4747 "cmd-alt-f7": "editor::FindAllReferences",
4848 "cmd-b": "editor::GoToDefinition",
49− "cmd-alt-b": "editor::GoToDefinition",
49+ "cmd-alt-b": "editor::GoToDefinitionSplit",
5050 "cmd-shift-b": "editor::GoToTypeDefinition",
51+ "cmd-alt-shift-b": "editor::GoToTypeDefinitionSplit",
5152 "alt-enter": "editor::ToggleCodeActions",
5253 "f2": "editor::GoToDiagnostic",
5354 "cmd-f2": "editor::GoToPrevDiagnostic",
assets/keymaps/sublime_text.json+1−0
@@ -20,6 +20,7 @@ · 19 unmodified lines
2020 "cmd-shift-a": "editor::SelectLargerSyntaxNode",
2121 "shift-f12": "editor::FindAllReferences",
2222 "alt-cmd-down": "editor::GoToDefinition",
23+ "ctrl-alt-cmd-down": "editor::GoToDefinitionSplit",
2324 "alt-shift-cmd-down": "editor::FindAllReferences",
2425 "ctrl-.": "editor::GoToHunk",
2526 "ctrl-,": "editor::GoToPrevHunk",
assets/keymaps/textmate.json+1−0
@@ -12,6 +12,7 @@ · 11 unmodified lines
1212 "cmd-l": "go_to_line::Toggle",
1313 "ctrl-shift-d": "editor::DuplicateLine",
1414 "cmd-b": "editor::GoToDefinition",
15+ "alt-cmd-b": "editor::GoToDefinition",
1516 "cmd-j": "editor::ScrollCursorCenter",
1617 "cmd-shift-l": "editor::SelectLine",
1718 "cmd-shift-t": "outline::Toggle",
assets/keymaps/vim.json+10−9
@@ -99,6 +99,10 @@ · 98 unmodified lines
9999 "vim::SwitchMode",
100100 "Normal"
101101 ],
102+ "ctrl+[": [
103+ "vim::SwitchMode",
104+ "Normal"
105+ ],
102106 "0": "vim::StartOfLine", // When no number operator present, use start of line motion
103107 "1": [
104108 "vim::Number",
@@ -234,10 +238,6 @@ · 129 unmodified lines
234238 "h": "editor::Hover",
235239 "t": "pane::ActivateNextItem",
236240 "shift-t": "pane::ActivatePrevItem",
237− "escape": [
238− "vim::SwitchMode",
239− "Normal"
240− ],
241241 "d": "editor::GoToDefinition"
242242 }
243243 },
@@ -265,10 +265,6 @@ · 21 unmodified lines
265265 "t": "editor::ScrollCursorTop",
266266 "z": "editor::ScrollCursorCenter",
267267 "b": "editor::ScrollCursorBottom",
268− "escape": [
269− "vim::SwitchMode",
270− "Normal"
271− ]
272268 }
273269 },
274270 {
@@ -322,7 +318,8 @@ · 47 unmodified lines
322318 "context": "Editor && vim_mode == insert",
323319 "bindings": {
324320 "escape": "vim::NormalBefore",
325− "ctrl-c": "vim::NormalBefore"
321+ "ctrl-c": "vim::NormalBefore",
322+ "ctrl-[": "vim::NormalBefore",
326323 }
327324 },
328325 {
@@ -333,6 +330,10 @@ · 4 unmodified lines
333330 "escape": [
334331 "vim::SwitchMode",
335332 "Normal"
333+ ],
334+ "ctrl+[": [
335+ "vim::SwitchMode",
336+ "Normal"
336337 ]
337338 }
338339 }
assets/settings/default.json+18−1
@@ -24,6 +24,17 @@ · 23 unmodified lines
2424 },
2525 // The default font size for text in the editor
2626 "buffer_font_size": 15,
27+ // Set the buffer's line height.
28+ // May take 3 values:
29+ // 1. Use a line height that's comfortable for reading (1.618)
30+ // "line_height": "comfortable"
31+ // 2. Use a standard line height, (1.3)
32+ // "line_height": "standard",
33+ // 3. Use a custom line height
34+ // "line_height": {
35+ // "custom": 2
36+ // },
37+ "buffer_line_height": "comfortable",
2738 // The factor to grow the active pane by. Defaults to 1.0
2839 // which gives the same size as all other panes.
2940 "active_pane_magnification": 1.0,
@@ -117,6 +128,13 @@ · 87 unmodified lines
117128 // 4. Save when idle for a certain amount of time:
118129 // "autosave": { "after_delay": {"milliseconds": 500} },
119130 "autosave": "off",
131+ // Settings related to the editor's tabs
132+ "tabs": {
133+ // Show git status colors in the editor tabs.
134+ "git_status": false,
135+ // Position of the close button on the editor tabs.
136+ "close_position": "right"
137+ },
120138 // Whether or not to remove any trailing whitespace from lines of a buffer
121139 // before saving it.
122140 "remove_trailing_whitespace_on_save": true,
@@ -282,7 +300,6 @@ · 159 unmodified lines
282300 // "line_height": {
283301 // "custom": 2
284302 // },
285− //
286303 "line_height": "comfortable"
287304 // Set the terminal's font size. If this option is not included,
288305 // the terminal will default to matching the buffer's font size.
crates/collab/src/tests/integration_tests.rs+3−3
@@ -7217,7 +7217,7 @@ async fn test_peers_following_each_other( · 7216 unmodified lines
72177217
72187218 // Clients A and B follow each other in split panes
72197219 workspace_a.update(cx_a, |workspace, cx| {
7220− workspace.split_pane(workspace.active_pane().clone(), SplitDirection::Right, cx);
7220+ workspace.split_and_clone(workspace.active_pane().clone(), SplitDirection::Right, cx);
72217221 });
72227222 workspace_a
72237223 .update(cx_a, |workspace, cx| {
@@ -7228,7 +7228,7 @@ async fn test_peers_following_each_other( · 4 unmodified lines
72287228 .await
72297229 .unwrap();
72307230 workspace_b.update(cx_b, |workspace, cx| {
7231− workspace.split_pane(workspace.active_pane().clone(), SplitDirection::Right, cx);
7231+ workspace.split_and_clone(workspace.active_pane().clone(), SplitDirection::Right, cx);
72327232 });
72337233 workspace_b
72347234 .update(cx_b, |workspace, cx| {
@@ -7455,7 +7455,7 @@ async fn test_auto_unfollowing( · 220 unmodified lines
74557455
74567456 // When client B activates a different pane, it continues following client A in the original pane.
74577457 workspace_b.update(cx_b, |workspace, cx| {
7458− workspace.split_pane(pane_b.clone(), SplitDirection::Right, cx)
7458+ workspace.split_and_clone(pane_b.clone(), SplitDirection::Right, cx)
74597459 });
74607460 assert_eq!(
74617461 workspace_b.read_with(cx_b, |workspace, _| workspace.leader_for_pane(&pane_b)),
crates/collab_ui/src/contact_finder.rs+1−1
@@ -67,7 +67,7 @@ impl PickerDelegate for ContactFinderDelegate { · 66 unmodified lines
6767 })
6868 }
6969
70− fn confirm(&mut self, cx: &mut ViewContext<Picker<Self>>) {
70+ fn confirm(&mut self, _: bool, cx: &mut ViewContext<Picker<Self>>) {
7171 if let Some(user) = self.potential_contacts.get(self.selected_index) {
7272 let user_store = self.user_store.read(cx);
7373 match user_store.contact_request_status(user) {
crates/command_palette/src/command_palette.rs+1−1
@@ -160,7 +160,7 @@ impl PickerDelegate for CommandPaletteDelegate { · 159 unmodified lines
160160
161161 fn dismissed(&mut self, _cx: &mut ViewContext<Picker<Self>>) {}
162162
163− fn confirm(&mut self, cx: &mut ViewContext<Picker<Self>>) {
163+ fn confirm(&mut self, _: bool, cx: &mut ViewContext<Picker<Self>>) {
164164 if !self.matches.is_empty() {
165165 let window_id = cx.window_id();
166166 let focused_view_id = self.focused_view_id;
crates/db/src/db.rs+11−89
@@ -7,7 +7,6 @@ use anyhow::Context; · 6 unmodified lines
77 use gpui::AppContext;
88 pub use indoc::indoc;
99 pub use lazy_static;
10−use parking_lot::{Mutex, RwLock};
1110 pub use smol;
1211 pub use sqlez;
1312 pub use sqlez_macros;
@@ -17,11 +16,9 @@ pub use util::paths::DB_DIR; · 3 unmodified lines
1716 use sqlez::domain::Migrator;
1817 use sqlez::thread_safe_connection::ThreadSafeConnection;
1918 use sqlez_macros::sql;
20−use std::fs::create_dir_all;
2119 use std::future::Future;
2220 use std::path::{Path, PathBuf};
2321 use std::sync::atomic::{AtomicBool, Ordering};
24−use std::time::{SystemTime, UNIX_EPOCH};
2522 use util::channel::ReleaseChannel;
2623 use util::{async_iife, ResultExt};
2724
@@ -42,10 +39,8 @@ const DB_FILE_NAME: &'static str = "db.sqlite"; · 14 unmodified lines
4239
4340 lazy_static::lazy_static! {
4441 pub static ref ZED_STATELESS: bool = std::env::var("ZED_STATELESS").map_or(false, |v| !v.is_empty());
45− pub static ref BACKUP_DB_PATH: RwLock<Option<PathBuf>> = RwLock::new(None);
4642 pub static ref ALL_FILE_DB_FAILED: AtomicBool = AtomicBool::new(false);
4743 }
48−static DB_FILE_OPERATIONS: Mutex<()> = Mutex::new(());
4944
5045 /// Open or create a database at the given directory path.
5146 /// This will retry a couple times if there are failures. If opening fails once, the db directory
@@ -63,66 +58,14 @@ pub async fn open_db<M: Migrator + 'static>( · 11 unmodified lines
6358 let main_db_dir = db_dir.join(Path::new(&format!("0-{}", release_channel_name)));
6459
6560 let connection = async_iife!({
66− // Note: This still has a race condition where 1 set of migrations succeeds
67− // (e.g. (Workspace, Editor)) and another fails (e.g. (Workspace, Terminal))
68− // This will cause the first connection to have the database taken out
69− // from under it. This *should* be fine though. The second dabatase failure will
70− // cause errors in the log and so should be observed by developers while writing
71− // soon-to-be good migrations. If user databases are corrupted, we toss them out
72− // and try again from a blank. As long as running all migrations from start to end
73− // on a blank database is ok, this race condition will never be triggered.
74− //
75− // Basically: Don't ever push invalid migrations to stable or everyone will have
76− // a bad time.
77−
78− // If no db folder, create one at 0-{channel}
79− create_dir_all(&main_db_dir).context("Could not create db directory")?;
61+ smol::fs::create_dir_all(&main_db_dir)
62+ .await
63+ .context("Could not create db directory")
64+ .log_err()?;
8065 let db_path = main_db_dir.join(Path::new(DB_FILE_NAME));
81−
82− // Optimistically open databases in parallel
83− if !DB_FILE_OPERATIONS.is_locked() {
84− // Try building a connection
85− if let Some(connection) = open_main_db(&db_path).await {
86− return Ok(connection)
87− };
88− }
89−
90− // Take a lock in the failure case so that we move the db once per process instead
91− // of potentially multiple times from different threads. This shouldn't happen in the
92− // normal path
93− let _lock = DB_FILE_OPERATIONS.lock();
94− if let Some(connection) = open_main_db(&db_path).await {
95− return Ok(connection)
96− };
97−
98− let backup_timestamp = SystemTime::now()
99− .duration_since(UNIX_EPOCH)
100− .expect("System clock is set before the unix timestamp, Zed does not support this region of spacetime")
101− .as_millis();
102−
103− // If failed, move 0-{channel} to {current unix timestamp}-{channel}
104− let backup_db_dir = db_dir.join(Path::new(&format!(
105− "{}-{}",
106− backup_timestamp,
107− release_channel_name,
108− )));
109−
110− std::fs::rename(&main_db_dir, &backup_db_dir)
111− .context("Failed clean up corrupted database, panicking.")?;
112−
113− // Set a static ref with the failed timestamp and error so we can notify the user
114− {
115− let mut guard = BACKUP_DB_PATH.write();
116− *guard = Some(backup_db_dir);
117− }
118−
119− // Create a new 0-{channel}
120− create_dir_all(&main_db_dir).context("Should be able to create the database directory")?;
121− let db_path = main_db_dir.join(Path::new(DB_FILE_NAME));
122−
123− // Try again
124− open_main_db(&db_path).await.context("Could not newly created db")
125− }).await.log_err();
66+ open_main_db(&db_path).await
67+ })
68+ .await;
12669
12770 if let Some(connection) = connection {
12871 return connection;
@@ -249,13 +192,13 @@ where · 120 unmodified lines
249192
250193 #[cfg(test)]
251194 mod tests {
252− use std::{fs, thread};
195+ use std::thread;
253196
254− use sqlez::{connection::Connection, domain::Domain};
197+ use sqlez::domain::Domain;
255198 use sqlez_macros::sql;
256199 use tempdir::TempDir;
257200
258− use crate::{open_db, DB_FILE_NAME};
201+ use crate::open_db;
259202
260203 // Test bad migration panics
261204 #[gpui::test]
@@ -321,31 +264,10 @@ mod tests { · 59 unmodified lines
321264 .unwrap()
322265 .is_none()
323266 );
324−
325− let mut corrupted_backup_dir = fs::read_dir(tempdir.path())
326− .unwrap()
327− .find(|entry| {
328− !entry
329− .as_ref()
330− .unwrap()
331− .file_name()
332− .to_str()
333− .unwrap()
334− .starts_with("0")
335− })
336− .unwrap()
337− .unwrap()
338− .path();
339− corrupted_backup_dir.push(DB_FILE_NAME);
340−
341− let backup = Connection::open_file(&corrupted_backup_dir.to_string_lossy());
342− assert!(backup.select_row::<usize>("SELECT * FROM test").unwrap()()
343− .unwrap()
344− .is_none());
345267 }
346268
347269 /// Test that DB exists but corrupted (causing recreate)
348− #[gpui::test]
270+ #[gpui::test(iterations = 30)]
349271 async fn test_simultaneous_db_corruption() {
350272 enum CorruptedDB {}
351273
crates/editor/Cargo.toml+8−9
@@ -57,16 +57,16 @@ ordered-float.workspace = true · 56 unmodified lines
5757 parking_lot.workspace = true
5858 postage.workspace = true
5959 pulldown-cmark = { version = "0.9.2", default-features = false }
60−rand = { workspace = true, optional = true }
6160 schemars.workspace = true
6261 serde.workspace = true
6362 serde_derive.workspace = true
6463 smallvec.workspace = true
6564 smol.workspace = true
66−tree-sitter-rust = { version = "*", optional = true }
67−tree-sitter-html = { version = "*", optional = true }
68−tree-sitter-javascript = { version = "*", optional = true }
69−tree-sitter-typescript = { git = "https://github.com/tree-sitter/tree-sitter-typescript", rev = "5d20856f34315b068c41edaee2ac8a100081d259", optional = true }
65+
66+rand = { workspace = true, optional = true }
67+tree-sitter-rust = { workspace = true, optional = true }
68+tree-sitter-html = { workspace = true, optional = true }
69+tree-sitter-typescript = { workspace = true, optional = true }
7070
7171 [dev-dependencies]
7272 copilot = { path = "../copilot", features = ["test-support"] }
@@ -84,7 +84,6 @@ env_logger.workspace = true · 11 unmodified lines
8484 rand.workspace = true
8585 unindent.workspace = true
8686 tree-sitter.workspace = true
87−tree-sitter-rust = "0.20"
88−tree-sitter-html = "0.19"
89−tree-sitter-typescript = { git = "https://github.com/tree-sitter/tree-sitter-typescript", rev = "5d20856f34315b068c41edaee2ac8a100081d259" }
90−tree-sitter-javascript = "0.20"
87+tree-sitter-rust.workspace = true
88+tree-sitter-html.workspace = true
89+tree-sitter-typescript.workspace = true
crates/editor/src/editor.rs+45−9
@@ -271,7 +271,9 @@ actions!( · 270 unmodified lines
271271 SelectLargerSyntaxNode,
272272 SelectSmallerSyntaxNode,
273273 GoToDefinition,
274+ GoToDefinitionSplit,
274275 GoToTypeDefinition,
276+ GoToTypeDefinitionSplit,
275277 MoveToEnclosingBracket,
276278 UndoSelection,
277279 RedoSelection,
@@ -407,7 +409,9 @@ pub fn init(cx: &mut AppContext) { · 129 unmodified lines
407409 cx.add_action(Editor::go_to_hunk);
408410 cx.add_action(Editor::go_to_prev_hunk);
409411 cx.add_action(Editor::go_to_definition);
412+ cx.add_action(Editor::go_to_definition_split);
410413 cx.add_action(Editor::go_to_type_definition);
414+ cx.add_action(Editor::go_to_type_definition_split);
411415 cx.add_action(Editor::fold);
412416 cx.add_action(Editor::fold_at);
413417 cx.add_action(Editor::unfold_lines);
@@ -494,6 +498,7 @@ pub enum SoftWrap { · 80 unmodified lines
494498 #[derive(Clone)]
495499 pub struct EditorStyle {
496500 pub text: TextStyle,
501+ pub line_height_scalar: f32,
497502 pub placeholder_text: Option<TextStyle>,
498503 pub theme: theme::Editor,
499504 pub theme_id: usize,
@@ -6184,14 +6189,31 @@ impl Editor { · 5684 unmodified lines
61846189 }
61856190
61866191 pub fn go_to_definition(&mut self, _: &GoToDefinition, cx: &mut ViewContext<Self>) {
6187− self.go_to_definition_of_kind(GotoDefinitionKind::Symbol, cx);
6192+ self.go_to_definition_of_kind(GotoDefinitionKind::Symbol, false, cx);
61886193 }
61896194
61906195 pub fn go_to_type_definition(&mut self, _: &GoToTypeDefinition, cx: &mut ViewContext<Self>) {
6191− self.go_to_definition_of_kind(GotoDefinitionKind::Type, cx);
6196+ self.go_to_definition_of_kind(GotoDefinitionKind::Type, false, cx);
61926197 }
61936198
6194− fn go_to_definition_of_kind(&mut self, kind: GotoDefinitionKind, cx: &mut ViewContext<Self>) {
6199+ pub fn go_to_definition_split(&mut self, _: &GoToDefinitionSplit, cx: &mut ViewContext<Self>) {
6200+ self.go_to_definition_of_kind(GotoDefinitionKind::Symbol, true, cx);
6201+ }
6202+
6203+ pub fn go_to_type_definition_split(
6204+ &mut self,
6205+ _: &GoToTypeDefinitionSplit,
6206+ cx: &mut ViewContext<Self>,
6207+ ) {
6208+ self.go_to_definition_of_kind(GotoDefinitionKind::Type, true, cx);
6209+ }
6210+
6211+ fn go_to_definition_of_kind(
6212+ &mut self,
6213+ kind: GotoDefinitionKind,
6214+ split: bool,
6215+ cx: &mut ViewContext<Self>,
6216+ ) {
61956217 let Some(workspace) = self.workspace(cx) else { return };
61966218 let buffer = self.buffer.read(cx);
61976219 let head = self.selections.newest::<usize>(cx).head();
@@ -6210,7 +6232,7 @@ impl Editor { · 12 unmodified lines
62106232 cx.spawn_labeled("Fetching Definition...", |editor, mut cx| async move {
62116233 let definitions = definitions.await?;
62126234 editor.update(&mut cx, |editor, cx| {
6213− editor.navigate_to_definitions(definitions, cx);
6235+ editor.navigate_to_definitions(definitions, split, cx);
62146236 })?;
62156237 Ok::<(), anyhow::Error>(())
62166238 })
@@ -6220,6 +6242,7 @@ impl Editor { · 3 unmodified lines
62206242 pub fn navigate_to_definitions(
62216243 &mut self,
62226244 mut definitions: Vec<LocationLink>,
6245+ split: bool,
62236246 cx: &mut ViewContext<Editor>,
62246247 ) {
62256248 let Some(workspace) = self.workspace(cx) else { return };
@@ -6239,7 +6262,11 @@ impl Editor { · 13 unmodified lines
62396262 } else {
62406263 cx.window_context().defer(move |cx| {
62416264 let target_editor: ViewHandle<Self> = workspace.update(cx, |workspace, cx| {
6242− workspace.open_project_item(definition.target.buffer.clone(), cx)
6265+ if split {
6266+ workspace.split_project_item(definition.target.buffer.clone(), cx)
6267+ } else {
6268+ workspace.open_project_item(definition.target.buffer.clone(), cx)
6269+ }
62436270 });
62446271 target_editor.update(cx, |target_editor, cx| {
62456272 // When selecting a definition in a different buffer, disable the nav history
@@ -6275,7 +6302,9 @@ impl Editor { · 29 unmodified lines
62756302 .map(|definition| definition.target)
62766303 .collect();
62776304 workspace.update(cx, |workspace, cx| {
6278− Self::open_locations_in_multibuffer(workspace, locations, replica_id, title, cx)
6305+ Self::open_locations_in_multibuffer(
6306+ workspace, locations, replica_id, title, split, cx,
6307+ )
62796308 });
62806309 });
62816310 }
@@ -6320,7 +6349,7 @@ impl Editor { · 38 unmodified lines
63206349 })
63216350 .unwrap();
63226351 Self::open_locations_in_multibuffer(
6323− workspace, locations, replica_id, title, cx,
6352+ workspace, locations, replica_id, title, false, cx,
63246353 );
63256354 })?;
63266355
@@ -6335,6 +6364,7 @@ impl Editor { · 8 unmodified lines
63356364 mut locations: Vec<Location>,
63366365 replica_id: ReplicaId,
63376366 title: String,
6367+ split: bool,
63386368 cx: &mut ViewContext<Workspace>,
63396369 ) {
63406370 // If there are multiple definitions, open them in a multibuffer
@@ -6381,7 +6411,11 @@ impl Editor { · 40 unmodified lines
63816411 cx,
63826412 );
63836413 });
6384− workspace.add_item(Box::new(editor), cx);
6414+ if split {
6415+ workspace.split_item(Box::new(editor), cx);
6416+ } else {
6417+ workspace.add_item(Box::new(editor), cx);
6418+ }
63856419 }
63866420
63876421 pub fn rename(&mut self, _: &Rename, cx: &mut ViewContext<Self>) -> Option<Task<Result<()>>> {
@@ -8101,7 +8135,7 @@ fn build_style( · 1713 unmodified lines
81018135 cx: &AppContext,
81028136 ) -> EditorStyle {
81038137 let font_cache = cx.font_cache();
8104−
8138+ let line_height_scalar = settings.line_height();
81058139 let theme_id = settings.theme.meta.id;
81068140 let mut theme = settings.theme.editor.clone();
81078141 let mut style = if let Some(get_field_editor_theme) = get_field_editor_theme {
@@ -8115,6 +8149,7 @@ fn build_style( · 7 unmodified lines
81158149 EditorStyle {
81168150 text: field_editor_theme.text,
81178151 placeholder_text: field_editor_theme.placeholder_text,
8152+ line_height_scalar,
81188153 theme,
81198154 theme_id,
81208155 }
@@ -8137,6 +8172,7 @@ fn build_style( · 16 unmodified lines
81378172 underline: Default::default(),
81388173 },
81398174 placeholder_text: None,
8175+ line_height_scalar,
81408176 theme,
81418177 theme_id,
81428178 }
crates/editor/src/editor_tests.rs+2−2
@@ -3836,7 +3836,7 @@ async fn test_autoclose_with_embedded_language(cx: &mut gpui::TestAppContext) { · 3835 unmodified lines
38363836 autoclose_before: "})]>".into(),
38373837 ..Default::default()
38383838 },
3839− Some(tree_sitter_javascript::language()),
3839+ Some(tree_sitter_typescript::language_tsx()),
38403840 ));
38413841
38423842 let registry = Arc::new(LanguageRegistry::test());
@@ -5383,7 +5383,7 @@ async fn test_toggle_block_comment(cx: &mut gpui::TestAppContext) { · 1540 unmodified lines
53835383 line_comment: Some("// ".into()),
53845384 ..Default::default()
53855385 },
5386− Some(tree_sitter_javascript::language()),
5386+ Some(tree_sitter_typescript::language_tsx()),
53875387 ));
53885388
53895389 let registry = Arc::new(LanguageRegistry::test());
crates/editor/src/element.rs+9−5
@@ -156,6 +156,7 @@ impl EditorElement { · 155 unmodified lines
156156 event.position,
157157 event.cmd,
158158 event.shift,
159+ event.alt,
159160 position_map.as_ref(),
160161 text_bounds,
161162 cx,
@@ -308,6 +309,7 @@ impl EditorElement { · 146 unmodified lines
308309 position: Vector2F,
309310 cmd: bool,
310311 shift: bool,
312+ alt: bool,
311313 position_map: &PositionMap,
312314 text_bounds: RectF,
313315 cx: &mut EventContext<Editor>,
@@ -324,9 +326,9 @@ impl EditorElement { · 10 unmodified lines
324326
325327 if point == target_point {
326328 if shift {
327− go_to_fetched_type_definition(editor, point, cx);
329+ go_to_fetched_type_definition(editor, point, alt, cx);
328330 } else {
329− go_to_fetched_definition(editor, point, cx);
331+ go_to_fetched_definition(editor, point, alt, cx);
330332 }
331333
332334 return true;
@@ -1182,8 +1184,10 @@ impl EditorElement { · 849 unmodified lines
11821184 });
11831185 scene.push_mouse_region(
11841186 MouseRegion::new::<ScrollbarMouseHandlers>(cx.view_id(), cx.view_id(), track_bounds)
1185− .on_move(move |_, editor: &mut Editor, cx| {
1186− editor.scroll_manager.show_scrollbar(cx);
1187+ .on_move(move |event, editor: &mut Editor, cx| {
1188+ if event.pressed_button.is_none() {
1189+ editor.scroll_manager.show_scrollbar(cx);
1190+ }
11871191 })
11881192 .on_down(MouseButton::Left, {
11891193 let row_range = row_range.clone();
@@ -1973,7 +1977,7 @@ impl Element<Editor> for EditorElement { · 783 unmodified lines
19731977
19741978 let snapshot = editor.snapshot(cx);
19751979 let style = self.style.clone();
1976− let line_height = style.text.line_height(cx.font_cache());
1980+ let line_height = (style.text.font_size * style.line_height_scalar).round();
19771981
19781982 let gutter_padding;
19791983 let gutter_width;
crates/editor/src/items.rs+32−5
@@ -887,10 +887,20 @@ pub(crate) enum BufferSearchHighlights {} · 886 unmodified lines
887887 impl SearchableItem for Editor {
888888 type Match = Range<Anchor>;
889889
890− fn to_search_event(event: &Self::Event) -> Option<SearchEvent> {
890+ fn to_search_event(
891+ &mut self,
892+ event: &Self::Event,
893+ _: &mut ViewContext<Self>,
894+ ) -> Option<SearchEvent> {
891895 match event {
892896 Event::BufferEdited => Some(SearchEvent::MatchesInvalidated),
893− Event::SelectionsChanged { .. } => Some(SearchEvent::ActiveMatchChanged),
897+ Event::SelectionsChanged { .. } => {
898+ if self.selections.disjoint_anchors().len() == 1 {
899+ Some(SearchEvent::ActiveMatchChanged)
900+ } else {
901+ None
902+ }
903+ }
894904 _ => None,
895905 }
896906 }
@@ -941,6 +951,11 @@ impl SearchableItem for Editor { · 44 unmodified lines
941951 });
942952 }
943953
954+ fn select_matches(&mut self, matches: Vec<Self::Match>, cx: &mut ViewContext<Self>) {
955+ self.unfold_ranges(matches.clone(), false, false, cx);
956+ self.change_selections(None, cx, |s| s.select_ranges(matches));
957+ }
958+
944959 fn match_index_for_direction(
945960 &mut self,
946961 matches: &Vec<Range<Anchor>>,
@@ -949,8 +964,16 @@ impl SearchableItem for Editor { · 2 unmodified lines
949964 cx: &mut ViewContext<Self>,
950965 ) -> usize {
951966 let buffer = self.buffer().read(cx).snapshot(cx);
952− let cursor = self.selections.newest_anchor().head();
953− if matches[current_index].start.cmp(&cursor, &buffer).is_gt() {
967+ let current_index_position = if self.selections.disjoint_anchors().len() == 1 {
968+ self.selections.newest_anchor().head()
969+ } else {
970+ matches[current_index].start
971+ };
972+ if matches[current_index]
973+ .start
974+ .cmp(&current_index_position, &buffer)
975+ .is_gt()
976+ {
954977 if direction == Direction::Prev {
955978 if current_index == 0 {
956979 current_index = matches.len() - 1;
@@ -958,7 +981,11 @@ impl SearchableItem for Editor { · 1 unmodified line
958981 current_index -= 1;
959982 }
960983 }
961− } else if matches[current_index].end.cmp(&cursor, &buffer).is_lt() {
984+ } else if matches[current_index]
985+ .end
986+ .cmp(&current_index_position, &buffer)
987+ .is_lt()
988+ {
962989 if direction == Direction::Next {
963990 current_index = 0;
964991 }
crates/editor/src/link_go_to_definition.rs+9−6
@@ -246,23 +246,26 @@ pub fn hide_link_definition(editor: &mut Editor, cx: &mut ViewContext<Editor>) { · 245 unmodified lines
246246 pub fn go_to_fetched_definition(
247247 editor: &mut Editor,
248248 point: DisplayPoint,
249+ split: bool,
249250 cx: &mut ViewContext<Editor>,
250251 ) {
251− go_to_fetched_definition_of_kind(LinkDefinitionKind::Symbol, editor, point, cx);
252+ go_to_fetched_definition_of_kind(LinkDefinitionKind::Symbol, editor, point, split, cx);
252253 }
253254
254255 pub fn go_to_fetched_type_definition(
255256 editor: &mut Editor,
256257 point: DisplayPoint,
258+ split: bool,
257259 cx: &mut ViewContext<Editor>,
258260 ) {
259− go_to_fetched_definition_of_kind(LinkDefinitionKind::Type, editor, point, cx);
261+ go_to_fetched_definition_of_kind(LinkDefinitionKind::Type, editor, point, split, cx);
260262 }
261263
262264 fn go_to_fetched_definition_of_kind(
263265 kind: LinkDefinitionKind,
264266 editor: &mut Editor,
265267 point: DisplayPoint,
268+ split: bool,
266269 cx: &mut ViewContext<Editor>,
267270 ) {
268271 let cached_definitions = editor.link_go_to_definition_state.definitions.clone();
@@ -275,7 +278,7 @@ fn go_to_fetched_definition_of_kind( · 6 unmodified lines
275278 cx.focus_self();
276279 }
277280
278− editor.navigate_to_definitions(cached_definitions, cx);
281+ editor.navigate_to_definitions(cached_definitions, split, cx);
279282 } else {
280283 editor.select(
281284 SelectPhase::Begin {
@@ -403,7 +406,7 @@ mod tests { · 121 unmodified lines
403406 });
404407
405408 cx.update_editor(|editor, cx| {
406− go_to_fetched_type_definition(editor, hover_point, cx);
409+ go_to_fetched_type_definition(editor, hover_point, false, cx);
407410 });
408411 requests.next().await;
409412 cx.foreground().run_until_parked();
@@ -614,7 +617,7 @@ mod tests { · 204 unmodified lines
614617
615618 // Cmd click with existing definition doesn't re-request and dismisses highlight
616619 cx.update_editor(|editor, cx| {
617− go_to_fetched_definition(editor, hover_point, cx);
620+ go_to_fetched_definition(editor, hover_point, false, cx);
618621 });
619622 // Assert selection moved to to definition
620623 cx.lsp
@@ -655,7 +658,7 @@ mod tests { · 34 unmodified lines
655658 ])))
656659 });
657660 cx.update_editor(|editor, cx| {
658− go_to_fetched_definition(editor, hover_point, cx);
661+ go_to_fetched_definition(editor, hover_point, false, cx);
659662 });
660663 requests.next().await;
661664 cx.foreground().run_until_parked();
crates/editor/src/selections_collection.rs+2−2
@@ -16,13 +16,13 @@ use crate::{ · 15 unmodified lines
1616 Anchor, DisplayPoint, ExcerptId, MultiBuffer, MultiBufferSnapshot, SelectMode, ToOffset,
1717 };
1818
19−#[derive(Clone)]
19+#[derive(Debug, Clone)]
2020 pub struct PendingSelection {
2121 pub selection: Selection<Anchor>,
2222 pub mode: SelectMode,
2323 }
2424
25−#[derive(Clone)]
25+#[derive(Debug, Clone)]
2626 pub struct SelectionsCollection {
2727 display_map: ModelHandle<DisplayMap>,
2828 buffer: ModelHandle<MultiBuffer>,
crates/feedback/src/feedback_editor.rs+31−3
@@ -60,6 +60,7 @@ pub(crate) struct FeedbackEditor { · 59 unmodified lines
6060 system_specs: SystemSpecs,
6161 editor: ViewHandle<Editor>,
6262 project: ModelHandle<Project>,
63+ pub allow_submission: bool,
6364 }
6465
6566 impl FeedbackEditor {
@@ -82,10 +83,15 @@ impl FeedbackEditor { · 16 unmodified lines
8283 system_specs: system_specs.clone(),
8384 editor,
8485 project,
86+ allow_submission: true,
8587 }
8688 }
8789
8890 pub fn submit(&mut self, cx: &mut ViewContext<Self>) -> Task<anyhow::Result<()>> {
91+ if !self.allow_submission {
92+ return Task::ready(Ok(()));
93+ }
94+
8995 let feedback_text = self.editor.read(cx).text(cx);
9096 let feedback_char_count = feedback_text.chars().count();
9197 let feedback_text = feedback_text.trim().to_string();
@@ -122,19 +128,26 @@ impl FeedbackEditor { · 30 unmodified lines
122128 let answer = answer.recv().await;
123129
124130 if answer == Some(0) {
131+ this.update(&mut cx, |feedback_editor, cx| {
132+ feedback_editor.set_allow_submission(false, cx);
133+ })
134+ .log_err();
135+
125136 match FeedbackEditor::submit_feedback(&feedback_text, client, specs).await {
126137 Ok(_) => {
127138 this.update(&mut cx, |_, cx| cx.emit(editor::Event::Closed))
128139 .log_err();
129140 }
141+
130142 Err(error) => {
131143 log::error!("{}", error);
132− this.update(&mut cx, |_, cx| {
144+ this.update(&mut cx, |feedback_editor, cx| {
133145 cx.prompt(
134146 PromptLevel::Critical,
135147 FEEDBACK_SUBMISSION_ERROR_TEXT,
136148 &["OK"],
137149 );
150+ feedback_editor.set_allow_submission(true, cx);
138151 })
139152 .log_err();
140153 }
@@ -146,6 +159,11 @@ impl FeedbackEditor { · 5 unmodified lines
146159 Task::ready(Ok(()))
147160 }
148161
162+ fn set_allow_submission(&mut self, allow_submission: bool, cx: &mut ViewContext<Self>) {
163+ self.allow_submission = allow_submission;
164+ cx.notify();
165+ }
166+
149167 async fn submit_feedback(
150168 feedback_text: &str,
151169 zed_client: Arc<Client>,
@@ -362,8 +380,13 @@ impl Item for FeedbackEditor { · 210 unmodified lines
362380 impl SearchableItem for FeedbackEditor {
363381 type Match = Range<Anchor>;
364382
365− fn to_search_event(event: &Self::Event) -> Option<workspace::searchable::SearchEvent> {
366− Editor::to_search_event(event)
383+ fn to_search_event(
384+ &mut self,
385+ event: &Self::Event,
386+ cx: &mut ViewContext<Self>,
387+ ) -> Option<workspace::searchable::SearchEvent> {
388+ self.editor
389+ .update(cx, |editor, cx| editor.to_search_event(event, cx))
367390 }
368391
369392 fn clear_matches(&mut self, cx: &mut ViewContext<Self>) {
@@ -391,6 +414,11 @@ impl SearchableItem for FeedbackEditor { · 21 unmodified lines
391414 .update(cx, |editor, cx| editor.activate_match(index, matches, cx))
392415 }
393416
417+ fn select_matches(&mut self, matches: Vec<Self::Match>, cx: &mut ViewContext<Self>) {
418+ self.editor
419+ .update(cx, |e, cx| e.select_matches(matches, cx))
420+ }
421+
394422 fn find_matches(
395423 &mut self,
396424 query: project::search::SearchQuery,
crates/feedback/src/submit_feedback_button.rs+20−2
@@ -46,10 +46,28 @@ impl View for SubmitFeedbackButton { · 45 unmodified lines
4646
4747 fn render(&mut self, cx: &mut ViewContext<Self>) -> AnyElement<Self> {
4848 let theme = theme::current(cx).clone();
49+ let allow_submission = self
50+ .active_item
51+ .as_ref()
52+ .map_or(true, |i| i.read(cx).allow_submission);
53+
4954 enum SubmitFeedbackButton {}
5055 MouseEventHandler::<SubmitFeedbackButton, Self>::new(0, cx, |state, _| {
51− let style = theme.feedback.submit_button.style_for(state);
52− Label::new("Submit as Markdown", style.text.clone())
56+ let text;
57+ let style = if allow_submission {
58+ text = "Submit as Markdown";
59+ theme.feedback.submit_button.style_for(state)
60+ } else {
61+ text = "Submitting...";
62+ theme
63+ .feedback
64+ .submit_button
65+ .disabled
66+ .as_ref()
67+ .unwrap_or(&theme.feedback.submit_button.default)
68+ };
69+
70+ Label::new(text, style.text.clone())
5371 .contained()
5472 .with_style(style.container)
5573 })
crates/file_finder/src/file_finder.rs+54−36
@@ -442,53 +442,71 @@ impl PickerDelegate for FileFinderDelegate { · 441 unmodified lines
442442 }
443443 }
444444
445− fn confirm(&mut self, cx: &mut ViewContext<FileFinder>) {
445+ fn confirm(&mut self, secondary: bool, cx: &mut ViewContext<FileFinder>) {
446446 if let Some(m) = self.matches.get(self.selected_index()) {
447447 if let Some(workspace) = self.workspace.upgrade(cx) {
448− let open_task = workspace.update(cx, |workspace, cx| match m {
449− Match::History(history_match) => {
450− let worktree_id = history_match.project.worktree_id;
451− if workspace
452− .project()
453− .read(cx)
454− .worktree_for_id(worktree_id, cx)
455− .is_some()
456− {
457− workspace.open_path(
458− ProjectPath {
459− worktree_id,
460− path: Arc::clone(&history_match.project.path),
461− },
462− None,
463− true,
464− cx,
465− )
448+ let open_task = workspace.update(cx, move |workspace, cx| {
449+ let split_or_open = |workspace: &mut Workspace, project_path, cx| {
450+ if secondary {
451+ workspace.split_path(project_path, cx)
466452 } else {
467− match history_match.absolute.as_ref() {
468− Some(abs_path) => {
469− workspace.open_abs_path(abs_path.to_path_buf(), false, cx)
470− }
471− None => workspace.open_path(
453+ workspace.open_path(project_path, None, true, cx)
454+ }
455+ };
456+ match m {
457+ Match::History(history_match) => {
458+ let worktree_id = history_match.project.worktree_id;
459+ if workspace
460+ .project()
461+ .read(cx)
462+ .worktree_for_id(worktree_id, cx)
463+ .is_some()
464+ {
465+ split_or_open(
466+ workspace,
472467 ProjectPath {
473468 worktree_id,
474469 path: Arc::clone(&history_match.project.path),
475470 },
476− None,
477− true,
478471 cx,
479− ),
472+ )
473+ } else {
474+ match history_match.absolute.as_ref() {
475+ Some(abs_path) => {
476+ if secondary {
477+ workspace.split_abs_path(
478+ abs_path.to_path_buf(),
479+ false,
480+ cx,
481+ )
482+ } else {
483+ workspace.open_abs_path(
484+ abs_path.to_path_buf(),
485+ false,
486+ cx,
487+ )
488+ }
489+ }
490+ None => split_or_open(
491+ workspace,
492+ ProjectPath {
493+ worktree_id,
494+ path: Arc::clone(&history_match.project.path),
495+ },
496+ cx,
497+ ),
498+ }
480499 }
481500 }
501+ Match::Search(m) => split_or_open(
502+ workspace,
503+ ProjectPath {
504+ worktree_id: WorktreeId::from_usize(m.worktree_id),
505+ path: m.path.clone(),
506+ },
507+ cx,
508+ ),
482509 }
483− Match::Search(m) => workspace.open_path(
484− ProjectPath {
485− worktree_id: WorktreeId::from_usize(m.worktree_id),
486− path: m.path.clone(),
487− },
488− None,
489− true,
490− cx,
491− ),
492510 });
493511
494512 let row = self
crates/fs/src/repository.rs+1−0
@@ -33,6 +33,7 @@ pub trait GitRepository: Send { · 32 unmodified lines
3333 fn statuses(&self) -> Option<TreeMap<RepoPath, GitFileStatus>>;
3434
3535 fn status(&self, path: &RepoPath) -> Result<Option<GitFileStatus>>;
36+
3637 fn branches(&self) -> Result<Vec<Branch>> {
3738 Ok(vec![])
3839 }
crates/gpui/src/app.rs+6−6
@@ -1073,7 +1073,7 @@ impl AppContext { · 1072 unmodified lines
10731073
10741074 pub fn is_action_available(&self, action: &dyn Action) -> bool {
10751075 let mut available_in_window = false;
1076− let action_type = action.as_any().type_id();
1076+ let action_id = action.id();
10771077 if let Some(window_id) = self.platform.main_window_id() {
10781078 available_in_window = self
10791079 .read_window(window_id, |cx| {
@@ -1083,7 +1083,7 @@ impl AppContext { · 3 unmodified lines
10831083 cx.views_metadata.get(&(window_id, view_id))
10841084 {
10851085 if let Some(actions) = cx.actions.get(&view_metadata.type_id) {
1086− if actions.contains_key(&action_type) {
1086+ if actions.contains_key(&action_id) {
10871087 return true;
10881088 }
10891089 }
@@ -1094,7 +1094,7 @@ impl AppContext { · 4 unmodified lines
10941094 })
10951095 .unwrap_or(false);
10961096 }
1097− available_in_window || self.global_actions.contains_key(&action_type)
1097+ available_in_window || self.global_actions.contains_key(&action_id)
10981098 }
10991099
11001100 fn actions_mut(
@@ -3399,7 +3399,7 @@ impl<'a, 'b, 'c, V: View> LayoutContext<'a, 'b, 'c, V> { · 2298 unmodified lines
33993399 for (i, view_id) in self.ancestors(view_id).enumerate() {
34003400 if let Some(view_metadata) = self.views_metadata.get(&(window_id, view_id)) {
34013401 if let Some(actions) = self.actions.get(&view_metadata.type_id) {
3402− if actions.contains_key(&action.as_any().type_id()) {
3402+ if actions.contains_key(&action.id()) {
34033403 handler_depth = Some(i);
34043404 }
34053405 }
@@ -3407,12 +3407,12 @@ impl<'a, 'b, 'c, V: View> LayoutContext<'a, 'b, 'c, V> { · 1 unmodified line
34073407 }
34083408 }
34093409
3410− if self.global_actions.contains_key(&action.as_any().type_id()) {
3410+ if self.global_actions.contains_key(&action.id()) {
34113411 handler_depth = Some(contexts.len())
34123412 }
34133413
34143414 self.keystroke_matcher
3415− .bindings_for_action_type(action.as_any().type_id())
3415+ .bindings_for_action(action.id())
34163416 .find_map(|b| {
34173417 let highest_handler = handler_depth?;
34183418 if action.eq(b.action())
crates/gpui/src/app/window.rs+23−18
@@ -14,8 +14,8 @@ use crate::{ · 13 unmodified lines
1414 text_layout::TextLayoutCache,
1515 util::post_inc,
1616 Action, AnyView, AnyViewHandle, AppContext, BorrowAppContext, BorrowWindowContext, Effect,
17− Element, Entity, Handle, LayoutContext, MouseRegion, MouseRegionId, NoAction, SceneBuilder,
18− Subscription, View, ViewContext, ViewHandle, WindowInvalidation,
17+ Element, Entity, Handle, LayoutContext, MouseRegion, MouseRegionId, SceneBuilder, Subscription,
18+ View, ViewContext, ViewHandle, WindowInvalidation,
1919 };
2020 use anyhow::{anyhow, bail, Result};
2121 use collections::{HashMap, HashSet};
@@ -363,17 +363,13 @@ impl<'a> WindowContext<'a> { · 341 unmodified lines
363363 ) -> Vec<(&'static str, Box<dyn Action>, SmallVec<[Binding; 1]>)> {
364364 let window_id = self.window_id;
365365 let mut contexts = Vec::new();
366− let mut handler_depths_by_action_type = HashMap::<TypeId, usize>::default();
366+ let mut handler_depths_by_action_id = HashMap::<TypeId, usize>::default();
367367 for (depth, view_id) in self.ancestors(view_id).enumerate() {
368368 if let Some(view_metadata) = self.views_metadata.get(&(window_id, view_id)) {
369369 contexts.push(view_metadata.keymap_context.clone());
370370 if let Some(actions) = self.actions.get(&view_metadata.type_id) {
371− handler_depths_by_action_type.extend(
372− actions
373− .keys()
374− .copied()
375− .map(|action_type| (action_type, depth)),
376− );
371+ handler_depths_by_action_id
372+ .extend(actions.keys().copied().map(|action_id| (action_id, depth)));
377373 }
378374 } else {
379375 log::error!(
@@ -383,21 +379,21 @@ impl<'a> WindowContext<'a> { · 3 unmodified lines
383379 }
384380 }
385381
386− handler_depths_by_action_type.extend(
382+ handler_depths_by_action_id.extend(
387383 self.global_actions
388384 .keys()
389385 .copied()
390− .map(|action_type| (action_type, contexts.len())),
386+ .map(|action_id| (action_id, contexts.len())),
391387 );
392388
393389 self.action_deserializers
394390 .iter()
395− .filter_map(move |(name, (type_id, deserialize))| {
396− if let Some(action_depth) = handler_depths_by_action_type.get(type_id).copied() {
391+ .filter_map(move |(name, (action_id, deserialize))| {
392+ if let Some(action_depth) = handler_depths_by_action_id.get(action_id).copied() {
397393 let action = deserialize(serde_json::Value::Object(Default::default())).ok()?;
398394 let bindings = self
399395 .keystroke_matcher
400− .bindings_for_action_type(*type_id)
396+ .bindings_for_action(*action_id)
401397 .filter(|b| {
402398 action.eq(b.action())
403399 && (0..=action_depth)
@@ -434,11 +430,7 @@ impl<'a> WindowContext<'a> { · 30 unmodified lines
434430 MatchResult::None => false,
435431 MatchResult::Pending => true,
436432 MatchResult::Matches(matches) => {
437− let no_action_id = (NoAction {}).id();
438433 for (view_id, action) in matches {
439− if action.id() == no_action_id {
440− return false;
441− }
442434 if self.dispatch_action(Some(*view_id), action.as_ref()) {
443435 self.keystroke_matcher.clear_pending();
444436 handled_by = Some(action.boxed_clone());
@@ -1268,6 +1260,19 @@ impl Vector2FExt for Vector2F { · 823 unmodified lines
12681260 }
12691261 }
12701262
1263+pub trait RectFExt {
1264+ fn length_along(self, axis: Axis) -> f32;
1265+}
1266+
1267+impl RectFExt for RectF {
1268+ fn length_along(self, axis: Axis) -> f32 {
1269+ match axis {
1270+ Axis::Horizontal => self.width(),
1271+ Axis::Vertical => self.height(),
1272+ }
1273+ }
1274+}
1275+
12711276 #[derive(Copy, Clone, Debug)]
12721277 pub struct SizeConstraint {
12731278 pub min: Vector2F,
crates/gpui/src/gpui.rs+1−1
@@ -27,7 +27,7 @@ pub mod json; · 26 unmodified lines
2727 pub mod keymap_matcher;
2828 pub mod platform;
2929 pub use gpui_macros::{test, Element};
30−pub use window::{Axis, SizeConstraint, Vector2FExt, WindowContext};
30+pub use window::{Axis, RectFExt, SizeConstraint, Vector2FExt, WindowContext};
3131
3232 pub use anyhow;
3333 pub use serde_json;
crates/gpui/src/keymap_matcher.rs+7−4
@@ -8,7 +8,7 @@ use std::{any::TypeId, fmt::Debug}; · 7 unmodified lines
88 use collections::HashMap;
99 use smallvec::SmallVec;
1010
11−use crate::Action;
11+use crate::{Action, NoAction};
1212
1313 pub use binding::{Binding, BindingMatchResult};
1414 pub use keymap::Keymap;
@@ -47,8 +47,8 @@ impl KeymapMatcher { · 32 unmodified lines
4747 self.keymap.clear();
4848 }
4949
50− pub fn bindings_for_action_type(&self, action_type: TypeId) -> impl Iterator<Item = &Binding> {
51− self.keymap.bindings_for_action_type(action_type)
50+ pub fn bindings_for_action(&self, action_id: TypeId) -> impl Iterator<Item = &Binding> {
51+ self.keymap.bindings_for_action(action_id)
5252 }
5353
5454 pub fn clear_pending(&mut self) {
@@ -81,6 +81,7 @@ impl KeymapMatcher { · 26 unmodified lines
8181 // The key is the reverse position of the binding in the bindings list so that later bindings
8282 // match before earlier ones in the user's config
8383 let mut matched_bindings: Vec<(usize, Box<dyn Action>)> = Default::default();
84+ let no_action_id = (NoAction {}).id();
8485
8586 let first_keystroke = self.pending_keystrokes.is_empty();
8687 self.pending_keystrokes.push(keystroke.clone());
@@ -108,7 +109,9 @@ impl KeymapMatcher { · 21 unmodified lines
108109 match binding.match_keys_and_context(&self.pending_keystrokes, &self.contexts[i..])
109110 {
110111 BindingMatchResult::Complete(action) => {
111− matched_bindings.push((*view_id, action));
112+ if action.id() != no_action_id {
113+ matched_bindings.push((*view_id, action));
114+ }
112115 }
113116 BindingMatchResult::Partial => {
114117 self.pending_views
crates/gpui/src/keymap_matcher/binding.rs+2−2
@@ -7,8 +7,8 @@ use super::{KeymapContext, KeymapContextPredicate, Keystroke}; · 6 unmodified lines
77
88 pub struct Binding {
99 action: Box<dyn Action>,
10− keystrokes: SmallVec<[Keystroke; 2]>,
11− context_predicate: Option<KeymapContextPredicate>,
10+ pub(super) keystrokes: SmallVec<[Keystroke; 2]>,
11+ pub(super) context_predicate: Option<KeymapContextPredicate>,
1212 }
1313
1414 impl std::fmt::Debug for Binding {
crates/gpui/src/keymap_matcher/keymap.rs+358−31
@@ -1,61 +1,388 @@
1+use collections::HashSet;
12 use smallvec::SmallVec;
2−use std::{
3− any::{Any, TypeId},
4− collections::HashMap,
5−};
3+use std::{any::TypeId, collections::HashMap};
64
7−use super::Binding;
5+use crate::{Action, NoAction};
6+
7+use super::{Binding, KeymapContextPredicate, Keystroke};
88
99 #[derive(Default)]
1010 pub struct Keymap {
1111 bindings: Vec<Binding>,
12− binding_indices_by_action_type: HashMap<TypeId, SmallVec<[usize; 3]>>,
12+ binding_indices_by_action_id: HashMap<TypeId, SmallVec<[usize; 3]>>,
13+ disabled_keystrokes: HashMap<SmallVec<[Keystroke; 2]>, HashSet<Option<KeymapContextPredicate>>>,
1314 }
1415
1516 impl Keymap {
16− pub fn new(bindings: Vec<Binding>) -> Self {
17− let mut binding_indices_by_action_type = HashMap::new();
18− for (ix, binding) in bindings.iter().enumerate() {
19− binding_indices_by_action_type
20− .entry(binding.action().type_id())
21− .or_insert_with(SmallVec::new)
22− .push(ix);
23− }
24−
25− Self {
26− binding_indices_by_action_type,
27− bindings,
28− }
17+ #[cfg(test)]
18+ pub(super) fn new(bindings: Vec<Binding>) -> Self {
19+ let mut this = Self::default();
20+ this.add_bindings(bindings);
21+ this
2922 }
3023
31− pub(crate) fn bindings_for_action_type(
24+ pub(crate) fn bindings_for_action(
3225 &self,
33− action_type: TypeId,
26+ action_id: TypeId,
3427 ) -> impl Iterator<Item = &'_ Binding> {
35− self.binding_indices_by_action_type
36− .get(&action_type)
28+ self.binding_indices_by_action_id
29+ .get(&action_id)
3730 .map(SmallVec::as_slice)
3831 .unwrap_or(&[])
3932 .iter()
4033 .map(|ix| &self.bindings[*ix])
34+ .filter(|binding| !self.binding_disabled(binding))
4135 }
4236
4337 pub(crate) fn add_bindings<T: IntoIterator<Item = Binding>>(&mut self, bindings: T) {
38+ let no_action_id = (NoAction {}).id();
39+ let mut new_bindings = Vec::new();
40+ let mut has_new_disabled_keystrokes = false;
4441 for binding in bindings {
45− self.binding_indices_by_action_type
46− .entry(binding.action().as_any().type_id())
47− .or_default()
48− .push(self.bindings.len());
49− self.bindings.push(binding);
42+ if binding.action().id() == no_action_id {
43+ has_new_disabled_keystrokes |= self
44+ .disabled_keystrokes
45+ .entry(binding.keystrokes)
46+ .or_default()
47+ .insert(binding.context_predicate);
48+ } else {
49+ new_bindings.push(binding);
50+ }
51+ }
52+
53+ if has_new_disabled_keystrokes {
54+ self.binding_indices_by_action_id.retain(|_, indices| {
55+ indices.retain(|ix| {
56+ let binding = &self.bindings[*ix];
57+ match self.disabled_keystrokes.get(&binding.keystrokes) {
58+ Some(disabled_predicates) => {
59+ !disabled_predicates.contains(&binding.context_predicate)
60+ }
61+ None => true,
62+ }
63+ });
64+ !indices.is_empty()
65+ });
66+ }
67+
68+ for new_binding in new_bindings {
69+ if !self.binding_disabled(&new_binding) {
70+ self.binding_indices_by_action_id
71+ .entry(new_binding.action().id())
72+ .or_default()
73+ .push(self.bindings.len());
74+ self.bindings.push(new_binding);
75+ }
5076 }
5177 }
5278
5379 pub(crate) fn clear(&mut self) {
5480 self.bindings.clear();
55− self.binding_indices_by_action_type.clear();
81+ self.binding_indices_by_action_id.clear();
82+ self.disabled_keystrokes.clear();
83+ }
84+
85+ pub fn bindings(&self) -> Vec<&Binding> {
86+ self.bindings
87+ .iter()
88+ .filter(|binding| !self.binding_disabled(binding))
89+ .collect()
90+ }
91+
92+ fn binding_disabled(&self, binding: &Binding) -> bool {
93+ match self.disabled_keystrokes.get(&binding.keystrokes) {
94+ Some(disabled_predicates) => disabled_predicates.contains(&binding.context_predicate),
95+ None => false,
96+ }
97+ }
98+}
99+
100+#[cfg(test)]
101+mod tests {
102+ use crate::actions;
103+
104+ use super::*;
105+
106+ actions!(
107+ keymap_test,
108+ [Present1, Present2, Present3, Duplicate, Missing]
109+ );
110+
111+ #[test]
112+ fn regular_keymap() {
113+ let present_1 = Binding::new("ctrl-q", Present1 {}, None);
114+ let present_2 = Binding::new("ctrl-w", Present2 {}, Some("pane"));
115+ let present_3 = Binding::new("ctrl-e", Present3 {}, Some("editor"));
116+ let keystroke_duplicate_to_1 = Binding::new("ctrl-q", Duplicate {}, None);
117+ let full_duplicate_to_2 = Binding::new("ctrl-w", Present2 {}, Some("pane"));
118+ let missing = Binding::new("ctrl-r", Missing {}, None);
119+ let all_bindings = [
120+ &present_1,
121+ &present_2,
122+ &present_3,
123+ &keystroke_duplicate_to_1,
124+ &full_duplicate_to_2,
125+ &missing,
126+ ];
127+
128+ let mut keymap = Keymap::default();
129+ assert_absent(&keymap, &all_bindings);
130+ assert!(keymap.bindings().is_empty());
131+
132+ keymap.add_bindings([present_1.clone(), present_2.clone(), present_3.clone()]);
133+ assert_absent(&keymap, &[&keystroke_duplicate_to_1, &missing]);
134+ assert_present(
135+ &keymap,
136+ &[(&present_1, "q"), (&present_2, "w"), (&present_3, "e")],
137+ );
138+
139+ keymap.add_bindings([
140+ keystroke_duplicate_to_1.clone(),
141+ full_duplicate_to_2.clone(),
142+ ]);
143+ assert_absent(&keymap, &[&missing]);
144+ assert!(
145+ !keymap.binding_disabled(&keystroke_duplicate_to_1),
146+ "Duplicate binding 1 was added and should not be disabled"
147+ );
148+ assert!(
149+ !keymap.binding_disabled(&full_duplicate_to_2),
150+ "Duplicate binding 2 was added and should not be disabled"
151+ );
152+
153+ assert_eq!(
154+ keymap
155+ .bindings_for_action(keystroke_duplicate_to_1.action().id())
156+ .map(|binding| &binding.keystrokes)
157+ .flatten()
158+ .collect::<Vec<_>>(),
159+ vec![&Keystroke {
160+ ctrl: true,
161+ alt: false,
162+ shift: false,
163+ cmd: false,
164+ function: false,
165+ key: "q".to_string()
166+ }],
167+ "{keystroke_duplicate_to_1:?} should have the expected keystroke in the keymap"
168+ );
169+ assert_eq!(
170+ keymap
171+ .bindings_for_action(full_duplicate_to_2.action().id())
172+ .map(|binding| &binding.keystrokes)
173+ .flatten()
174+ .collect::<Vec<_>>(),
175+ vec![
176+ &Keystroke {
177+ ctrl: true,
178+ alt: false,
179+ shift: false,
180+ cmd: false,
181+ function: false,
182+ key: "w".to_string()
183+ },
184+ &Keystroke {
185+ ctrl: true,
186+ alt: false,
187+ shift: false,
188+ cmd: false,
189+ function: false,
190+ key: "w".to_string()
191+ }
192+ ],
193+ "{full_duplicate_to_2:?} should have a duplicated keystroke in the keymap"
194+ );
195+
196+ let updated_bindings = keymap.bindings();
197+ let expected_updated_bindings = vec![
198+ &present_1,
199+ &present_2,
200+ &present_3,
201+ &keystroke_duplicate_to_1,
202+ &full_duplicate_to_2,
203+ ];
204+ assert_eq!(
205+ updated_bindings.len(),
206+ expected_updated_bindings.len(),
207+ "Unexpected updated keymap bindings {updated_bindings:?}"
208+ );
209+ for (i, expected) in expected_updated_bindings.iter().enumerate() {
210+ let keymap_binding = &updated_bindings[i];
211+ assert_eq!(
212+ keymap_binding.context_predicate, expected.context_predicate,
213+ "Unexpected context predicate for keymap {i} element: {keymap_binding:?}"
214+ );
215+ assert_eq!(
216+ keymap_binding.keystrokes, expected.keystrokes,
217+ "Unexpected keystrokes for keymap {i} element: {keymap_binding:?}"
218+ );
219+ }
220+
221+ keymap.clear();
222+ assert_absent(&keymap, &all_bindings);
223+ assert!(keymap.bindings().is_empty());
56224 }
57225
58− pub fn bindings(&self) -> &Vec<Binding> {
59− &self.bindings
226+ #[test]
227+ fn keymap_with_ignored() {
228+ let present_1 = Binding::new("ctrl-q", Present1 {}, None);
229+ let present_2 = Binding::new("ctrl-w", Present2 {}, Some("pane"));
230+ let present_3 = Binding::new("ctrl-e", Present3 {}, Some("editor"));
231+ let keystroke_duplicate_to_1 = Binding::new("ctrl-q", Duplicate {}, None);
232+ let full_duplicate_to_2 = Binding::new("ctrl-w", Present2 {}, Some("pane"));
233+ let ignored_1 = Binding::new("ctrl-q", NoAction {}, None);
234+ let ignored_2 = Binding::new("ctrl-w", NoAction {}, Some("pane"));
235+ let ignored_3_with_other_context =
236+ Binding::new("ctrl-e", NoAction {}, Some("other_context"));
237+
238+ let mut keymap = Keymap::default();
239+
240+ keymap.add_bindings([
241+ ignored_1.clone(),
242+ ignored_2.clone(),
243+ ignored_3_with_other_context.clone(),
244+ ]);
245+ assert_absent(&keymap, &[&present_3]);
246+ assert_disabled(
247+ &keymap,
248+ &[
249+ &present_1,
250+ &present_2,
251+ &ignored_1,
252+ &ignored_2,
253+ &ignored_3_with_other_context,
254+ ],
255+ );
256+ assert!(keymap.bindings().is_empty());
257+ keymap.clear();
258+
259+ keymap.add_bindings([
260+ present_1.clone(),
261+ present_2.clone(),
262+ present_3.clone(),
263+ ignored_1.clone(),
264+ ignored_2.clone(),
265+ ignored_3_with_other_context.clone(),
266+ ]);
267+ assert_present(&keymap, &[(&present_3, "e")]);
268+ assert_disabled(
269+ &keymap,
270+ &[
271+ &present_1,
272+ &present_2,
273+ &ignored_1,
274+ &ignored_2,
275+ &ignored_3_with_other_context,
276+ ],
277+ );
278+ keymap.clear();
279+
280+ keymap.add_bindings([
281+ present_1.clone(),
282+ present_2.clone(),
283+ present_3.clone(),
284+ ignored_1.clone(),
285+ ]);
286+ assert_present(&keymap, &[(&present_2, "w"), (&present_3, "e")]);
287+ assert_disabled(&keymap, &[&present_1, &ignored_1]);
288+ assert_absent(&keymap, &[&ignored_2, &ignored_3_with_other_context]);
289+ keymap.clear();
290+
291+ keymap.add_bindings([
292+ present_1.clone(),
293+ present_2.clone(),
294+ present_3.clone(),
295+ keystroke_duplicate_to_1.clone(),
296+ full_duplicate_to_2.clone(),
297+ ignored_1.clone(),
298+ ignored_2.clone(),
299+ ignored_3_with_other_context.clone(),
300+ ]);
301+ assert_present(&keymap, &[(&present_3, "e")]);
302+ assert_disabled(
303+ &keymap,
304+ &[
305+ &present_1,
306+ &present_2,
307+ &keystroke_duplicate_to_1,
308+ &full_duplicate_to_2,
309+ &ignored_1,
310+ &ignored_2,
311+ &ignored_3_with_other_context,
312+ ],
313+ );
314+ keymap.clear();
315+ }
316+
317+ #[track_caller]
318+ fn assert_present(keymap: &Keymap, expected_bindings: &[(&Binding, &str)]) {
319+ let keymap_bindings = keymap.bindings();
320+ assert_eq!(
321+ expected_bindings.len(),
322+ keymap_bindings.len(),
323+ "Unexpected keymap bindings {keymap_bindings:?}"
324+ );
325+ for (i, (expected, expected_key)) in expected_bindings.iter().enumerate() {
326+ assert!(
327+ !keymap.binding_disabled(expected),
328+ "{expected:?} should not be disabled as it was added into keymap for element {i}"
329+ );
330+ assert_eq!(
331+ keymap
332+ .bindings_for_action(expected.action().id())
333+ .map(|binding| &binding.keystrokes)
334+ .flatten()
335+ .collect::<Vec<_>>(),
336+ vec![&Keystroke {
337+ ctrl: true,
338+ alt: false,
339+ shift: false,
340+ cmd: false,
341+ function: false,
342+ key: expected_key.to_string()
343+ }],
344+ "{expected:?} should have the expected keystroke with key '{expected_key}' in the keymap for element {i}"
345+ );
346+
347+ let keymap_binding = &keymap_bindings[i];
348+ assert_eq!(
349+ keymap_binding.context_predicate, expected.context_predicate,
350+ "Unexpected context predicate for keymap {i} element: {keymap_binding:?}"
351+ );
352+ assert_eq!(
353+ keymap_binding.keystrokes, expected.keystrokes,
354+ "Unexpected keystrokes for keymap {i} element: {keymap_binding:?}"
355+ );
356+ }
357+ }
358+
359+ #[track_caller]
360+ fn assert_absent(keymap: &Keymap, bindings: &[&Binding]) {
361+ for binding in bindings.iter() {
362+ assert!(
363+ !keymap.binding_disabled(binding),
364+ "{binding:?} should not be disabled in the keymap where was not added"
365+ );
366+ assert_eq!(
367+ keymap.bindings_for_action(binding.action().id()).count(),
368+ 0,
369+ "{binding:?} should have no actions in the keymap where was not added"
370+ );
371+ }
372+ }
373+
374+ #[track_caller]
375+ fn assert_disabled(keymap: &Keymap, bindings: &[&Binding]) {
376+ for binding in bindings.iter() {
377+ assert!(
378+ keymap.binding_disabled(binding),
379+ "{binding:?} should be disabled in the keymap"
380+ );
381+ assert_eq!(
382+ keymap.bindings_for_action(binding.action().id()).count(),
383+ 0,
384+ "{binding:?} should have no actions in the keymap where it was disabled"
385+ );
386+ }
60387 }
61388 }
crates/gpui/src/keymap_matcher/keymap_context.rs+1−1
@@ -44,7 +44,7 @@ impl KeymapContext { · 43 unmodified lines
4444 }
4545 }
4646
47−#[derive(Clone, Debug, Eq, PartialEq)]
47+#[derive(Clone, Debug, Eq, PartialEq, Hash)]
4848 pub enum KeymapContextPredicate {
4949 Identifier(String),
5050 Equal(String, String),
crates/gpui/src/keymap_matcher/keystroke.rs+1−1
@@ -3,7 +3,7 @@ use std::fmt::Write; · 2 unmodified lines
33 use anyhow::anyhow;
44 use serde::Deserialize;
55
6−#[derive(Clone, Debug, Eq, PartialEq, Default, Deserialize)]
6+#[derive(Clone, Debug, Eq, PartialEq, Default, Deserialize, Hash)]
77 pub struct Keystroke {
88 pub ctrl: bool,
99 pub alt: bool,
crates/gpui/src/platform/mac/platform.rs+1−1
@@ -231,7 +231,7 @@ impl MacForegroundPlatform { · 230 unmodified lines
231231 } => {
232232 // TODO
233233 let keystrokes = keystroke_matcher
234− .bindings_for_action_type(action.as_any().type_id())
234+ .bindings_for_action(action.id())
235235 .find(|binding| binding.action().eq(action.as_ref()))
236236 .map(|binding| binding.keystrokes());
237237 let selector = match os_action {
crates/language/Cargo.toml+14−12
@@ -46,7 +46,6 @@ lazy_static.workspace = true · 45 unmodified lines
4646 log.workspace = true
4747 parking_lot.workspace = true
4848 postage.workspace = true
49−rand = { workspace = true, optional = true }
5049 regex.workspace = true
5150 schemars.workspace = true
5251 serde.workspace = true
@@ -56,10 +55,12 @@ similar = "1.3" · 3 unmodified lines
5655 smallvec.workspace = true
5756 smol.workspace = true
5857 tree-sitter.workspace = true
59−tree-sitter-rust = { version = "*", optional = true }
60−tree-sitter-typescript = { version = "*", optional = true }
6158 unicase = "2.6"
6259
60+rand = { workspace = true, optional = true }
61+tree-sitter-rust = { workspace = true, optional = true }
62+tree-sitter-typescript = { workspace = true, optional = true }
63+
6364 [dev-dependencies]
6465 client = { path = "../client", features = ["test-support"] }
6566 collections = { path = "../collections", features = ["test-support"] }
@@ -74,12 +75,13 @@ indoc.workspace = true · 8 unmodified lines
7475 rand.workspace = true
7576 unindent.workspace = true
7677
77−tree-sitter-embedded-template = "*"
78−tree-sitter-html = "*"
79−tree-sitter-javascript = "*"
80−tree-sitter-json = "*"
81−tree-sitter-markdown = { git = "https://github.com/MDeiml/tree-sitter-markdown", rev = "330ecab87a3e3a7211ac69bbadc19eabecdb1cca" }
82−tree-sitter-rust = "*"
83−tree-sitter-python = "*"
84−tree-sitter-typescript = "*"
85−tree-sitter-ruby = "*"
78+tree-sitter-embedded-template.workspace = true
79+tree-sitter-html.workspace = true
80+tree-sitter-json.workspace = true
81+tree-sitter-markdown.workspace = true
82+tree-sitter-rust.workspace = true
83+tree-sitter-python.workspace = true
84+tree-sitter-typescript.workspace = true
85+tree-sitter-ruby.workspace = true
86+tree-sitter-elixir.workspace = true
87+tree-sitter-heex.workspace = true
crates/language/src/buffer.rs+19−15
@@ -2145,23 +2145,27 @@ impl BufferSnapshot { · 2144 unmodified lines
21452145
21462146 pub fn language_scope_at<D: ToOffset>(&self, position: D) -> Option<LanguageScope> {
21472147 let offset = position.to_offset(self);
2148+ let mut range = 0..self.len();
2149+ let mut scope = self.language.clone().map(|language| LanguageScope {
2150+ language,
2151+ override_id: None,
2152+ });
21482153
2149− if let Some(layer_info) = self
2150− .syntax
2151− .layers_for_range(offset..offset, &self.text)
2152− .filter(|l| l.node().end_byte() > offset)
2153− .last()
2154− {
2155− Some(LanguageScope {
2156− language: layer_info.language.clone(),
2157− override_id: layer_info.override_id(offset, &self.text),
2158− })
2159− } else {
2160− self.language.clone().map(|language| LanguageScope {
2161− language,
2162− override_id: None,
2163− })
2154+ // Use the layer that has the smallest node intersecting the given point.
2155+ for layer in self.syntax.layers_for_range(offset..offset, &self.text) {
2156+ let mut cursor = layer.node().walk();
2157+ while cursor.goto_first_child_for_byte(offset).is_some() {}
2158+ let node_range = cursor.node().byte_range();
2159+ if node_range.to_inclusive().contains(&offset) && node_range.len() < range.len() {
2160+ range = node_range;
2161+ scope = Some(LanguageScope {
2162+ language: layer.language.clone(),
2163+ override_id: layer.override_id(offset, &self.text),
2164+ });
2165+ }
21642166 }
2167+
2168+ scope
21652169 }
21662170
21672171 pub fn surrounding_word<T: ToOffset>(&self, start: T) -> (Range<usize>, Option<CharKind>) {
crates/language/src/buffer_tests.rs+115−43
@@ -1533,47 +1533,9 @@ fn test_autoindent_with_injected_languages(cx: &mut AppContext) { · 1532 unmodified lines
15331533 ])
15341534 });
15351535
1536− let html_language = Arc::new(
1537− Language::new(
1538− LanguageConfig {
1539− name: "HTML".into(),
1540− ..Default::default()
1541− },
1542− Some(tree_sitter_html::language()),
1543− )
1544− .with_indents_query(
1545− "
1546− (element
1547− (start_tag) @start
1548− (end_tag)? @end) @indent
1549− ",
1550− )
1551− .unwrap()
1552− .with_injection_query(
1553− r#"
1554− (script_element
1555− (raw_text) @content
1556− (#set! "language" "javascript"))
1557− "#,
1558− )
1559− .unwrap(),
1560− );
1536+ let html_language = Arc::new(html_lang());
15611537
1562− let javascript_language = Arc::new(
1563− Language::new(
1564− LanguageConfig {
1565− name: "JavaScript".into(),
1566− ..Default::default()
1567− },
1568− Some(tree_sitter_javascript::language()),
1569− )
1570− .with_indents_query(
1571− r#"
1572− (object "}" @end) @indent
1573− "#,
1574− )
1575− .unwrap(),
1576− );
1538+ let javascript_language = Arc::new(javascript_lang());
15771539
15781540 let language_registry = Arc::new(LanguageRegistry::test());
15791541 language_registry.add(html_language.clone());
@@ -1669,7 +1631,7 @@ fn test_autoindent_query_with_outdent_captures(cx: &mut AppContext) { · 89 unmodified lines
16691631 }
16701632
16711633 #[gpui::test]
1672−fn test_language_config_at(cx: &mut AppContext) {
1634+fn test_language_scope_at(cx: &mut AppContext) {
16731635 init_settings(cx, |_| {});
16741636
16751637 cx.add_model(|cx| {
@@ -1709,7 +1671,7 @@ fn test_language_config_at(cx: &mut AppContext) { · 33 unmodified lines
17091671 .collect(),
17101672 ..Default::default()
17111673 },
1712− Some(tree_sitter_javascript::language()),
1674+ Some(tree_sitter_typescript::language_tsx()),
17131675 )
17141676 .with_override_query(
17151677 r#"
@@ -1756,6 +1718,54 @@ fn test_language_config_at(cx: &mut AppContext) { · 40 unmodified lines
17561718 });
17571719 }
17581720
1721+#[gpui::test]
1722+fn test_language_scope_at_with_combined_injections(cx: &mut AppContext) {
1723+ init_settings(cx, |_| {});
1724+
1725+ cx.add_model(|cx| {
1726+ let text = r#"
1727+ <ol>
1728+ <% people.each do |person| %>
1729+ <li>
1730+ <%= person.name %>
1731+ </li>
1732+ <% end %>
1733+ </ol>
1734+ "#
1735+ .unindent();
1736+
1737+ let language_registry = Arc::new(LanguageRegistry::test());
1738+ language_registry.add(Arc::new(ruby_lang()));
1739+ language_registry.add(Arc::new(html_lang()));
1740+ language_registry.add(Arc::new(erb_lang()));
1741+
1742+ let mut buffer = Buffer::new(0, text, cx);
1743+ buffer.set_language_registry(language_registry.clone());
1744+ buffer.set_language(
1745+ language_registry
1746+ .language_for_name("ERB")
1747+ .now_or_never()
1748+ .unwrap()
1749+ .ok(),
1750+ cx,
1751+ );
1752+
1753+ let snapshot = buffer.snapshot();
1754+ let html_config = snapshot.language_scope_at(Point::new(2, 4)).unwrap();
1755+ assert_eq!(html_config.line_comment_prefix(), None);
1756+ assert_eq!(
1757+ html_config.block_comment_delimiters(),
1758+ Some((&"<!--".into(), &"-->".into()))
1759+ );
1760+
1761+ let ruby_config = snapshot.language_scope_at(Point::new(3, 12)).unwrap();
1762+ assert_eq!(ruby_config.line_comment_prefix().unwrap().as_ref(), "# ");
1763+ assert_eq!(ruby_config.block_comment_delimiters(), None);
1764+
1765+ buffer
1766+ });
1767+}
1768+
17591769 #[gpui::test]
17601770 fn test_serialization(cx: &mut gpui::AppContext) {
17611771 let mut now = Instant::now();
@@ -2143,6 +2153,7 @@ fn ruby_lang() -> Language { · 381 unmodified lines
21432153 LanguageConfig {
21442154 name: "Ruby".into(),
21452155 path_suffixes: vec!["rb".to_string()],
2156+ line_comment: Some("# ".into()),
21462157 ..Default::default()
21472158 },
21482159 Some(tree_sitter_ruby::language()),
@@ -2158,6 +2169,61 @@ fn ruby_lang() -> Language { · 9 unmodified lines
21582169 .unwrap()
21592170 }
21602171
2172+fn html_lang() -> Language {
2173+ Language::new(
2174+ LanguageConfig {
2175+ name: "HTML".into(),
2176+ block_comment: Some(("<!--".into(), "-->".into())),
2177+ ..Default::default()
2178+ },
2179+ Some(tree_sitter_html::language()),
2180+ )
2181+ .with_indents_query(
2182+ "
2183+ (element
2184+ (start_tag) @start
2185+ (end_tag)? @end) @indent
2186+ ",
2187+ )
2188+ .unwrap()
2189+ .with_injection_query(
2190+ r#"
2191+ (script_element
2192+ (raw_text) @content
2193+ (#set! "language" "javascript"))
2194+ "#,
2195+ )
2196+ .unwrap()
2197+}
2198+
2199+fn erb_lang() -> Language {
2200+ Language::new(
2201+ LanguageConfig {
2202+ name: "ERB".into(),
2203+ path_suffixes: vec!["erb".to_string()],
2204+ block_comment: Some(("<%#".into(), "%>".into())),
2205+ ..Default::default()
2206+ },
2207+ Some(tree_sitter_embedded_template::language()),
2208+ )
2209+ .with_injection_query(
2210+ r#"
2211+ (
2212+ (code) @content
2213+ (#set! "language" "ruby")
2214+ (#set! "combined")
2215+ )
2216+
2217+ (
2218+ (content) @content
2219+ (#set! "language" "html")
2220+ (#set! "combined")
2221+ )
2222+ "#,
2223+ )
2224+ .unwrap()
2225+}
2226+
21612227 fn rust_lang() -> Language {
21622228 Language::new(
21632229 LanguageConfig {
@@ -2227,7 +2293,7 @@ fn javascript_lang() -> Language { · 63 unmodified lines
22272293 name: "JavaScript".into(),
22282294 ..Default::default()
22292295 },
2230− Some(tree_sitter_javascript::language()),
2296+ Some(tree_sitter_typescript::language_tsx()),
22312297 )
22322298 .with_brackets_query(
22332299 r#"
@@ -2236,6 +2302,12 @@ fn javascript_lang() -> Language { · 2 unmodified lines
22362302 "#,
22372303 )
22382304 .unwrap()
2305+ .with_indents_query(
2306+ r#"
2307+ (object "}" @end) @indent
2308+ "#,
2309+ )
2310+ .unwrap()
22392311 }
22402312
22412313 fn get_tree_sexp(buffer: &ModelHandle<Buffer>, cx: &gpui::TestAppContext) -> String {
crates/language/src/language.rs+2−1
@@ -830,6 +830,7 @@ impl LanguageRegistry { · 829 unmodified lines
830830 Ok(language) => {
831831 let language = Arc::new(language);
832832 let mut state = this.state.write();
833+
833834 state.add(language.clone());
834835 state.mark_language_loaded(id);
835836 if let Some(mut txs) = state.loading_languages.remove(&id) {
@@ -1787,7 +1788,7 @@ mod tests { · 951 unmodified lines
17871788 first_line_pattern: Some(Regex::new(r"\bnode\b").unwrap()),
17881789 ..Default::default()
17891790 },
1790− tree_sitter_javascript::language(),
1791+ tree_sitter_typescript::language_tsx(),
17911792 vec![],
17921793 |_| Default::default(),
17931794 );
crates/language/src/syntax_map.rs+101−16
@@ -569,11 +569,19 @@ impl SyntaxSnapshot { · 568 unmodified lines
569569 range.end = range.end.saturating_sub(step_start_byte);
570570 }
571571
572− included_ranges = splice_included_ranges(
572+ let changed_indices;
573+ (included_ranges, changed_indices) = splice_included_ranges(
573574 old_tree.included_ranges(),
574575 &parent_layer_changed_ranges,
575576 &included_ranges,
576577 );
578+ insert_newlines_between_ranges(
579+ changed_indices,
580+ &mut included_ranges,
581+ &text,
582+ step_start_byte,
583+ step_start_point,
584+ );
577585 }
578586
579587 if included_ranges.is_empty() {
@@ -586,7 +594,7 @@ impl SyntaxSnapshot { · 6 unmodified lines
586594 }
587595
588596 log::trace!(
589− "update layer. language:{}, start:{:?}, ranges:{:?}",
597+ "update layer. language:{}, start:{:?}, included_ranges:{:?}",
590598 language.name(),
591599 LogAnchorRange(&step.range, text),
592600 LogIncludedRanges(&included_ranges),
@@ -608,6 +616,16 @@ impl SyntaxSnapshot { · 15 unmodified lines
608616 }),
609617 );
610618 } else {
619+ if matches!(step.mode, ParseMode::Combined { .. }) {
620+ insert_newlines_between_ranges(
621+ 0..included_ranges.len(),
622+ &mut included_ranges,
623+ text,
624+ step_start_byte,
625+ step_start_point,
626+ );
627+ }
628+
611629 if included_ranges.is_empty() {
612630 included_ranges.push(tree_sitter::Range {
613631 start_byte: 0,
@@ -771,8 +789,10 @@ impl SyntaxSnapshot { · 157 unmodified lines
771789 range: Range<T>,
772790 buffer: &'a BufferSnapshot,
773791 ) -> impl 'a + Iterator<Item = SyntaxLayerInfo> {
774− let start = buffer.anchor_before(range.start.to_offset(buffer));
775− let end = buffer.anchor_after(range.end.to_offset(buffer));
792+ let start_offset = range.start.to_offset(buffer);
793+ let end_offset = range.end.to_offset(buffer);
794+ let start = buffer.anchor_before(start_offset);
795+ let end = buffer.anchor_after(end_offset);
776796
777797 let mut cursor = self.layers.filter::<_, ()>(move |summary| {
778798 if summary.max_depth > summary.min_depth {
@@ -787,20 +807,21 @@ impl SyntaxSnapshot { · 8 unmodified lines
787807 cursor.next(buffer);
788808 iter::from_fn(move || {
789809 while let Some(layer) = cursor.item() {
810+ let mut info = None;
790811 if let SyntaxLayerContent::Parsed { tree, language } = &layer.content {
791− let info = SyntaxLayerInfo {
812+ let layer_start_offset = layer.range.start.to_offset(buffer);
813+ let layer_start_point = layer.range.start.to_point(buffer).to_ts_point();
814+
815+ info = Some(SyntaxLayerInfo {
792816 tree,
793817 language,
794818 depth: layer.depth,
795− offset: (
796− layer.range.start.to_offset(buffer),
797− layer.range.start.to_point(buffer).to_ts_point(),
798− ),
799− };
800− cursor.next(buffer);
801− return Some(info);
802− } else {
803− cursor.next(buffer);
819+ offset: (layer_start_offset, layer_start_point),
820+ });
821+ }
822+ cursor.next(buffer);
823+ if info.is_some() {
824+ return info;
804825 }
805826 }
806827 None
@@ -1272,14 +1293,20 @@ fn get_injections( · 465 unmodified lines
12721293 }
12731294 }
12741295
1296+/// Update the given list of included `ranges`, removing any ranges that intersect
1297+/// `removed_ranges`, and inserting the given `new_ranges`.
1298+///
1299+/// Returns a new vector of ranges, and the range of the vector that was changed,
1300+/// from the previous `ranges` vector.
12751301 pub(crate) fn splice_included_ranges(
12761302 mut ranges: Vec<tree_sitter::Range>,
12771303 removed_ranges: &[Range<usize>],
12781304 new_ranges: &[tree_sitter::Range],
1279−) -> Vec<tree_sitter::Range> {
1305+) -> (Vec<tree_sitter::Range>, Range<usize>) {
12801306 let mut removed_ranges = removed_ranges.iter().cloned().peekable();
12811307 let mut new_ranges = new_ranges.into_iter().cloned().peekable();
12821308 let mut ranges_ix = 0;
1309+ let mut changed_portion = usize::MAX..0;
12831310 loop {
12841311 let next_new_range = new_ranges.peek();
12851312 let next_removed_range = removed_ranges.peek();
@@ -1341,11 +1368,69 @@ pub(crate) fn splice_included_ranges( · 55 unmodified lines
13411368 }
13421369 }
13431370
1371+ changed_portion.start = changed_portion.start.min(start_ix);
1372+ changed_portion.end = changed_portion.end.max(if insert.is_some() {
1373+ start_ix + 1
1374+ } else {
1375+ start_ix
1376+ });
1377+
13441378 ranges.splice(start_ix..end_ix, insert);
13451379 ranges_ix = start_ix;
13461380 }
13471381
1348− ranges
1382+ if changed_portion.end < changed_portion.start {
1383+ changed_portion = 0..0;
1384+ }
1385+
1386+ (ranges, changed_portion)
1387+}
1388+
1389+/// Ensure there are newline ranges in between content range that appear on
1390+/// different lines. For performance, only iterate through the given range of
1391+/// indices. All of the ranges in the array are relative to a given start byte
1392+/// and point.
1393+fn insert_newlines_between_ranges(
1394+ indices: Range<usize>,
1395+ ranges: &mut Vec<tree_sitter::Range>,
1396+ text: &text::BufferSnapshot,
1397+ start_byte: usize,
1398+ start_point: Point,
1399+) {
1400+ let mut ix = indices.end + 1;
1401+ while ix > indices.start {
1402+ ix -= 1;
1403+ if 0 == ix || ix == ranges.len() {
1404+ continue;
1405+ }
1406+
1407+ let range_b = ranges[ix].clone();
1408+ let range_a = &mut ranges[ix - 1];
1409+ if range_a.end_point.column == 0 {
1410+ continue;
1411+ }
1412+
1413+ if range_a.end_point.row < range_b.start_point.row {
1414+ let end_point = start_point + Point::from_ts_point(range_a.end_point);
1415+ let line_end = Point::new(end_point.row, text.line_len(end_point.row));
1416+ if end_point.column as u32 >= line_end.column {
1417+ range_a.end_byte += 1;
1418+ range_a.end_point.row += 1;
1419+ range_a.end_point.column = 0;
1420+ } else {
1421+ let newline_offset = text.point_to_offset(line_end);
1422+ ranges.insert(
1423+ ix,
1424+ tree_sitter::Range {
1425+ start_byte: newline_offset - start_byte,
1426+ end_byte: newline_offset - start_byte + 1,
1427+ start_point: (line_end - start_point).to_ts_point(),
1428+ end_point: ((line_end - start_point) + Point::new(1, 0)).to_ts_point(),
1429+ },
1430+ )
1431+ }
1432+ }
1433+ }
13491434 }
13501435
13511436 impl OwnedSyntaxLayerInfo {
crates/language/src/syntax_map/syntax_map_tests.rs+162−73
@@ -11,7 +11,7 @@ use util::test::marked_text_ranges; · 10 unmodified lines
1111 fn test_splice_included_ranges() {
1212 let ranges = vec![ts_range(20..30), ts_range(50..60), ts_range(80..90)];
1313
14− let new_ranges = splice_included_ranges(
14+ let (new_ranges, change) = splice_included_ranges(
1515 ranges.clone(),
1616 &[54..56, 58..68],
1717 &[ts_range(50..54), ts_range(59..67)],
@@ -25,14 +25,16 @@ fn test_splice_included_ranges() { · 7 unmodified lines
2525 ts_range(80..90),
2626 ]
2727 );
28+ assert_eq!(change, 1..3);
2829
29− let new_ranges = splice_included_ranges(ranges.clone(), &[70..71, 91..100], &[]);
30+ let (new_ranges, change) = splice_included_ranges(ranges.clone(), &[70..71, 91..100], &[]);
3031 assert_eq!(
3132 new_ranges,
3233 &[ts_range(20..30), ts_range(50..60), ts_range(80..90)]
3334 );
35+ assert_eq!(change, 2..3);
3436
35− let new_ranges =
37+ let (new_ranges, change) =
3638 splice_included_ranges(ranges.clone(), &[], &[ts_range(0..2), ts_range(70..75)]);
3739 assert_eq!(
3840 new_ranges,
@@ -44,16 +46,21 @@ fn test_splice_included_ranges() { · 5 unmodified lines
4446 ts_range(80..90)
4547 ]
4648 );
49+ assert_eq!(change, 0..4);
4750
48− let new_ranges = splice_included_ranges(ranges.clone(), &[30..50], &[ts_range(25..55)]);
51+ let (new_ranges, change) =
52+ splice_included_ranges(ranges.clone(), &[30..50], &[ts_range(25..55)]);
4953 assert_eq!(new_ranges, &[ts_range(25..55), ts_range(80..90)]);
54+ assert_eq!(change, 0..1);
5055
5156 // does not create overlapping ranges
52− let new_ranges = splice_included_ranges(ranges.clone(), &[0..18], &[ts_range(20..32)]);
57+ let (new_ranges, change) =
58+ splice_included_ranges(ranges.clone(), &[0..18], &[ts_range(20..32)]);
5359 assert_eq!(
5460 new_ranges,
5561 &[ts_range(20..32), ts_range(50..60), ts_range(80..90)]
5662 );
63+ assert_eq!(change, 0..1);
5764
5865 fn ts_range(range: Range<usize>) -> tree_sitter::Range {
5966 tree_sitter::Range {
@@ -511,7 +518,7 @@ fn test_removing_injection_by_replacing_across_boundary() { · 451 unmodified lines
511518 }
512519
513520 #[gpui::test]
514−fn test_combined_injections() {
521+fn test_combined_injections_simple() {
515522 let (buffer, syntax_map) = test_edit_sequence(
516523 "ERB",
517524 &[
@@ -653,33 +660,78 @@ fn test_combined_injections_editing_after_last_injection() { · 135 unmodified lines
653660
654661 #[gpui::test]
655662 fn test_combined_injections_inside_injections() {
656− let (_buffer, _syntax_map) = test_edit_sequence(
663+ let (buffer, syntax_map) = test_edit_sequence(
657664 "Markdown",
658665 &[
659666 r#"
660− here is some ERB code:
667+ here is
668+ some
669+ ERB code:
661670
662671 ```erb
663672 <ul>
664673 <% people.each do |person| %>
665674 <li><%= person.name %></li>
675+ <li><%= person.age %></li>
666676 <% end %>
667677 </ul>
668678 ```
669679 "#,
670680 r#"
671− here is some ERB code:
681+ here is
682+ some
683+ ERB code:
672684
673685 ```erb
674686 <ul>
675687 <% people«2».each do |person| %>
676688 <li><%= person.name %></li>
689+ <li><%= person.age %></li>
690+ <% end %>
691+ </ul>
692+ ```
693+ "#,
694+ // Inserting a comment character inside one code directive
695+ // does not cause the other code directive to become a comment,
696+ // because newlines are included in between each injection range.
697+ r#"
698+ here is
699+ some
700+ ERB code:
701+
702+ ```erb
703+ <ul>
704+ <% people2.each do |person| %>
705+ <li><%= «# »person.name %></li>
706+ <li><%= person.age %></li>
677707 <% end %>
678708 </ul>
679709 ```
680710 "#,
681711 ],
682712 );
713+
714+ // Check that the code directive below the ruby comment is
715+ // not parsed as a comment.
716+ assert_capture_ranges(
717+ &syntax_map,
718+ &buffer,
719+ &["method"],
720+ "
721+ here is
722+ some
723+ ERB code:
724+
725+ ```erb
726+ <ul>
727+ <% people2.«each» do |person| %>
728+ <li><%= # person.name %></li>
729+ <li><%= person.«age» %></li>
730+ <% end %>
731+ </ul>
732+ ```
733+ ",
734+ );
683735 }
684736
685737 #[gpui::test]
@@ -711,11 +763,7 @@ fn test_empty_combined_injections_inside_injections() { · 25 unmodified lines
711763 }
712764
713765 #[gpui::test(iterations = 50)]
714−fn test_random_syntax_map_edits(mut rng: StdRng) {
715− let operations = env::var("OPERATIONS")
716− .map(|i| i.parse().expect("invalid `OPERATIONS` variable"))
717− .unwrap_or(10);
718−
766+fn test_random_syntax_map_edits_rust_macros(rng: StdRng) {
719767 let text = r#"
720768 fn test_something() {
721769 let vec = vec![5, 1, 3, 8];
@@ -736,68 +784,12 @@ fn test_random_syntax_map_edits(mut rng: StdRng) { · 14 unmodified lines
736784 let registry = Arc::new(LanguageRegistry::test());
737785 let language = Arc::new(rust_lang());
738786 registry.add(language.clone());
739− let mut buffer = Buffer::new(0, 0, text);
740−
741− let mut syntax_map = SyntaxMap::new();
742− syntax_map.set_language_registry(registry.clone());
743− syntax_map.reparse(language.clone(), &buffer);
744−
745− let mut reference_syntax_map = SyntaxMap::new();
746− reference_syntax_map.set_language_registry(registry.clone());
747−
748− log::info!("initial text:\n{}", buffer.text());
749−
750− for _ in 0..operations {
751− let prev_buffer = buffer.snapshot();
752− let prev_syntax_map = syntax_map.snapshot();
753−
754− buffer.randomly_edit(&mut rng, 3);
755− log::info!("text:\n{}", buffer.text());
756−
757− syntax_map.interpolate(&buffer);
758− check_interpolation(&prev_syntax_map, &syntax_map, &prev_buffer, &buffer);
759−
760− syntax_map.reparse(language.clone(), &buffer);
761−
762− reference_syntax_map.clear();
763− reference_syntax_map.reparse(language.clone(), &buffer);
764− }
765−
766− for i in 0..operations {
767− let i = operations - i - 1;
768− buffer.undo();
769− log::info!("undoing operation {}", i);
770− log::info!("text:\n{}", buffer.text());
771−
772− syntax_map.interpolate(&buffer);
773− syntax_map.reparse(language.clone(), &buffer);
774−
775− reference_syntax_map.clear();
776− reference_syntax_map.reparse(language.clone(), &buffer);
777− assert_eq!(
778− syntax_map.layers(&buffer).len(),
779− reference_syntax_map.layers(&buffer).len(),
780− "wrong number of layers after undoing edit {i}"
781− );
782− }
783787
784− let layers = syntax_map.layers(&buffer);
785− let reference_layers = reference_syntax_map.layers(&buffer);
786− for (edited_layer, reference_layer) in layers.into_iter().zip(reference_layers.into_iter()) {
787− assert_eq!(
788− edited_layer.node().to_sexp(),
789− reference_layer.node().to_sexp()
790− );
791− assert_eq!(edited_layer.node().range(), reference_layer.node().range());
792− }
788+ test_random_edits(text, registry, language, rng);
793789 }
794790
795791 #[gpui::test(iterations = 50)]
796−fn test_random_syntax_map_edits_with_combined_injections(mut rng: StdRng) {
797− let operations = env::var("OPERATIONS")
798− .map(|i| i.parse().expect("invalid `OPERATIONS` variable"))
799− .unwrap_or(10);
800−
792+fn test_random_syntax_map_edits_with_erb(rng: StdRng) {
801793 let text = r#"
802794 <div id="main">
803795 <% if one?(:two) %>
@@ -814,13 +806,60 @@ fn test_random_syntax_map_edits_with_combined_injections(mut rng: StdRng) { · 10 unmodified lines
814806 </div>
815807 "#
816808 .unindent()
817− .repeat(8);
809+ .repeat(5);
818810
819811 let registry = Arc::new(LanguageRegistry::test());
820812 let language = Arc::new(erb_lang());
821813 registry.add(language.clone());
822814 registry.add(Arc::new(ruby_lang()));
823815 registry.add(Arc::new(html_lang()));
816+
817+ test_random_edits(text, registry, language, rng);
818+}
819+
820+#[gpui::test(iterations = 50)]
821+fn test_random_syntax_map_edits_with_heex(rng: StdRng) {
822+ let text = r#"
823+ defmodule TheModule do
824+ def the_method(assigns) do
825+ ~H"""
826+ <%= if @empty do %>
827+ <div class="h-4"></div>
828+ <% else %>
829+ <div class="max-w-2xl w-full animate-pulse">
830+ <div class="flex-1 space-y-4">
831+ <div class={[@bg_class, "h-4 rounded-lg w-3/4"]}></div>
832+ <div class={[@bg_class, "h-4 rounded-lg"]}></div>
833+ <div class={[@bg_class, "h-4 rounded-lg w-5/6"]}></div>
834+ </div>
835+ </div>
836+ <% end %>
837+ """
838+ end
839+ end
840+ "#
841+ .unindent()
842+ .repeat(3);
843+
844+ let registry = Arc::new(LanguageRegistry::test());
845+ let language = Arc::new(elixir_lang());
846+ registry.add(language.clone());
847+ registry.add(Arc::new(heex_lang()));
848+ registry.add(Arc::new(html_lang()));
849+
850+ test_random_edits(text, registry, language, rng);
851+}
852+
853+fn test_random_edits(
854+ text: String,
855+ registry: Arc<LanguageRegistry>,
856+ language: Arc<Language>,
857+ mut rng: StdRng,
858+) {
859+ let operations = env::var("OPERATIONS")
860+ .map(|i| i.parse().expect("invalid `OPERATIONS` variable"))
861+ .unwrap_or(10);
862+
824863 let mut buffer = Buffer::new(0, 0, text);
825864
826865 let mut syntax_map = SyntaxMap::new();
@@ -984,11 +1023,14 @@ fn check_interpolation( · 157 unmodified lines
9841023
9851024 fn test_edit_sequence(language_name: &str, steps: &[&str]) -> (Buffer, SyntaxMap) {
9861025 let registry = Arc::new(LanguageRegistry::test());
1026+ registry.add(Arc::new(elixir_lang()));
1027+ registry.add(Arc::new(heex_lang()));
9871028 registry.add(Arc::new(rust_lang()));
9881029 registry.add(Arc::new(ruby_lang()));
9891030 registry.add(Arc::new(html_lang()));
9901031 registry.add(Arc::new(erb_lang()));
9911032 registry.add(Arc::new(markdown_lang()));
1033+
9921034 let language = registry
9931035 .language_for_name(language_name)
9941036 .now_or_never()
@@ -1074,6 +1116,7 @@ fn ruby_lang() -> Language { · 79 unmodified lines
10741116 r#"
10751117 ["if" "do" "else" "end"] @keyword
10761118 (instance_variable) @ivar
1119+ (call method: (identifier) @method)
10771120 "#,
10781121 )
10791122 .unwrap()
@@ -1158,6 +1201,52 @@ fn markdown_lang() -> Language { · 78 unmodified lines
11581201 .unwrap()
11591202 }
11601203
1204+fn elixir_lang() -> Language {
1205+ Language::new(
1206+ LanguageConfig {
1207+ name: "Elixir".into(),
1208+ path_suffixes: vec!["ex".into()],
1209+ ..Default::default()
1210+ },
1211+ Some(tree_sitter_elixir::language()),
1212+ )
1213+ .with_highlights_query(
1214+ r#"
1215+
1216+ "#,
1217+ )
1218+ .unwrap()
1219+}
1220+
1221+fn heex_lang() -> Language {
1222+ Language::new(
1223+ LanguageConfig {
1224+ name: "HEEx".into(),
1225+ path_suffixes: vec!["heex".into()],
1226+ ..Default::default()
1227+ },
1228+ Some(tree_sitter_heex::language()),
1229+ )
1230+ .with_injection_query(
1231+ r#"
1232+ (
1233+ (directive
1234+ [
1235+ (partial_expression_value)
1236+ (expression_value)
1237+ (ending_expression_value)
1238+ ] @content)
1239+ (#set! language "elixir")
1240+ (#set! combined)
1241+ )
1242+
1243+ ((expression (expression_value) @content)
1244+ (#set! language "elixir"))
1245+ "#,
1246+ )
1247+ .unwrap()
1248+}
1249+
11611250 fn range_for_text(buffer: &Buffer, text: &str) -> Range<usize> {
11621251 let start = buffer.as_rope().to_string().find(text).unwrap();
11631252 start..start + text.len()
crates/language_selector/src/language_selector.rs+1−1
@@ -93,7 +93,7 @@ impl PickerDelegate for LanguageSelectorDelegate { · 92 unmodified lines
9393 self.matches.len()
9494 }
9595
96− fn confirm(&mut self, cx: &mut ViewContext<Picker<Self>>) {
96+ fn confirm(&mut self, _: bool, cx: &mut ViewContext<Picker<Self>>) {
9797 if let Some(mat) = self.matches.get(self.selected_index) {
9898 let language_name = &self.candidates[mat.candidate_id].string;
9999 let language = self.language_registry.language_for_name(language_name);
crates/language_tools/src/lsp_log.rs+12−2
@@ -467,8 +467,13 @@ impl Item for LspLogView { · 466 unmodified lines
467467 impl SearchableItem for LspLogView {
468468 type Match = <Editor as SearchableItem>::Match;
469469
470− fn to_search_event(event: &Self::Event) -> Option<workspace::searchable::SearchEvent> {
471− Editor::to_search_event(event)
470+ fn to_search_event(
471+ &mut self,
472+ event: &Self::Event,
473+ cx: &mut ViewContext<Self>,
474+ ) -> Option<workspace::searchable::SearchEvent> {
475+ self.editor
476+ .update(cx, |editor, cx| editor.to_search_event(event, cx))
472477 }
473478
474479 fn clear_matches(&mut self, cx: &mut ViewContext<Self>) {
@@ -494,6 +499,11 @@ impl SearchableItem for LspLogView { · 19 unmodified lines
494499 .update(cx, |e, cx| e.activate_match(index, matches, cx))
495500 }
496501
502+ fn select_matches(&mut self, matches: Vec<Self::Match>, cx: &mut ViewContext<Self>) {
503+ self.editor
504+ .update(cx, |e, cx| e.select_matches(matches, cx))
505+ }
506+
497507 fn find_matches(
498508 &mut self,
499509 query: project::search::SearchQuery,
crates/lsp/src/lsp.rs+4−3
@@ -151,16 +151,17 @@ impl LanguageServer { · 150 unmodified lines
151151 let stdin = server.stdin.take().unwrap();
152152 let stout = server.stdout.take().unwrap();
153153 let mut server = Self::new_internal(
154− server_id,
154+ server_id.clone(),
155155 stdin,
156156 stout,
157157 Some(server),
158158 root_path,
159159 code_action_kinds,
160160 cx,
161− |notification| {
161+ move |notification| {
162162 log::info!(
163− "unhandled notification {}:\n{}",
163+ "{} unhandled notification {}:\n{}",
164+ server_id,
164165 notification.method,
165166 serde_json::to_string_pretty(
166167 &notification
crates/menu/src/menu.rs+1−0
@@ -3,6 +3,7 @@ gpui::actions!( · 2 unmodified lines
33 [
44 Cancel,
55 Confirm,
6+ SecondaryConfirm,
67 SelectPrev,
78 SelectNext,
89 SelectFirst,
crates/node_runtime/src/node_runtime.rs+16−29
@@ -6,13 +6,13 @@ use futures::{future::Shared, FutureExt}; · 5 unmodified lines
66 use gpui::{executor::Background, Task};
77 use serde::Deserialize;
88 use smol::{fs, io::BufReader, process::Command};
9−use std::process::Output;
9+use std::process::{Output, Stdio};
1010 use std::{
1111 env::consts,
1212 path::{Path, PathBuf},
1313 sync::{Arc, OnceLock},
1414 };
15−use util::{http::HttpClient, ResultExt};
15+use util::http::HttpClient;
1616
1717 const VERSION: &str = "v18.15.0";
1818
@@ -84,9 +84,8 @@ impl NodeRuntime { · 65 unmodified lines
8484 };
8585
8686 let installation_path = self.install_if_needed().await?;
87− let mut output = attempt(installation_path).await;
87+ let mut output = attempt(installation_path.clone()).await;
8888 if output.is_err() {
89− let installation_path = self.reinstall().await?;
9089 output = attempt(installation_path).await;
9190 if output.is_err() {
9291 return Err(anyhow!(
@@ -158,29 +157,6 @@ impl NodeRuntime { · 65 unmodified lines
158157 Ok(())
159158 }
160159
161− async fn reinstall(&self) -> Result<PathBuf> {
162− log::info!("beginnning to reinstall Node runtime");
163− let mut installation_path = self.installation_path.lock().await;
164−
165− if let Some(task) = installation_path.as_ref().cloned() {
166− if let Ok(installation_path) = task.await {
167− smol::fs::remove_dir_all(&installation_path)
168− .await
169− .context("node dir removal")
170− .log_err();
171− }
172− }
173−
174− let http = self.http.clone();
175− let task = self
176− .background
177− .spawn(async move { Self::install(http).await.map_err(Arc::new) })
178− .shared();
179−
180− *installation_path = Some(task.clone());
181− task.await.map_err(|e| anyhow!("{}", e))
182− }
183−
184160 async fn install_if_needed(&self) -> Result<PathBuf> {
185161 let task = self
186162 .installation_path
@@ -209,8 +185,19 @@ impl NodeRuntime { · 22 unmodified lines
209185 let node_containing_dir = util::paths::SUPPORT_DIR.join("node");
210186 let node_dir = node_containing_dir.join(folder_name);
211187 let node_binary = node_dir.join("bin/node");
212−
213− if fs::metadata(&node_binary).await.is_err() {
188+ let npm_file = node_dir.join("bin/npm");
189+
190+ let result = Command::new(&node_binary)
191+ .arg(npm_file)
192+ .arg("--version")
193+ .stdin(Stdio::null())
194+ .stdout(Stdio::null())
195+ .stderr(Stdio::null())
196+ .status()
197+ .await;
198+ let valid = matches!(result, Ok(status) if status.success());
199+
200+ if !valid {
214201 _ = fs::remove_dir_all(&node_containing_dir).await;
215202 fs::create_dir(&node_containing_dir)
216203 .await
crates/outline/src/outline.rs+1−1
@@ -177,7 +177,7 @@ impl PickerDelegate for OutlineViewDelegate { · 176 unmodified lines
177177 Task::ready(())
178178 }
179179
180− fn confirm(&mut self, cx: &mut ViewContext<OutlineView>) {
180+ fn confirm(&mut self, _: bool, cx: &mut ViewContext<OutlineView>) {
181181 self.prev_scroll_position.take();
182182 self.active_editor.update(cx, |active_editor, cx| {
183183 if let Some(rows) = active_editor.highlighted_rows() {
crates/picker/src/picker.rs+13−7
@@ -7,7 +7,7 @@ use gpui::{ · 6 unmodified lines
77 AnyElement, AnyViewHandle, AppContext, Axis, Entity, MouseState, Task, View, ViewContext,
88 ViewHandle,
99 };
10−use menu::{Cancel, Confirm, SelectFirst, SelectLast, SelectNext, SelectPrev};
10+use menu::{Cancel, Confirm, SecondaryConfirm, SelectFirst, SelectLast, SelectNext, SelectPrev};
1111 use parking_lot::Mutex;
1212 use std::{cmp, sync::Arc};
1313 use util::ResultExt;
@@ -34,7 +34,7 @@ pub trait PickerDelegate: Sized + 'static { · 20 unmodified lines
3434 fn selected_index(&self) -> usize;
3535 fn set_selected_index(&mut self, ix: usize, cx: &mut ViewContext<Picker<Self>>);
3636 fn update_matches(&mut self, query: String, cx: &mut ViewContext<Picker<Self>>) -> Task<()>;
37− fn confirm(&mut self, cx: &mut ViewContext<Picker<Self>>);
37+ fn confirm(&mut self, secondary: bool, cx: &mut ViewContext<Picker<Self>>);
3838 fn dismissed(&mut self, cx: &mut ViewContext<Picker<Self>>);
3939 fn render_match(
4040 &self,
@@ -118,8 +118,8 @@ impl<D: PickerDelegate> View for Picker<D> { · 77 unmodified lines
118118 // Capture mouse events
119119 .on_down(MouseButton::Left, |_, _, _| {})
120120 .on_up(MouseButton::Left, |_, _, _| {})
121− .on_click(MouseButton::Left, move |_, picker, cx| {
122− picker.select_index(ix, cx);
121+ .on_click(MouseButton::Left, move |click, picker, cx| {
122+ picker.select_index(ix, click.cmd, cx);
123123 })
124124 .with_cursor_style(CursorStyle::PointingHand)
125125 .into_any()
@@ -175,6 +175,7 @@ impl<D: PickerDelegate> Picker<D> { · 49 unmodified lines
175175 cx.add_action(Self::select_next);
176176 cx.add_action(Self::select_prev);
177177 cx.add_action(Self::confirm);
178+ cx.add_action(Self::secondary_confirm);
178179 cx.add_action(Self::cancel);
179180 }
180181
@@ -288,11 +289,11 @@ impl<D: PickerDelegate> Picker<D> { · 107 unmodified lines
288289 cx.notify();
289290 }
290291
291− pub fn select_index(&mut self, index: usize, cx: &mut ViewContext<Self>) {
292+ pub fn select_index(&mut self, index: usize, cmd: bool, cx: &mut ViewContext<Self>) {
292293 if self.delegate.match_count() > 0 {
293294 self.confirmed = true;
294295 self.delegate.set_selected_index(index, cx);
295− self.delegate.confirm(cx);
296+ self.delegate.confirm(cmd, cx);
296297 }
297298 }
298299
@@ -330,7 +331,12 @@ impl<D: PickerDelegate> Picker<D> { · 31 unmodified lines
330331
331332 pub fn confirm(&mut self, _: &Confirm, cx: &mut ViewContext<Self>) {
332333 self.confirmed = true;
333− self.delegate.confirm(cx);
334+ self.delegate.confirm(false, cx);
335+ }
336+
337+ pub fn secondary_confirm(&mut self, _: &SecondaryConfirm, cx: &mut ViewContext<Self>) {
338+ self.confirmed = true;
339+ self.delegate.confirm(true, cx);
334340 }
335341
336342 fn cancel(&mut self, _: &Cancel, cx: &mut ViewContext<Self>) {
crates/project/src/project.rs+2−1
@@ -2709,7 +2709,6 @@ impl Project { · 2708 unmodified lines
27092709 Some(language_server) => language_server,
27102710 None => return Ok(None),
27112711 };
2712−
27132712 let this = match this.upgrade(cx) {
27142713 Some(this) => this,
27152714 None => return Err(anyhow!("failed to upgrade project handle")),
@@ -3045,6 +3044,8 @@ impl Project { · 329 unmodified lines
30453044 ) -> Task<(Option<PathBuf>, Vec<WorktreeId>)> {
30463045 let key = (worktree_id, adapter_name);
30473046 if let Some(server_id) = self.language_server_ids.remove(&key) {
3047+ log::info!("stopping language server {}", key.1 .0);
3048+
30483049 // Remove other entries for this language server as well
30493050 let mut orphaned_worktrees = vec![worktree_id];
30503051 let other_keys = self.language_server_ids.keys().cloned().collect::<Vec<_>>();
crates/project/src/worktree.rs+6−4
@@ -397,6 +397,7 @@ impl Worktree { · 396 unmodified lines
397397 }))
398398 }
399399
400+ // abcdefghi
400401 pub fn remote(
401402 project_remote_id: u64,
402403 replica_id: ReplicaId,
@@ -2022,6 +2023,9 @@ impl LocalSnapshot { · 1619 unmodified lines
20222023 ) -> Vec<Arc<Path>> {
20232024 let mut changes = vec![];
20242025 let mut edits = vec![];
2026+
2027+ let statuses = repo_ptr.statuses();
2028+
20252029 for mut entry in self
20262030 .descendent_entries(false, false, &work_directory.0)
20272031 .cloned()
@@ -2029,10 +2033,8 @@ impl LocalSnapshot { · 1 unmodified line
20292033 let Ok(repo_path) = entry.path.strip_prefix(&work_directory.0) else {
20302034 continue;
20312035 };
2032− let git_file_status = repo_ptr
2033− .status(&RepoPath(repo_path.into()))
2034− .log_err()
2035− .flatten();
2036+ let repo_path = RepoPath(repo_path.to_path_buf());
2037+ let git_file_status = statuses.as_ref().and_then(|s| s.get(&repo_path).copied());
20362038 if entry.git_status != git_file_status {
20372039 entry.git_status = git_file_status;
20382040 changes.push(entry.path.clone());
crates/project_panel/src/project_panel.rs+27−1
@@ -159,6 +159,9 @@ pub enum Event { · 158 unmodified lines
159159 entry_id: ProjectEntryId,
160160 focus_opened_item: bool,
161161 },
162+ SplitEntry {
163+ entry_id: ProjectEntryId,
164+ },
162165 DockPositionChanged,
163166 Focus,
164167 }
@@ -290,6 +293,21 @@ impl ProjectPanel { · 125 unmodified lines
290293 }
291294 }
292295 }
296+ &Event::SplitEntry { entry_id } => {
297+ if let Some(worktree) = project.read(cx).worktree_for_entry(entry_id, cx) {
298+ if let Some(entry) = worktree.read(cx).entry_for_id(entry_id) {
299+ workspace
300+ .split_path(
301+ ProjectPath {
302+ worktree_id: worktree.read(cx).id(),
303+ path: entry.path.clone(),
304+ },
305+ cx,
306+ )
307+ .detach_and_log_err(cx);
308+ }
309+ }
310+ }
293311 _ => {}
294312 }
295313 })
@@ -620,6 +638,10 @@ impl ProjectPanel { · 324 unmodified lines
620638 });
621639 }
622640
641+ fn split_entry(&mut self, entry_id: ProjectEntryId, cx: &mut ViewContext<Self>) {
642+ cx.emit(Event::SplitEntry { entry_id });
643+ }
644+
623645 fn new_file(&mut self, _: &NewFile, cx: &mut ViewContext<Self>) {
624646 self.add_entry(false, cx)
625647 }
@@ -1333,7 +1355,11 @@ impl ProjectPanel { · 707 unmodified lines
13331355 if kind.is_dir() {
13341356 this.toggle_expanded(entry_id, cx);
13351357 } else {
1336− this.open_entry(entry_id, event.click_count > 1, cx);
1358+ if event.cmd {
1359+ this.split_entry(entry_id, cx);
1360+ } else if !event.cmd {
1361+ this.open_entry(entry_id, event.click_count > 1, cx);
1362+ }
13371363 }
13381364 }
13391365 })
crates/project_symbols/src/project_symbols.rs+7−2
@@ -104,7 +104,7 @@ impl PickerDelegate for ProjectSymbolsDelegate { · 103 unmodified lines
104104 "Search project symbols...".into()
105105 }
106106
107− fn confirm(&mut self, cx: &mut ViewContext<ProjectSymbols>) {
107+ fn confirm(&mut self, secondary: bool, cx: &mut ViewContext<ProjectSymbols>) {
108108 if let Some(symbol) = self
109109 .matches
110110 .get(self.selected_match_index)
@@ -122,7 +122,12 @@ impl PickerDelegate for ProjectSymbolsDelegate { · 11 unmodified lines
122122 .read(cx)
123123 .clip_point_utf16(symbol.range.start, Bias::Left);
124124
125− let editor = workspace.open_project_item::<Editor>(buffer, cx);
125+ let editor = if secondary {
126+ workspace.split_project_item::<Editor>(buffer, cx)
127+ } else {
128+ workspace.open_project_item::<Editor>(buffer, cx)
129+ };
130+
126131 editor.update(cx, |editor, cx| {
127132 editor.change_selections(Some(Autoscroll::center()), cx, |s| {
128133 s.select_ranges([position..position])
crates/recent_projects/src/recent_projects.rs+1−1
@@ -161,7 +161,7 @@ impl PickerDelegate for RecentProjectsDelegate { · 160 unmodified lines
161161 Task::ready(())
162162 }
163163
164− fn confirm(&mut self, cx: &mut ViewContext<RecentProjects>) {
164+ fn confirm(&mut self, _: bool, cx: &mut ViewContext<RecentProjects>) {
165165 if let Some((selected_match, workspace)) = self
166166 .matches
167167 .get(self.selected_index())
crates/search/src/buffer_search.rs+199−12
@@ -1,6 +1,6 @@
11 use crate::{
2− SearchOption, SelectNextMatch, SelectPrevMatch, ToggleCaseSensitive, ToggleRegex,
3− ToggleWholeWord,
2+ SearchOption, SelectAllMatches, SelectNextMatch, SelectPrevMatch, ToggleCaseSensitive,
3+ ToggleRegex, ToggleWholeWord,
44 };
55 use collections::HashMap;
66 use editor::Editor;
@@ -39,8 +39,10 @@ pub fn init(cx: &mut AppContext) { · 32 unmodified lines
3939 cx.add_action(BufferSearchBar::focus_editor);
4040 cx.add_action(BufferSearchBar::select_next_match);
4141 cx.add_action(BufferSearchBar::select_prev_match);
42+ cx.add_action(BufferSearchBar::select_all_matches);
4243 cx.add_action(BufferSearchBar::select_next_match_on_pane);
4344 cx.add_action(BufferSearchBar::select_prev_match_on_pane);
45+ cx.add_action(BufferSearchBar::select_all_matches_on_pane);
4446 cx.add_action(BufferSearchBar::handle_editor_cancel);
4547 add_toggle_option_action::<ToggleCaseSensitive>(SearchOption::CaseSensitive, cx);
4648 add_toggle_option_action::<ToggleWholeWord>(SearchOption::WholeWord, cx);
@@ -66,7 +68,7 @@ pub struct BufferSearchBar { · 19 unmodified lines
6668 active_searchable_item: Option<Box<dyn SearchableItemHandle>>,
6769 active_match_index: Option<usize>,
6870 active_searchable_item_subscription: Option<Subscription>,
69− seachable_items_with_matches:
71+ searchable_items_with_matches:
7072 HashMap<Box<dyn WeakSearchableItemHandle>, Vec<Box<dyn Any + Send>>>,
7173 pending_search: Option<Task<()>>,
7274 case_sensitive: bool,
@@ -118,7 +120,7 @@ impl View for BufferSearchBar { · 45 unmodified lines
118120 .with_children(self.active_searchable_item.as_ref().and_then(
119121 |searchable_item| {
120122 let matches = self
121− .seachable_items_with_matches
123+ .searchable_items_with_matches
122124 .get(&searchable_item.downgrade())?;
123125 let message = if let Some(match_ix) = self.active_match_index {
124126 format!("{}/{}", match_ix + 1, matches.len())
@@ -146,6 +148,7 @@ impl View for BufferSearchBar { · 21 unmodified lines
146148 Flex::row()
147149 .with_child(self.render_nav_button("<", Direction::Prev, cx))
148150 .with_child(self.render_nav_button(">", Direction::Next, cx))
151+ .with_child(self.render_action_button("Select All", cx))
149152 .aligned(),
150153 )
151154 .with_child(
@@ -249,7 +252,7 @@ impl BufferSearchBar { · 97 unmodified lines
249252 active_searchable_item: None,
250253 active_searchable_item_subscription: None,
251254 active_match_index: None,
252− seachable_items_with_matches: Default::default(),
255+ searchable_items_with_matches: Default::default(),
253256 case_sensitive: false,
254257 whole_word: false,
255258 regex: false,
@@ -265,7 +268,7 @@ impl BufferSearchBar { · 9 unmodified lines
265268
266269 pub fn dismiss(&mut self, _: &Dismiss, cx: &mut ViewContext<Self>) {
267270 self.dismissed = true;
268− for searchable_item in self.seachable_items_with_matches.keys() {
271+ for searchable_item in self.searchable_items_with_matches.keys() {
269272 if let Some(searchable_item) =
270273 WeakSearchableItemHandle::upgrade(searchable_item.as_ref(), cx)
271274 {
@@ -401,6 +404,37 @@ impl BufferSearchBar { · 129 unmodified lines
401404 .into_any()
402405 }
403406
407+ fn render_action_button(
408+ &self,
409+ icon: &'static str,
410+ cx: &mut ViewContext<Self>,
411+ ) -> AnyElement<Self> {
412+ let tooltip = "Select All Matches";
413+ let tooltip_style = theme::current(cx).tooltip.clone();
414+ let action_type_id = 0_usize;
415+
416+ enum ActionButton {}
417+ MouseEventHandler::<ActionButton, _>::new(action_type_id, cx, |state, cx| {
418+ let theme = theme::current(cx);
419+ let style = theme.search.action_button.style_for(state);
420+ Label::new(icon, style.text.clone())
421+ .contained()
422+ .with_style(style.container)
423+ })
424+ .on_click(MouseButton::Left, move |_, this, cx| {
425+ this.select_all_matches(&SelectAllMatches, cx)
426+ })
427+ .with_cursor_style(CursorStyle::PointingHand)
428+ .with_tooltip::<ActionButton>(
429+ action_type_id,
430+ tooltip.to_string(),
431+ Some(Box::new(SelectAllMatches)),
432+ tooltip_style,
433+ cx,
434+ )
435+ .into_any()
436+ }
437+
404438 fn render_close_button(
405439 &self,
406440 theme: &theme::Search,
@@ -488,11 +522,25 @@ impl BufferSearchBar { · 81 unmodified lines
488522 self.select_match(Direction::Prev, cx);
489523 }
490524
525+ fn select_all_matches(&mut self, _: &SelectAllMatches, cx: &mut ViewContext<Self>) {
526+ if !self.dismissed {
527+ if let Some(searchable_item) = self.active_searchable_item.as_ref() {
528+ if let Some(matches) = self
529+ .searchable_items_with_matches
530+ .get(&searchable_item.downgrade())
531+ {
532+ searchable_item.select_matches(matches, cx);
533+ self.focus_editor(&FocusEditor, cx);
534+ }
535+ }
536+ }
537+ }
538+
491539 pub fn select_match(&mut self, direction: Direction, cx: &mut ViewContext<Self>) {
492540 if let Some(index) = self.active_match_index {
493541 if let Some(searchable_item) = self.active_searchable_item.as_ref() {
494542 if let Some(matches) = self
495− .seachable_items_with_matches
543+ .searchable_items_with_matches
496544 .get(&searchable_item.downgrade())
497545 {
498546 let new_match_index =
@@ -524,6 +572,16 @@ impl BufferSearchBar { · 25 unmodified lines
524572 }
525573 }
526574
575+ fn select_all_matches_on_pane(
576+ pane: &mut Pane,
577+ action: &SelectAllMatches,
578+ cx: &mut ViewContext<Pane>,
579+ ) {
580+ if let Some(search_bar) = pane.toolbar().read(cx).item_of_type::<BufferSearchBar>() {
581+ search_bar.update(cx, |bar, cx| bar.select_all_matches(action, cx));
582+ }
583+ }
584+
527585 fn on_query_editor_event(
528586 &mut self,
529587 _: ViewHandle<Editor>,
@@ -547,7 +605,7 @@ impl BufferSearchBar { · 17 unmodified lines
547605
548606 fn clear_matches(&mut self, cx: &mut ViewContext<Self>) {
549607 let mut active_item_matches = None;
550− for (searchable_item, matches) in self.seachable_items_with_matches.drain() {
608+ for (searchable_item, matches) in self.searchable_items_with_matches.drain() {
551609 if let Some(searchable_item) =
552610 WeakSearchableItemHandle::upgrade(searchable_item.as_ref(), cx)
553611 {
@@ -559,7 +617,7 @@ impl BufferSearchBar { · 5 unmodified lines
559617 }
560618 }
561619
562− self.seachable_items_with_matches
620+ self.searchable_items_with_matches
563621 .extend(active_item_matches);
564622 }
565623
@@ -605,13 +663,13 @@ impl BufferSearchBar { · 39 unmodified lines
605663 if let Some(active_searchable_item) =
606664 WeakSearchableItemHandle::upgrade(active_searchable_item.as_ref(), cx)
607665 {
608− this.seachable_items_with_matches
666+ this.searchable_items_with_matches
609667 .insert(active_searchable_item.downgrade(), matches);
610668
611669 this.update_match_index(cx);
612670 if !this.dismissed {
613671 let matches = this
614− .seachable_items_with_matches
672+ .searchable_items_with_matches
615673 .get(&active_searchable_item.downgrade())
616674 .unwrap();
617675 active_searchable_item.update_matches(matches, cx);
@@ -637,7 +695,7 @@ impl BufferSearchBar { · 19 unmodified lines
637695 .as_ref()
638696 .and_then(|searchable_item| {
639697 let matches = self
640− .seachable_items_with_matches
698+ .searchable_items_with_matches
641699 .get(&searchable_item.downgrade())?;
642700 searchable_item.active_match_index(matches, cx)
643701 });
@@ -966,4 +1024,133 @@ mod tests { · 322 unmodified lines
9661024 assert_eq!(search_bar.active_match_index, Some(2));
9671025 });
9681026 }
1027+
1028+ #[gpui::test]
1029+ async fn test_search_select_all_matches(cx: &mut TestAppContext) {
1030+ crate::project_search::tests::init_test(cx);
1031+
1032+ let buffer_text = r#"
1033+ A regular expression (shortened as regex or regexp;[1] also referred to as
1034+ rational expression[2][3]) is a sequence of characters that specifies a search
1035+ pattern in text. Usually such patterns are used by string-searching algorithms
1036+ for "find" or "find and replace" operations on strings, or for input validation.
1037+ "#
1038+ .unindent();
1039+ let expected_query_matches_count = buffer_text
1040+ .chars()
1041+ .filter(|c| c.to_ascii_lowercase() == 'a')
1042+ .count();
1043+ assert!(
1044+ expected_query_matches_count > 1,
1045+ "Should pick a query with multiple results"
1046+ );
1047+ let buffer = cx.add_model(|cx| Buffer::new(0, buffer_text, cx));
1048+ let (window_id, _root_view) = cx.add_window(|_| EmptyView);
1049+
1050+ let editor = cx.add_view(window_id, |cx| Editor::for_buffer(buffer.clone(), None, cx));
1051+
1052+ let search_bar = cx.add_view(window_id, |cx| {
1053+ let mut search_bar = BufferSearchBar::new(cx);
1054+ search_bar.set_active_pane_item(Some(&editor), cx);
1055+ search_bar.show(false, true, cx);
1056+ search_bar
1057+ });
1058+
1059+ search_bar.update(cx, |search_bar, cx| {
1060+ search_bar.set_query("a", cx);
1061+ });
1062+
1063+ editor.next_notification(cx).await;
1064+ let initial_selections = editor.update(cx, |editor, cx| {
1065+ let initial_selections = editor.selections.display_ranges(cx);
1066+ assert_eq!(
1067+ initial_selections.len(), 1,
1068+ "Expected to have only one selection before adding carets to all matches, but got: {initial_selections:?}",
1069+ );
1070+ initial_selections
1071+ });
1072+ search_bar.update(cx, |search_bar, _| {
1073+ assert_eq!(search_bar.active_match_index, Some(0));
1074+ });
1075+
1076+ search_bar.update(cx, |search_bar, cx| {
1077+ search_bar.select_all_matches(&SelectAllMatches, cx);
1078+ let all_selections =
1079+ editor.update(cx, |editor, cx| editor.selections.display_ranges(cx));
1080+ assert_eq!(
1081+ all_selections.len(),
1082+ expected_query_matches_count,
1083+ "Should select all `a` characters in the buffer, but got: {all_selections:?}"
1084+ );
1085+ });
1086+ search_bar.update(cx, |search_bar, _| {
1087+ assert_eq!(
1088+ search_bar.active_match_index,
1089+ Some(0),
1090+ "Match index should not change after selecting all matches"
1091+ );
1092+ });
1093+
1094+ search_bar.update(cx, |search_bar, cx| {
1095+ search_bar.select_next_match(&SelectNextMatch, cx);
1096+ let all_selections =
1097+ editor.update(cx, |editor, cx| editor.selections.display_ranges(cx));
1098+ assert_eq!(
1099+ all_selections.len(),
1100+ 1,
1101+ "On next match, should deselect items and select the next match"
1102+ );
1103+ assert_ne!(
1104+ all_selections, initial_selections,
1105+ "Next match should be different from the first selection"
1106+ );
1107+ });
1108+ search_bar.update(cx, |search_bar, _| {
1109+ assert_eq!(
1110+ search_bar.active_match_index,
1111+ Some(1),
1112+ "Match index should be updated to the next one"
1113+ );
1114+ });
1115+
1116+ search_bar.update(cx, |search_bar, cx| {
1117+ search_bar.select_all_matches(&SelectAllMatches, cx);
1118+ let all_selections =
1119+ editor.update(cx, |editor, cx| editor.selections.display_ranges(cx));
1120+ assert_eq!(
1121+ all_selections.len(),
1122+ expected_query_matches_count,
1123+ "Should select all `a` characters in the buffer, but got: {all_selections:?}"
1124+ );
1125+ });
1126+ search_bar.update(cx, |search_bar, _| {
1127+ assert_eq!(
1128+ search_bar.active_match_index,
1129+ Some(1),
1130+ "Match index should not change after selecting all matches"
1131+ );
1132+ });
1133+
1134+ search_bar.update(cx, |search_bar, cx| {
1135+ search_bar.select_prev_match(&SelectPrevMatch, cx);
1136+ let all_selections =
1137+ editor.update(cx, |editor, cx| editor.selections.display_ranges(cx));
1138+ assert_eq!(
1139+ all_selections.len(),
1140+ 1,
1141+ "On previous match, should deselect items and select the previous item"
1142+ );
1143+ assert_eq!(
1144+ all_selections, initial_selections,
1145+ "Previous match should be the same as the first selection"
1146+ );
1147+ });
1148+ search_bar.update(cx, |search_bar, _| {
1149+ assert_eq!(
1150+ search_bar.active_match_index,
1151+ Some(0),
1152+ "Match index should be updated to the previous one"
1153+ );
1154+ });
1155+ }
9691156 }
crates/search/src/search.rs+2−1
@@ -17,7 +17,8 @@ actions!( · 16 unmodified lines
1717 ToggleCaseSensitive,
1818 ToggleRegex,
1919 SelectNextMatch,
20− SelectPrevMatch
20+ SelectPrevMatch,
21+ SelectAllMatches,
2122 ]
2223 );
2324
crates/semantic_index/src/embedding.rs+7−5
@@ -67,11 +67,13 @@ impl EmbeddingProvider for DummyEmbeddings { · 66 unmodified lines
6767 }
6868 }
6969
70+const INPUT_LIMIT: usize = 8190;
71+
7072 impl OpenAIEmbeddings {
71− async fn truncate(span: String) -> String {
73+ fn truncate(span: String) -> String {
7274 let mut tokens = OPENAI_BPE_TOKENIZER.encode_with_special_tokens(span.as_ref());
73− if tokens.len() > 8190 {
74− tokens.truncate(8190);
75+ if tokens.len() > INPUT_LIMIT {
76+ tokens.truncate(INPUT_LIMIT);
7577 let result = OPENAI_BPE_TOKENIZER.decode(tokens.clone());
7678 if result.is_ok() {
7779 let transformed = result.unwrap();
@@ -80,7 +82,7 @@ impl OpenAIEmbeddings { · 2 unmodified lines
8082 }
8183 }
8284
83− return span.to_string();
85+ span
8486 }
8587
8688 async fn send_request(&self, api_key: &str, spans: Vec<&str>) -> Result<Response<AsyncBody>> {
@@ -142,7 +144,7 @@ impl EmbeddingProvider for OpenAIEmbeddings { · 55 unmodified lines
142144 // Don't worry about delaying bad request, as we can assume
143145 // we haven't been rate limited yet.
144146 for span in spans.iter_mut() {
145− *span = Self::truncate(span.to_string()).await;
147+ *span = Self::truncate(span.to_string());
146148 }
147149 }
148150 StatusCode::OK => {
crates/terminal/src/terminal.rs+16−1
@@ -198,7 +198,7 @@ impl TerminalLineHeight { · 197 unmodified lines
198198 match self {
199199 TerminalLineHeight::Comfortable => 1.618,
200200 TerminalLineHeight::Standard => 1.3,
201− TerminalLineHeight::Custom(line_height) => *line_height,
201+ TerminalLineHeight::Custom(line_height) => f32::max(*line_height, 1.),
202202 }
203203 }
204204 }
@@ -908,6 +908,21 @@ impl Terminal { · 703 unmodified lines
908908 }
909909 }
910910
911+ pub fn select_matches(&mut self, matches: Vec<RangeInclusive<Point>>) {
912+ let matches_to_select = self
913+ .matches
914+ .iter()
915+ .filter(|self_match| matches.contains(self_match))
916+ .cloned()
917+ .collect::<Vec<_>>();
918+ for match_to_select in matches_to_select {
919+ self.set_selection(Some((
920+ make_selection(&match_to_select),
921+ *match_to_select.end(),
922+ )));
923+ }
924+ }
925+
911926 fn set_selection(&mut self, selection: Option<(Selection, Point)>) {
912927 self.events
913928 .push_back(InternalEvent::SetSelection(selection));
crates/terminal_view/src/terminal_view.rs+12−1
@@ -647,7 +647,11 @@ impl SearchableItem for TerminalView { · 646 unmodified lines
647647 }
648648
649649 /// Convert events raised by this item into search-relevant events (if applicable)
650− fn to_search_event(event: &Self::Event) -> Option<SearchEvent> {
650+ fn to_search_event(
651+ &mut self,
652+ event: &Self::Event,
653+ _: &mut ViewContext<Self>,
654+ ) -> Option<SearchEvent> {
651655 match event {
652656 Event::Wakeup => Some(SearchEvent::MatchesInvalidated),
653657 Event::SelectionsChanged => Some(SearchEvent::ActiveMatchChanged),
@@ -682,6 +686,13 @@ impl SearchableItem for TerminalView { · 28 unmodified lines
682686 cx.notify();
683687 }
684688
689+ /// Add selections for all matches given.
690+ fn select_matches(&mut self, matches: Vec<Self::Match>, cx: &mut ViewContext<Self>) {
691+ self.terminal()
692+ .update(cx, |term, _| term.select_matches(matches));
693+ cx.notify();
694+ }
695+
685696 /// Get all of the matches for this query, should be done on the background
686697 fn find_matches(
687698 &mut self,
crates/theme/src/theme.rs+4−2
@@ -350,6 +350,7 @@ pub struct Tab { · 349 unmodified lines
350350 pub icon_close_active: Color,
351351 pub icon_dirty: Color,
352352 pub icon_conflict: Color,
353+ pub git: GitProjectStatus,
353354 }
354355
355356 #[derive(Clone, Deserialize, Default, JsonSchema)]
@@ -379,6 +380,7 @@ pub struct Search { · 23 unmodified lines
379380 pub invalid_include_exclude_editor: ContainerStyle,
380381 pub include_exclude_inputs: ContainedText,
381382 pub option_button: Toggleable<Interactive<ContainedText>>,
383+ pub action_button: Interactive<ContainedText>,
382384 pub match_background: Color,
383385 pub match_index: ContainedText,
384386 pub results_status: TextStyle,
@@ -721,12 +723,12 @@ pub struct Scrollbar { · 336 unmodified lines
721723 pub thumb: ContainerStyle,
722724 pub width: f32,
723725 pub min_height_factor: f32,
724− pub git: GitDiffColors,
726+ pub git: BufferGitDiffColors,
725727 pub selections: Color,
726728 }
727729
728730 #[derive(Clone, Deserialize, Default, JsonSchema)]
729−pub struct GitDiffColors {
731+pub struct BufferGitDiffColors {
730732 pub inserted: Color,
731733 pub modified: Color,
732734 pub deleted: Color,
crates/theme/src/theme_registry.rs+17−5
@@ -5,6 +5,7 @@ use parking_lot::Mutex; · 4 unmodified lines
55 use serde::Deserialize;
66 use serde_json::Value;
77 use std::{
8+ borrow::Cow,
89 collections::HashMap,
910 sync::{
1011 atomic::{AtomicUsize, Ordering::SeqCst},
@@ -43,7 +44,7 @@ impl ThemeRegistry { · 32 unmodified lines
4344 this
4445 }
4546
46− pub fn list(&self, staff: bool) -> impl Iterator<Item = ThemeMeta> + '_ {
47+ pub fn list_names(&self, staff: bool) -> impl Iterator<Item = Cow<str>> + '_ {
4748 let mut dirs = self.assets.list("themes/");
4849
4950 if !staff {
@@ -53,10 +54,21 @@ impl ThemeRegistry { · 3 unmodified lines
5354 .collect()
5455 }
5556
56− dirs.into_iter().filter_map(|path| {
57− let filename = path.strip_prefix("themes/")?;
58− let theme_name = filename.strip_suffix(".json")?;
59− self.get(theme_name).ok().map(|theme| theme.meta.clone())
57+ fn get_name(path: &str) -> Option<&str> {
58+ path.strip_prefix("themes/")?.strip_suffix(".json")
59+ }
60+
61+ dirs.into_iter().filter_map(|path| match path {
62+ Cow::Borrowed(path) => Some(Cow::Borrowed(get_name(path)?)),
63+ Cow::Owned(path) => Some(Cow::Owned(get_name(&path)?.to_string())),
64+ })
65+ }
66+
67+ pub fn list(&self, staff: bool) -> impl Iterator<Item = ThemeMeta> + '_ {
68+ self.list_names(staff).filter_map(|theme_name| {
69+ self.get(theme_name.as_ref())
70+ .ok()
71+ .map(|theme| theme.meta.clone())
6072 })
6173 }
6274
crates/theme/src/theme_settings.rs+31−2
@@ -13,6 +13,7 @@ use std::sync::Arc; · 12 unmodified lines
1313 use util::ResultExt as _;
1414
1515 const MIN_FONT_SIZE: f32 = 6.0;
16+const MIN_LINE_HEIGHT: f32 = 1.0;
1617
1718 #[derive(Clone, JsonSchema)]
1819 pub struct ThemeSettings {
@@ -20,6 +21,7 @@ pub struct ThemeSettings { · 1 unmodified line
2021 pub buffer_font_features: fonts::Features,
2122 pub buffer_font_family: FamilyId,
2223 pub(crate) buffer_font_size: f32,
24+ pub(crate) buffer_line_height: BufferLineHeight,
2325 #[serde(skip)]
2426 pub theme: Arc<Theme>,
2527 }
@@ -33,11 +35,32 @@ pub struct ThemeSettingsContent { · 7 unmodified lines
3335 #[serde(default)]
3436 pub buffer_font_size: Option<f32>,
3537 #[serde(default)]
38+ pub buffer_line_height: Option<BufferLineHeight>,
39+ #[serde(default)]
3640 pub buffer_font_features: Option<fonts::Features>,
3741 #[serde(default)]
3842 pub theme: Option<String>,
3943 }
4044
45+#[derive(Clone, Copy, Debug, Serialize, Deserialize, PartialEq, JsonSchema, Default)]
46+#[serde(rename_all = "snake_case")]
47+pub enum BufferLineHeight {
48+ #[default]
49+ Comfortable,
50+ Standard,
51+ Custom(f32),
52+}
53+
54+impl BufferLineHeight {
55+ pub fn value(&self) -> f32 {
56+ match self {
57+ BufferLineHeight::Comfortable => 1.618,
58+ BufferLineHeight::Standard => 1.3,
59+ BufferLineHeight::Custom(line_height) => *line_height,
60+ }
61+ }
62+}
63+
4164 impl ThemeSettings {
4265 pub fn buffer_font_size(&self, cx: &AppContext) -> f32 {
4366 if cx.has_global::<AdjustedBufferFontSize>() {
@@ -47,6 +70,10 @@ impl ThemeSettings { · 3 unmodified lines
4770 }
4871 .max(MIN_FONT_SIZE)
4972 }
73+
74+ pub fn line_height(&self) -> f32 {
75+ f32::max(self.buffer_line_height.value(), MIN_LINE_HEIGHT)
76+ }
5077 }
5178
5279 pub fn adjusted_font_size(size: f32, cx: &AppContext) -> f32 {
@@ -106,6 +133,7 @@ impl settings::Setting for ThemeSettings { · 53 unmodified lines
106133 buffer_font_family_name: defaults.buffer_font_family.clone().unwrap(),
107134 buffer_font_features,
108135 buffer_font_size: defaults.buffer_font_size.unwrap(),
136+ buffer_line_height: defaults.buffer_line_height.unwrap(),
109137 theme: themes.get(defaults.theme.as_ref().unwrap()).unwrap(),
110138 };
111139
@@ -136,6 +164,7 @@ impl settings::Setting for ThemeSettings { · 24 unmodified lines
136164 }
137165
138166 merge(&mut this.buffer_font_size, value.buffer_font_size);
167+ merge(&mut this.buffer_line_height, value.buffer_line_height);
139168 }
140169
141170 Ok(this)
@@ -149,8 +178,8 @@ impl settings::Setting for ThemeSettings { · 7 unmodified lines
149178 let mut root_schema = generator.root_schema_for::<ThemeSettingsContent>();
150179 let theme_names = cx
151180 .global::<Arc<ThemeRegistry>>()
152− .list(params.staff_mode)
153− .map(|theme| Value::String(theme.name.clone()))
181+ .list_names(params.staff_mode)
182+ .map(|theme_name| Value::String(theme_name.to_string()))
154183 .collect();
155184
156185 let theme_name_schema = SchemaObject {
crates/theme_selector/src/theme_selector.rs+1−1
@@ -120,7 +120,7 @@ impl PickerDelegate for ThemeSelectorDelegate { · 119 unmodified lines
120120 self.matches.len()
121121 }
122122
123− fn confirm(&mut self, cx: &mut ViewContext<ThemeSelector>) {
123+ fn confirm(&mut self, _: bool, cx: &mut ViewContext<ThemeSelector>) {
124124 self.selection_completed = true;
125125
126126 let theme_name = theme::current(cx).meta.name.clone();
crates/vcs_menu/src/lib.rs+10−6
@@ -106,12 +106,14 @@ impl PickerDelegate for BranchListDelegate { · 105 unmodified lines
106106 .read_with(&mut cx, |view, cx| {
107107 let delegate = view.delegate();
108108 let project = delegate.workspace.read(cx).project().read(&cx);
109− let mut cwd =
110− project
109+
110+ let Some(worktree) = project
111111 .visible_worktrees(cx)
112112 .next()
113− .unwrap()
114− .read(cx)
113+ else {
114+ bail!("Cannot update branch list as there are no visible worktrees")
115+ };
116+ let mut cwd = worktree .read(cx)
115117 .abs_path()
116118 .to_path_buf();
117119 cwd.push(".git");
@@ -180,9 +182,11 @@ impl PickerDelegate for BranchListDelegate { · 62 unmodified lines
180182 })
181183 }
182184
183− fn confirm(&mut self, cx: &mut ViewContext<Picker<Self>>) {
185+ fn confirm(&mut self, _: bool, cx: &mut ViewContext<Picker<Self>>) {
184186 let current_pick = self.selected_index();
185− let current_pick = self.matches[current_pick].string.clone();
187+ let Some(current_pick) = self.matches.get(current_pick).map(|pick| pick.string.clone()) else {
188+ return;
189+ };
186190 cx.spawn(|picker, mut cx| async move {
187191 picker
188192 .update(&mut cx, |this, cx| {
crates/welcome/src/base_keymap_picker.rs+1−1
@@ -120,7 +120,7 @@ impl PickerDelegate for BaseKeymapSelectorDelegate { · 119 unmodified lines
120120 })
121121 }
122122
123− fn confirm(&mut self, cx: &mut ViewContext<BaseKeymapSelector>) {
123+ fn confirm(&mut self, _: bool, cx: &mut ViewContext<BaseKeymapSelector>) {
124124 if let Some(selection) = self.matches.get(self.selected_index) {
125125 let base_keymap = BaseKeymap::from_names(&selection.string);
126126 update_settings_file::<BaseKeymap>(self.fs.clone(), cx, move |setting| {
crates/workspace/src/item.rs+46−0
@@ -10,6 +10,9 @@ use gpui::{ · 9 unmodified lines
1010 ViewContext, ViewHandle, WeakViewHandle, WindowContext,
1111 };
1212 use project::{Project, ProjectEntryId, ProjectPath};
13+use schemars::JsonSchema;
14+use serde_derive::{Deserialize, Serialize};
15+use settings::Setting;
1316 use smallvec::SmallVec;
1417 use std::{
1518 any::{Any, TypeId},
@@ -27,6 +30,49 @@ use std::{ · 11 unmodified lines
2730 };
2831 use theme::Theme;
2932
33+#[derive(Deserialize)]
34+pub struct ItemSettings {
35+ pub git_status: bool,
36+ pub close_position: ClosePosition,
37+}
38+
39+#[derive(Clone, Default, Serialize, Deserialize, JsonSchema)]
40+#[serde(rename_all = "lowercase")]
41+pub enum ClosePosition {
42+ Left,
43+ #[default]
44+ Right,
45+}
46+
47+impl ClosePosition {
48+ pub fn right(&self) -> bool {
49+ match self {
50+ ClosePosition::Left => false,
51+ ClosePosition::Right => true,
52+ }
53+ }
54+}
55+
56+#[derive(Clone, Default, Serialize, Deserialize, JsonSchema)]
57+pub struct ItemSettingsContent {
58+ git_status: Option<bool>,
59+ close_position: Option<ClosePosition>,
60+}
61+
62+impl Setting for ItemSettings {
63+ const KEY: Option<&'static str> = Some("tabs");
64+
65+ type FileContent = ItemSettingsContent;
66+
67+ fn load(
68+ default_value: &Self::FileContent,
69+ user_values: &[&Self::FileContent],
70+ _: &gpui::AppContext,
71+ ) -> anyhow::Result<Self> {
72+ Self::load_via_json_merge(default_value, user_values)
73+ }
74+}
75+
3076 #[derive(Eq, PartialEq, Hash, Debug)]
3177 pub enum ItemEvent {
3278 CloseItem,
crates/workspace/src/pane.rs+106−73
@@ -3,14 +3,16 @@ mod dragged_item_receiver; · 2 unmodified lines
33 use super::{ItemHandle, SplitDirection};
44 pub use crate::toolbar::Toolbar;
55 use crate::{
6− item::WeakItemHandle, notify_of_new_dock, AutosaveSetting, Item, NewCenterTerminal, NewFile,
7− NewSearch, ToggleZoom, Workspace, WorkspaceSettings,
6+ item::{ItemSettings, WeakItemHandle},
7+ notify_of_new_dock, AutosaveSetting, Item, NewCenterTerminal, NewFile, NewSearch, ToggleZoom,
8+ Workspace, WorkspaceSettings,
89 };
910 use anyhow::Result;
1011 use collections::{HashMap, HashSet, VecDeque};
1112 use context_menu::{ContextMenu, ContextMenuItem};
1213 use drag_and_drop::{DragAndDrop, Draggable};
1314 use dragged_item_receiver::dragged_item_receiver;
15+use fs::repository::GitFileStatus;
1416 use futures::StreamExt;
1517 use gpui::{
1618 actions,
@@ -866,6 +868,7 @@ impl Pane { · 849 unmodified lines
866868 .paths_by_item
867869 .get(&item.id())
868870 .and_then(|(_, abs_path)| abs_path.clone());
871+
869872 self.nav_history
870873 .0
871874 .borrow_mut()
@@ -1157,6 +1160,11 @@ impl Pane { · 285 unmodified lines
11571160 .zip(self.tab_details(cx))
11581161 .enumerate()
11591162 {
1163+ let git_status = item
1164+ .project_path(cx)
1165+ .and_then(|path| self.project.read(cx).entry_for_path(&path, cx))
1166+ .and_then(|entry| entry.git_status());
1167+
11601168 let detail = if detail == 0 { None } else { Some(detail) };
11611169 let tab_active = ix == self.active_item_index;
11621170
@@ -1174,9 +1182,21 @@ impl Pane { · 11 unmodified lines
11741182 let tab_tooltip_text =
11751183 item.tab_tooltip_text(cx).map(|text| text.into_owned());
11761184
1185+ let mut tab_style = theme
1186+ .workspace
1187+ .tab_bar
1188+ .tab_style(pane_active, tab_active)
1189+ .clone();
1190+ let should_show_status = settings::get::<ItemSettings>(cx).git_status;
1191+ if should_show_status && git_status != None {
1192+ tab_style.label.text.color = match git_status.unwrap() {
1193+ GitFileStatus::Added => tab_style.git.inserted,
1194+ GitFileStatus::Modified => tab_style.git.modified,
1195+ GitFileStatus::Conflict => tab_style.git.conflict,
1196+ };
1197+ }
1198+
11771199 move |mouse_state, cx| {
1178− let tab_style =
1179− theme.workspace.tab_bar.tab_style(pane_active, tab_active);
11801200 let hovered = mouse_state.hovered();
11811201
11821202 enum Tab {}
@@ -1188,7 +1208,7 @@ impl Pane { · 5 unmodified lines
11881208 ix == 0,
11891209 detail,
11901210 hovered,
1191− tab_style,
1211+ &tab_style,
11921212 cx,
11931213 )
11941214 })
@@ -1350,81 +1370,94 @@ impl Pane { · 155 unmodified lines
13501370 container.border.left = false;
13511371 }
13521372
1353− Flex::row()
1354− .with_child({
1355− let diameter = 7.0;
1356− let icon_color = if item.has_conflict(cx) {
1357− Some(tab_style.icon_conflict)
1358− } else if item.is_dirty(cx) {
1359− Some(tab_style.icon_dirty)
1360− } else {
1361− None
1362− };
1373+ let buffer_jewel_element = {
1374+ let diameter = 7.0;
1375+ let icon_color = if item.has_conflict(cx) {
1376+ Some(tab_style.icon_conflict)
1377+ } else if item.is_dirty(cx) {
1378+ Some(tab_style.icon_dirty)
1379+ } else {
1380+ None
1381+ };
13631382
1364− Canvas::new(move |scene, bounds, _, _, _| {
1365− if let Some(color) = icon_color {
1366− let square = RectF::new(bounds.origin(), vec2f(diameter, diameter));
1367− scene.push_quad(Quad {
1368− bounds: square,
1369− background: Some(color),
1370− border: Default::default(),
1371− corner_radius: diameter / 2.,
1372− });
1373− }
1374− })
1375− .constrained()
1376− .with_width(diameter)
1377− .with_height(diameter)
1378− .aligned()
1383+ Canvas::new(move |scene, bounds, _, _, _| {
1384+ if let Some(color) = icon_color {
1385+ let square = RectF::new(bounds.origin(), vec2f(diameter, diameter));
1386+ scene.push_quad(Quad {
1387+ bounds: square,
1388+ background: Some(color),
1389+ border: Default::default(),
1390+ corner_radius: diameter / 2.,
1391+ });
1392+ }
13791393 })
1380− .with_child(title.aligned().contained().with_style(ContainerStyle {
1381− margin: Margin {
1382− left: tab_style.spacing,
1383− right: tab_style.spacing,
1384− ..Default::default()
1385− },
1394+ .constrained()
1395+ .with_width(diameter)
1396+ .with_height(diameter)
1397+ .aligned()
1398+ };
1399+
1400+ let title_element = title.aligned().contained().with_style(ContainerStyle {
1401+ margin: Margin {
1402+ left: tab_style.spacing,
1403+ right: tab_style.spacing,
13861404 ..Default::default()
1387− }))
1388− .with_child(
1389− if hovered {
1390− let item_id = item.id();
1391− enum TabCloseButton {}
1392− let icon = Svg::new("icons/x_mark_8.svg");
1393− MouseEventHandler::<TabCloseButton, _>::new(item_id, cx, |mouse_state, _| {
1394− if mouse_state.hovered() {
1395− icon.with_color(tab_style.icon_close_active)
1396− } else {
1397− icon.with_color(tab_style.icon_close)
1398− }
1399− })
1400− .with_padding(Padding::uniform(4.))
1401− .with_cursor_style(CursorStyle::PointingHand)
1402− .on_click(MouseButton::Left, {
1403− let pane = pane.clone();
1404− move |_, _, cx| {
1405− let pane = pane.clone();
1406− cx.window_context().defer(move |cx| {
1407− if let Some(pane) = pane.upgrade(cx) {
1408− pane.update(cx, |pane, cx| {
1409− pane.close_item_by_id(item_id, cx).detach_and_log_err(cx);
1410− });
1411− }
1405+ },
1406+ ..Default::default()
1407+ });
1408+
1409+ let close_element = if hovered {
1410+ let item_id = item.id();
1411+ enum TabCloseButton {}
1412+ let icon = Svg::new("icons/x_mark_8.svg");
1413+ MouseEventHandler::<TabCloseButton, _>::new(item_id, cx, |mouse_state, _| {
1414+ if mouse_state.hovered() {
1415+ icon.with_color(tab_style.icon_close_active)
1416+ } else {
1417+ icon.with_color(tab_style.icon_close)
1418+ }
1419+ })
1420+ .with_padding(Padding::uniform(4.))
1421+ .with_cursor_style(CursorStyle::PointingHand)
1422+ .on_click(MouseButton::Left, {
1423+ let pane = pane.clone();
1424+ move |_, _, cx| {
1425+ let pane = pane.clone();
1426+ cx.window_context().defer(move |cx| {
1427+ if let Some(pane) = pane.upgrade(cx) {
1428+ pane.update(cx, |pane, cx| {
1429+ pane.close_item_by_id(item_id, cx).detach_and_log_err(cx);
14121430 });
14131431 }
1414− })
1415− .into_any_named("close-tab-icon")
1416− .constrained()
1417− } else {
1418− Empty::new().constrained()
1432+ });
14191433 }
1420− .with_width(tab_style.close_icon_width)
1421− .aligned(),
1422− )
1423− .contained()
1424− .with_style(container)
1434+ })
1435+ .into_any_named("close-tab-icon")
14251436 .constrained()
1426− .with_height(tab_style.height)
1427− .into_any()
1437+ } else {
1438+ Empty::new().constrained()
1439+ }
1440+ .with_width(tab_style.close_icon_width)
1441+ .aligned();
1442+
1443+ let close_right = settings::get::<ItemSettings>(cx).close_position.right();
1444+
1445+ if close_right {
1446+ Flex::row()
1447+ .with_child(buffer_jewel_element)
1448+ .with_child(title_element)
1449+ .with_child(close_element)
1450+ } else {
1451+ Flex::row()
1452+ .with_child(close_element)
1453+ .with_child(title_element)
1454+ .with_child(buffer_jewel_element)
1455+ }
1456+ .contained()
1457+ .with_style(container)
1458+ .constrained()
1459+ .with_height(tab_style.height)
1460+ .into_any()
14281461 }
14291462
14301463 pub fn render_tab_bar_button<
crates/workspace/src/pane_group.rs+417−38
@@ -1,6 +1,8 @@
1−use std::sync::Arc;
1+use std::{cell::RefCell, rc::Rc, sync::Arc};
22
3−use crate::{AppState, FollowerStatesByLeader, Pane, Workspace, WorkspaceSettings};
3+use crate::{
4+ pane_group::element::PaneAxisElement, AppState, FollowerStatesByLeader, Pane, Workspace,
5+};
46 use anyhow::{anyhow, Result};
57 use call::{ActiveCall, ParticipantLocation};
68 use gpui::{
@@ -13,7 +15,11 @@ use project::Project; · 6 unmodified lines
1315 use serde::Deserialize;
1416 use theme::Theme;
1517
16−#[derive(Clone, Debug, Eq, PartialEq)]
18+const HANDLE_HITBOX_SIZE: f32 = 4.0;
19+const HORIZONTAL_MIN_SIZE: f32 = 80.;
20+const VERTICAL_MIN_SIZE: f32 = 100.;
21+
22+#[derive(Clone, Debug, PartialEq)]
1723 pub struct PaneGroup {
1824 pub(crate) root: Member,
1925 }
@@ -77,6 +83,7 @@ impl PaneGroup { · 57 unmodified lines
7783 ) -> AnyElement<Workspace> {
7884 self.root.render(
7985 project,
86+ 0,
8087 theme,
8188 follower_states,
8289 active_call,
@@ -94,7 +101,7 @@ impl PaneGroup { · 11 unmodified lines
94101 }
95102 }
96103
97−#[derive(Clone, Debug, Eq, PartialEq)]
104+#[derive(Clone, Debug, PartialEq)]
98105 pub(crate) enum Member {
99106 Axis(PaneAxis),
100107 Pane(ViewHandle<Pane>),
@@ -119,7 +126,7 @@ impl Member { · 18 unmodified lines
119126 Down | Right => vec![Member::Pane(old_pane), Member::Pane(new_pane)],
120127 };
121128
122− Member::Axis(PaneAxis { axis, members })
129+ Member::Axis(PaneAxis::new(axis, members))
123130 }
124131
125132 fn contains(&self, needle: &ViewHandle<Pane>) -> bool {
@@ -132,6 +139,7 @@ impl Member { · 6 unmodified lines
132139 pub fn render(
133140 &self,
134141 project: &ModelHandle<Project>,
142+ basis: usize,
135143 theme: &Theme,
136144 follower_states: &FollowerStatesByLeader,
137145 active_call: Option<&ModelHandle<ActiveCall>>,
@@ -272,6 +280,7 @@ impl Member { · 134 unmodified lines
272280 }
273281 Member::Axis(axis) => axis.render(
274282 project,
283+ basis + 1,
275284 theme,
276285 follower_states,
277286 active_call,
@@ -295,13 +304,35 @@ impl Member { · 17 unmodified lines
295304 }
296305 }
297306
298−#[derive(Clone, Debug, Eq, PartialEq)]
307+#[derive(Clone, Debug, PartialEq)]
299308 pub(crate) struct PaneAxis {
300309 pub axis: Axis,
301310 pub members: Vec<Member>,
311+ pub flexes: Rc<RefCell<Vec<f32>>>,
302312 }
303313
304314 impl PaneAxis {
315+ pub fn new(axis: Axis, members: Vec<Member>) -> Self {
316+ let flexes = Rc::new(RefCell::new(vec![1.; members.len()]));
317+ Self {
318+ axis,
319+ members,
320+ flexes,
321+ }
322+ }
323+
324+ pub fn load(axis: Axis, members: Vec<Member>, flexes: Option<Vec<f32>>) -> Self {
325+ let flexes = flexes.unwrap_or_else(|| vec![1.; members.len()]);
326+ debug_assert!(members.len() == flexes.len());
327+
328+ let flexes = Rc::new(RefCell::new(flexes));
329+ Self {
330+ axis,
331+ members,
332+ flexes,
333+ }
334+ }
335+
305336 fn split(
306337 &mut self,
307338 old_pane: &ViewHandle<Pane>,
@@ -323,6 +354,7 @@ impl PaneAxis { · 15 unmodified lines
323354 }
324355
325356 self.members.insert(idx, Member::Pane(new_pane.clone()));
357+ *self.flexes.borrow_mut() = vec![1.; self.members.len()];
326358 } else {
327359 *member =
328360 Member::new_axis(old_pane.clone(), new_pane.clone(), direction);
@@ -362,10 +394,13 @@ impl PaneAxis { · 33 unmodified lines
362394 if found_pane {
363395 if let Some(idx) = remove_member {
364396 self.members.remove(idx);
397+ *self.flexes.borrow_mut() = vec![1.; self.members.len()];
365398 }
366399
367400 if self.members.len() == 1 {
368− Ok(self.members.pop())
401+ let result = self.members.pop();
402+ *self.flexes.borrow_mut() = vec![1.; self.members.len()];
403+ Ok(result)
369404 } else {
370405 Ok(None)
371406 }
@@ -377,6 +412,7 @@ impl PaneAxis { · 5 unmodified lines
377412 fn render(
378413 &self,
379414 project: &ModelHandle<Project>,
415+ basis: usize,
380416 theme: &Theme,
381417 follower_state: &FollowerStatesByLeader,
382418 active_call: Option<&ModelHandle<ActiveCall>>,
@@ -385,40 +421,50 @@ impl PaneAxis { · 2 unmodified lines
385421 app_state: &Arc<AppState>,
386422 cx: &mut ViewContext<Workspace>,
387423 ) -> AnyElement<Workspace> {
388− let last_member_ix = self.members.len() - 1;
389− Flex::new(self.axis)
390− .with_children(self.members.iter().enumerate().map(|(ix, member)| {
391− let mut flex = 1.0;
392− if member.contains(active_pane) {
393− flex = settings::get::<WorkspaceSettings>(cx).active_pane_magnification;
394− }
424+ debug_assert!(self.members.len() == self.flexes.borrow().len());
395425
396− let mut member = member.render(
397− project,
398− theme,
399− follower_state,
400− active_call,
401− active_pane,
402− zoomed,
403− app_state,
404− cx,
405− );
406− if ix < last_member_ix {
407− let mut border = theme.workspace.pane_divider;
408− border.left = false;
409− border.right = false;
410− border.top = false;
411− border.bottom = false;
412− match self.axis {
413− Axis::Vertical => border.bottom = true,
414− Axis::Horizontal => border.right = true,
415− }
416− member = member.contained().with_border(border).into_any();
426+ let mut pane_axis = PaneAxisElement::new(self.axis, basis, self.flexes.clone());
427+ let mut active_pane_ix = None;
428+
429+ let mut members = self.members.iter().enumerate().peekable();
430+ while let Some((ix, member)) = members.next() {
431+ let last = members.peek().is_none();
432+
433+ if member.contains(active_pane) {
434+ active_pane_ix = Some(ix);
435+ }
436+
437+ let mut member = member.render(
438+ project,
439+ (basis + ix) * 10,
440+ theme,
441+ follower_state,
442+ active_call,
443+ active_pane,
444+ zoomed,
445+ app_state,
446+ cx,
447+ );
448+
449+ if !last {
450+ let mut border = theme.workspace.pane_divider;
451+ border.left = false;
452+ border.right = false;
453+ border.top = false;
454+ border.bottom = false;
455+
456+ match self.axis {
457+ Axis::Vertical => border.bottom = true,
458+ Axis::Horizontal => border.right = true,
417459 }
418460
419− FlexItem::new(member).flex(flex, true)
420− }))
421− .into_any()
461+ member = member.contained().with_border(border).into_any();
462+ }
463+
464+ pane_axis = pane_axis.with_child(member.into_any());
465+ }
466+ pane_axis.set_active_pane(active_pane_ix);
467+ pane_axis.into_any()
422468 }
423469 }
424470
@@ -474,3 +520,336 @@ impl SplitDirection { · 49 unmodified lines
474520 }
475521 }
476522 }
523+
524+mod element {
525+ use std::{cell::RefCell, ops::Range, rc::Rc};
526+
527+ use gpui::{
528+ geometry::{
529+ rect::RectF,
530+ vector::{vec2f, Vector2F},
531+ },
532+ json::{self, ToJson},
533+ platform::{CursorStyle, MouseButton},
534+ AnyElement, Axis, CursorRegion, Element, LayoutContext, MouseRegion, RectFExt,
535+ SceneBuilder, SizeConstraint, Vector2FExt, ViewContext,
536+ };
537+
538+ use crate::{
539+ pane_group::{HANDLE_HITBOX_SIZE, HORIZONTAL_MIN_SIZE, VERTICAL_MIN_SIZE},
540+ Workspace, WorkspaceSettings,
541+ };
542+
543+ pub struct PaneAxisElement {
544+ axis: Axis,
545+ basis: usize,
546+ active_pane_ix: Option<usize>,
547+ flexes: Rc<RefCell<Vec<f32>>>,
548+ children: Vec<AnyElement<Workspace>>,
549+ }
550+
551+ impl PaneAxisElement {
552+ pub fn new(axis: Axis, basis: usize, flexes: Rc<RefCell<Vec<f32>>>) -> Self {
553+ Self {
554+ axis,
555+ basis,
556+ flexes,
557+ active_pane_ix: None,
558+ children: Default::default(),
559+ }
560+ }
561+
562+ pub fn set_active_pane(&mut self, active_pane_ix: Option<usize>) {
563+ self.active_pane_ix = active_pane_ix;
564+ }
565+
566+ fn layout_children(
567+ &mut self,
568+ active_pane_magnification: f32,
569+ constraint: SizeConstraint,
570+ remaining_space: &mut f32,
571+ remaining_flex: &mut f32,
572+ cross_axis_max: &mut f32,
573+ view: &mut Workspace,
574+ cx: &mut LayoutContext<Workspace>,
575+ ) {
576+ let flexes = self.flexes.borrow();
577+ let cross_axis = self.axis.invert();
578+ for (ix, child) in self.children.iter_mut().enumerate() {
579+ let flex = if active_pane_magnification != 1. {
580+ if let Some(active_pane_ix) = self.active_pane_ix {
581+ if ix == active_pane_ix {
582+ active_pane_magnification
583+ } else {
584+ 1.
585+ }
586+ } else {
587+ 1.
588+ }
589+ } else {
590+ flexes[ix]
591+ };
592+
593+ let child_size = if *remaining_flex == 0.0 {
594+ *remaining_space
595+ } else {
596+ let space_per_flex = *remaining_space / *remaining_flex;
597+ space_per_flex * flex
598+ };
599+
600+ let child_constraint = match self.axis {
601+ Axis::Horizontal => SizeConstraint::new(
602+ vec2f(child_size, constraint.min.y()),
603+ vec2f(child_size, constraint.max.y()),
604+ ),
605+ Axis::Vertical => SizeConstraint::new(
606+ vec2f(constraint.min.x(), child_size),
607+ vec2f(constraint.max.x(), child_size),
608+ ),
609+ };
610+ let child_size = child.layout(child_constraint, view, cx);
611+ *remaining_space -= child_size.along(self.axis);
612+ *remaining_flex -= flex;
613+ *cross_axis_max = cross_axis_max.max(child_size.along(cross_axis));
614+ }
615+ }
616+ }
617+
618+ impl Extend<AnyElement<Workspace>> for PaneAxisElement {
619+ fn extend<T: IntoIterator<Item = AnyElement<Workspace>>>(&mut self, children: T) {
620+ self.children.extend(children);
621+ }
622+ }
623+
624+ impl Element<Workspace> for PaneAxisElement {
625+ type LayoutState = f32;
626+ type PaintState = ();
627+
628+ fn layout(
629+ &mut self,
630+ constraint: SizeConstraint,
631+ view: &mut Workspace,
632+ cx: &mut LayoutContext<Workspace>,
633+ ) -> (Vector2F, Self::LayoutState) {
634+ debug_assert!(self.children.len() == self.flexes.borrow().len());
635+
636+ let active_pane_magnification =
637+ settings::get::<WorkspaceSettings>(cx).active_pane_magnification;
638+
639+ let mut remaining_flex = 0.;
640+
641+ if active_pane_magnification != 1. {
642+ let active_pane_flex = self
643+ .active_pane_ix
644+ .map(|_| active_pane_magnification)
645+ .unwrap_or(1.);
646+ remaining_flex += self.children.len() as f32 - 1. + active_pane_flex;
647+ } else {
648+ for flex in self.flexes.borrow().iter() {
649+ remaining_flex += flex;
650+ }
651+ }
652+
653+ let mut cross_axis_max: f32 = 0.0;
654+ let mut remaining_space = constraint.max_along(self.axis);
655+
656+ if remaining_space.is_infinite() {
657+ panic!("flex contains flexible children but has an infinite constraint along the flex axis");
658+ }
659+
660+ self.layout_children(
661+ active_pane_magnification,
662+ constraint,
663+ &mut remaining_space,
664+ &mut remaining_flex,
665+ &mut cross_axis_max,
666+ view,
667+ cx,
668+ );
669+
670+ let mut size = match self.axis {
671+ Axis::Horizontal => vec2f(constraint.max.x() - remaining_space, cross_axis_max),
672+ Axis::Vertical => vec2f(cross_axis_max, constraint.max.y() - remaining_space),
673+ };
674+
675+ if constraint.min.x().is_finite() {
676+ size.set_x(size.x().max(constraint.min.x()));
677+ }
678+ if constraint.min.y().is_finite() {
679+ size.set_y(size.y().max(constraint.min.y()));
680+ }
681+
682+ if size.x() > constraint.max.x() {
683+ size.set_x(constraint.max.x());
684+ }
685+ if size.y() > constraint.max.y() {
686+ size.set_y(constraint.max.y());
687+ }
688+
689+ (size, remaining_space)
690+ }
691+
692+ fn paint(
693+ &mut self,
694+ scene: &mut SceneBuilder,
695+ bounds: RectF,
696+ visible_bounds: RectF,
697+ remaining_space: &mut Self::LayoutState,
698+ view: &mut Workspace,
699+ cx: &mut ViewContext<Workspace>,
700+ ) -> Self::PaintState {
701+ let can_resize = settings::get::<WorkspaceSettings>(cx).active_pane_magnification == 1.;
702+ let visible_bounds = bounds.intersection(visible_bounds).unwrap_or_default();
703+
704+ let overflowing = *remaining_space < 0.;
705+ if overflowing {
706+ scene.push_layer(Some(visible_bounds));
707+ }
708+
709+ let mut child_origin = bounds.origin();
710+
711+ let mut children_iter = self.children.iter_mut().enumerate().peekable();
712+ while let Some((ix, child)) = children_iter.next() {
713+ let child_start = child_origin.clone();
714+ child.paint(scene, child_origin, visible_bounds, view, cx);
715+
716+ match self.axis {
717+ Axis::Horizontal => child_origin += vec2f(child.size().x(), 0.0),
718+ Axis::Vertical => child_origin += vec2f(0.0, child.size().y()),
719+ }
720+
721+ if let Some(Some((next_ix, next_child))) = can_resize.then(|| children_iter.peek())
722+ {
723+ scene.push_stacking_context(None, None);
724+
725+ let handle_origin = match self.axis {
726+ Axis::Horizontal => child_origin - vec2f(HANDLE_HITBOX_SIZE / 2., 0.0),
727+ Axis::Vertical => child_origin - vec2f(0.0, HANDLE_HITBOX_SIZE / 2.),
728+ };
729+
730+ let handle_bounds = match self.axis {
731+ Axis::Horizontal => RectF::new(
732+ handle_origin,
733+ vec2f(HANDLE_HITBOX_SIZE, visible_bounds.height()),
734+ ),
735+ Axis::Vertical => RectF::new(
736+ handle_origin,
737+ vec2f(visible_bounds.width(), HANDLE_HITBOX_SIZE),
738+ ),
739+ };
740+
741+ let style = match self.axis {
742+ Axis::Horizontal => CursorStyle::ResizeLeftRight,
743+ Axis::Vertical => CursorStyle::ResizeUpDown,
744+ };
745+
746+ scene.push_cursor_region(CursorRegion {
747+ bounds: handle_bounds,
748+ style,
749+ });
750+
751+ let axis = self.axis;
752+ let child_size = child.size();
753+ let next_child_size = next_child.size();
754+ let drag_bounds = visible_bounds.clone();
755+ let flexes = self.flexes.clone();
756+ let current_flex = flexes.borrow()[ix];
757+ let next_ix = *next_ix;
758+ let next_flex = flexes.borrow()[next_ix];
759+ enum ResizeHandle {}
760+ let mut mouse_region = MouseRegion::new::<ResizeHandle>(
761+ cx.view_id(),
762+ self.basis + ix,
763+ handle_bounds,
764+ );
765+ mouse_region = mouse_region.on_drag(
766+ MouseButton::Left,
767+ move |drag, workspace: &mut Workspace, cx| {
768+ let min_size = match axis {
769+ Axis::Horizontal => HORIZONTAL_MIN_SIZE,
770+ Axis::Vertical => VERTICAL_MIN_SIZE,
771+ };
772+ // Don't allow resizing to less than the minimum size, if elements are already too small
773+ if min_size - 1. > child_size.along(axis)
774+ || min_size - 1. > next_child_size.along(axis)
775+ {
776+ return;
777+ }
778+
779+ let mut current_target_size = (drag.position - child_start).along(axis);
780+
781+ let proposed_current_pixel_change =
782+ current_target_size - child_size.along(axis);
783+
784+ if proposed_current_pixel_change < 0. {
785+ current_target_size = f32::max(current_target_size, min_size);
786+ } else if proposed_current_pixel_change > 0. {
787+ // TODO: cascade this change to other children if current item is at min size
788+ let next_target_size = f32::max(
789+ next_child_size.along(axis) - proposed_current_pixel_change,
790+ min_size,
791+ );
792+ current_target_size = f32::min(
793+ current_target_size,
794+ child_size.along(axis) + next_child_size.along(axis)
795+ - next_target_size,
796+ );
797+ }
798+
799+ let current_pixel_change = current_target_size - child_size.along(axis);
800+ let flex_change = current_pixel_change / drag_bounds.length_along(axis);
801+ let current_target_flex = current_flex + flex_change;
802+ let next_target_flex = next_flex - flex_change;
803+
804+ let mut borrow = flexes.borrow_mut();
805+ *borrow.get_mut(ix).unwrap() = current_target_flex;
806+ *borrow.get_mut(next_ix).unwrap() = next_target_flex;
807+
808+ workspace.schedule_serialize(cx);
809+ cx.notify();
810+ },
811+ );
812+ scene.push_mouse_region(mouse_region);
813+
814+ scene.pop_stacking_context();
815+ }
816+ }
817+
818+ if overflowing {
819+ scene.pop_layer();
820+ }
821+ }
822+
823+ fn rect_for_text_range(
824+ &self,
825+ range_utf16: Range<usize>,
826+ _: RectF,
827+ _: RectF,
828+ _: &Self::LayoutState,
829+ _: &Self::PaintState,
830+ view: &Workspace,
831+ cx: &ViewContext<Workspace>,
832+ ) -> Option<RectF> {
833+ self.children
834+ .iter()
835+ .find_map(|child| child.rect_for_text_range(range_utf16.clone(), view, cx))
836+ }
837+
838+ fn debug(
839+ &self,
840+ bounds: RectF,
841+ _: &Self::LayoutState,
842+ _: &Self::PaintState,
843+ view: &Workspace,
844+ cx: &ViewContext<Workspace>,
845+ ) -> json::Value {
846+ serde_json::json!({
847+ "type": "PaneAxis",
848+ "bounds": bounds.to_json(),
849+ "axis": self.axis.to_json(),
850+ "flexes": *self.flexes.borrow(),
851+ "children": self.children.iter().map(|child| child.debug(view, cx)).collect::<Vec<json::Value>>()
852+ })
853+ }
854+ }
855+}
crates/workspace/src/persistence.rs+101−54
@@ -45,6 +45,7 @@ define_connection! { · 44 unmodified lines
4545 // parent_group_id: Option<usize>, // None indicates that this is the root node
4646 // position: Optiopn<usize>, // None indicates that this is the root node
4747 // axis: Option<Axis>, // 'Vertical', 'Horizontal'
48+ // flexes: Option<Vec<f32>>, // A JSON array of floats
4849 // )
4950 //
5051 // panes(
@@ -168,7 +169,12 @@ define_connection! { · 117 unmodified lines
168169 ALTER TABLE workspaces ADD COLUMN left_dock_zoom INTEGER; //bool
169170 ALTER TABLE workspaces ADD COLUMN right_dock_zoom INTEGER; //bool
170171 ALTER TABLE workspaces ADD COLUMN bottom_dock_zoom INTEGER; //bool
171− )];
172+ ),
173+ // Add pane group flex data
174+ sql!(
175+ ALTER TABLE pane_groups ADD COLUMN flexes TEXT;
176+ )
177+ ];
172178 }
173179
174180 impl WorkspaceDb {
@@ -359,38 +365,51 @@ impl WorkspaceDb { · 184 unmodified lines
359365 group_id: Option<GroupId>,
360366 ) -> Result<Vec<SerializedPaneGroup>> {
361367 type GroupKey = (Option<GroupId>, WorkspaceId);
362− type GroupOrPane = (Option<GroupId>, Option<Axis>, Option<PaneId>, Option<bool>);
368+ type GroupOrPane = (
369+ Option<GroupId>,
370+ Option<Axis>,
371+ Option<PaneId>,
372+ Option<bool>,
373+ Option<String>,
374+ );
363375 self.select_bound::<GroupKey, GroupOrPane>(sql!(
364− SELECT group_id, axis, pane_id, active
376+ SELECT group_id, axis, pane_id, active, flexes
365377 FROM (SELECT
366− group_id,
367− axis,
368− NULL as pane_id,
369− NULL as active,
370− position,
371− parent_group_id,
372− workspace_id
373− FROM pane_groups
378+ group_id,
379+ axis,
380+ NULL as pane_id,
381+ NULL as active,
382+ position,
383+ parent_group_id,
384+ workspace_id,
385+ flexes
386+ FROM pane_groups
374387 UNION
375− SELECT
376− NULL,
377− NULL,
378− center_panes.pane_id,
379− panes.active as active,
380− position,
381− parent_group_id,
382− panes.workspace_id as workspace_id
383− FROM center_panes
384− JOIN panes ON center_panes.pane_id = panes.pane_id)
388+ SELECT
389+ NULL,
390+ NULL,
391+ center_panes.pane_id,
392+ panes.active as active,
393+ position,
394+ parent_group_id,
395+ panes.workspace_id as workspace_id,
396+ NULL
397+ FROM center_panes
398+ JOIN panes ON center_panes.pane_id = panes.pane_id)
385399 WHERE parent_group_id IS ? AND workspace_id = ?
386400 ORDER BY position
387401 ))?((group_id, workspace_id))?
388402 .into_iter()
389− .map(|(group_id, axis, pane_id, active)| {
403+ .map(|(group_id, axis, pane_id, active, flexes)| {
390404 if let Some((group_id, axis)) = group_id.zip(axis) {
405+ let flexes = flexes
406+ .map(|flexes| serde_json::from_str::<Vec<f32>>(&flexes))
407+ .transpose()?;
408+
391409 Ok(SerializedPaneGroup::Group {
392410 axis,
393411 children: self.get_pane_group(workspace_id, Some(group_id))?,
412+ flexes,
394413 })
395414 } else if let Some((pane_id, active)) = pane_id.zip(active) {
396415 Ok(SerializedPaneGroup::Pane(SerializedPane::new(
@@ -417,14 +436,34 @@ impl WorkspaceDb { · 20 unmodified lines
417436 parent: Option<(GroupId, usize)>,
418437 ) -> Result<()> {
419438 match pane_group {
420− SerializedPaneGroup::Group { axis, children } => {
439+ SerializedPaneGroup::Group {
440+ axis,
441+ children,
442+ flexes,
443+ } => {
421444 let (parent_id, position) = unzip_option(parent);
422445
446+ let flex_string = flexes
447+ .as_ref()
448+ .map(|flexes| serde_json::json!(flexes).to_string());
449+
423450 let group_id = conn.select_row_bound::<_, i64>(sql!(
424− INSERT INTO pane_groups(workspace_id, parent_group_id, position, axis)
425− VALUES (?, ?, ?, ?)
451+ INSERT INTO pane_groups(
452+ workspace_id,
453+ parent_group_id,
454+ position,
455+ axis,
456+ flexes
457+ )
458+ VALUES (?, ?, ?, ?, ?)
426459 RETURNING group_id
427− ))?((workspace_id, parent_id, position, *axis))?
460+ ))?((
461+ workspace_id,
462+ parent_id,
463+ position,
464+ *axis,
465+ flex_string,
466+ ))?
428467 .ok_or_else(|| anyhow!("Couldn't retrieve group_id from inserted pane_group"))?;
429468
430469 for (position, group) in children.iter().enumerate() {
@@ -641,6 +680,14 @@ mod tests { · 210 unmodified lines
641680 assert_eq!(test_text_1, "test-text-1");
642681 }
643682
683+ fn group(axis: gpui::Axis, children: Vec<SerializedPaneGroup>) -> SerializedPaneGroup {
684+ SerializedPaneGroup::Group {
685+ axis,
686+ flexes: None,
687+ children,
688+ }
689+ }
690+
644691 #[gpui::test]
645692 async fn test_full_workspace_serialization() {
646693 env_logger::try_init().ok();
@@ -652,12 +699,12 @@ mod tests { · 5 unmodified lines
652699 // | - - - | |
653700 // | 3,4 | |
654701 // -----------------
655− let center_group = SerializedPaneGroup::Group {
656− axis: gpui::Axis::Horizontal,
657− children: vec![
658− SerializedPaneGroup::Group {
659− axis: gpui::Axis::Vertical,
660− children: vec![
702+ let center_group = group(
703+ gpui::Axis::Horizontal,
704+ vec![
705+ group(
706+ gpui::Axis::Vertical,
707+ vec![
661708 SerializedPaneGroup::Pane(SerializedPane::new(
662709 vec![
663710 SerializedItem::new("Terminal", 5, false),
@@ -673,7 +720,7 @@ mod tests { · 9 unmodified lines
673720 false,
674721 )),
675722 ],
676− },
723+ ),
677724 SerializedPaneGroup::Pane(SerializedPane::new(
678725 vec![
679726 SerializedItem::new("Terminal", 9, false),
@@ -682,7 +729,7 @@ mod tests { · 2 unmodified lines
682729 false,
683730 )),
684731 ],
685− };
732+ );
686733
687734 let workspace = SerializedWorkspace {
688735 id: 5,
@@ -811,12 +858,12 @@ mod tests { · 122 unmodified lines
811858 // | - - - | |
812859 // | 3,4 | |
813860 // -----------------
814− let center_pane = SerializedPaneGroup::Group {
815− axis: gpui::Axis::Horizontal,
816− children: vec![
817− SerializedPaneGroup::Group {
818− axis: gpui::Axis::Vertical,
819− children: vec![
861+ let center_pane = group(
862+ gpui::Axis::Horizontal,
863+ vec![
864+ group(
865+ gpui::Axis::Vertical,
866+ vec![
820867 SerializedPaneGroup::Pane(SerializedPane::new(
821868 vec![
822869 SerializedItem::new("Terminal", 1, false),
@@ -832,7 +879,7 @@ mod tests { · 9 unmodified lines
832879 true,
833880 )),
834881 ],
835− },
882+ ),
836883 SerializedPaneGroup::Pane(SerializedPane::new(
837884 vec![
838885 SerializedItem::new("Terminal", 5, true),
@@ -841,7 +888,7 @@ mod tests { · 2 unmodified lines
841888 false,
842889 )),
843890 ],
844− };
891+ );
845892
846893 let workspace = default_workspace(&["/tmp"], &center_pane);
847894
@@ -858,12 +905,12 @@ mod tests { · 10 unmodified lines
858905
859906 let db = WorkspaceDb(open_test_db("test_cleanup_panes").await);
860907
861− let center_pane = SerializedPaneGroup::Group {
862− axis: gpui::Axis::Horizontal,
863− children: vec![
864− SerializedPaneGroup::Group {
865− axis: gpui::Axis::Vertical,
866− children: vec![
908+ let center_pane = group(
909+ gpui::Axis::Horizontal,
910+ vec![
911+ group(
912+ gpui::Axis::Vertical,
913+ vec![
867914 SerializedPaneGroup::Pane(SerializedPane::new(
868915 vec![
869916 SerializedItem::new("Terminal", 1, false),
@@ -879,7 +926,7 @@ mod tests { · 9 unmodified lines
879926 true,
880927 )),
881928 ],
882− },
929+ ),
883930 SerializedPaneGroup::Pane(SerializedPane::new(
884931 vec![
885932 SerializedItem::new("Terminal", 5, false),
@@ -888,7 +935,7 @@ mod tests { · 2 unmodified lines
888935 false,
889936 )),
890937 ],
891− };
938+ );
892939
893940 let id = &["/tmp"];
894941
@@ -896,9 +943,9 @@ mod tests { · 1 unmodified line
896943
897944 db.save_workspace(workspace.clone()).await;
898945
899− workspace.center_group = SerializedPaneGroup::Group {
900− axis: gpui::Axis::Vertical,
901− children: vec![
946+ workspace.center_group = group(
947+ gpui::Axis::Vertical,
948+ vec![
902949 SerializedPaneGroup::Pane(SerializedPane::new(
903950 vec![
904951 SerializedItem::new("Terminal", 1, false),
@@ -914,7 +961,7 @@ mod tests { · 9 unmodified lines
914961 true,
915962 )),
916963 ],
917− };
964+ );
918965
919966 db.save_workspace(workspace.clone()).await;
920967
crates/workspace/src/persistence/model.rs+9−7
@@ -127,10 +127,11 @@ impl Bind for DockData { · 126 unmodified lines
127127 }
128128 }
129129
130−#[derive(Debug, PartialEq, Eq, Clone)]
130+#[derive(Debug, PartialEq, Clone)]
131131 pub enum SerializedPaneGroup {
132132 Group {
133133 axis: Axis,
134+ flexes: Option<Vec<f32>>,
134135 children: Vec<SerializedPaneGroup>,
135136 },
136137 Pane(SerializedPane),
@@ -149,7 +150,7 @@ impl Default for SerializedPaneGroup { · 12 unmodified lines
149150 impl SerializedPaneGroup {
150151 #[async_recursion(?Send)]
151152 pub(crate) async fn deserialize(
152− &self,
153+ self,
153154 project: &ModelHandle<Project>,
154155 workspace_id: WorkspaceId,
155156 workspace: &WeakViewHandle<Workspace>,
@@ -160,7 +161,11 @@ impl SerializedPaneGroup { · 4 unmodified lines
160161 Vec<Option<Box<dyn ItemHandle>>>,
161162 )> {
162163 match self {
163− SerializedPaneGroup::Group { axis, children } => {
164+ SerializedPaneGroup::Group {
165+ axis,
166+ children,
167+ flexes,
168+ } => {
164169 let mut current_active_pane = None;
165170 let mut members = Vec::new();
166171 let mut items = Vec::new();
@@ -184,10 +189,7 @@ impl SerializedPaneGroup { · 17 unmodified lines
184189 }
185190
186191 Some((
187− Member::Axis(PaneAxis {
188− axis: *axis,
189− members,
190− }),
192+ Member::Axis(PaneAxis::load(axis, members, flexes)),
191193 current_active_pane,
192194 items,
193195 ))
crates/workspace/src/searchable.rs+16−3
@@ -37,7 +37,11 @@ pub trait SearchableItem: Item { · 36 unmodified lines
3737 regex: true,
3838 }
3939 }
40− fn to_search_event(event: &Self::Event) -> Option<SearchEvent>;
40+ fn to_search_event(
41+ &mut self,
42+ event: &Self::Event,
43+ cx: &mut ViewContext<Self>,
44+ ) -> Option<SearchEvent>;
4145 fn clear_matches(&mut self, cx: &mut ViewContext<Self>);
4246 fn update_matches(&mut self, matches: Vec<Self::Match>, cx: &mut ViewContext<Self>);
4347 fn query_suggestion(&mut self, cx: &mut ViewContext<Self>) -> String;
@@ -47,6 +51,7 @@ pub trait SearchableItem: Item { · 3 unmodified lines
4751 matches: Vec<Self::Match>,
4852 cx: &mut ViewContext<Self>,
4953 );
54+ fn select_matches(&mut self, matches: Vec<Self::Match>, cx: &mut ViewContext<Self>);
5055 fn match_index_for_direction(
5156 &mut self,
5257 matches: &Vec<Self::Match>,
@@ -102,6 +107,7 @@ pub trait SearchableItemHandle: ItemHandle { · 49 unmodified lines
102107 matches: &Vec<Box<dyn Any + Send>>,
103108 cx: &mut WindowContext,
104109 );
110+ fn select_matches(&self, matches: &Vec<Box<dyn Any + Send>>, cx: &mut WindowContext);
105111 fn match_index_for_direction(
106112 &self,
107113 matches: &Vec<Box<dyn Any + Send>>,
@@ -139,8 +145,9 @@ impl<T: SearchableItem> SearchableItemHandle for ViewHandle<T> { · 31 unmodified lines
139145 cx: &mut WindowContext,
140146 handler: Box<dyn Fn(SearchEvent, &mut WindowContext)>,
141147 ) -> Subscription {
142− cx.subscribe(self, move |_, event, cx| {
143− if let Some(search_event) = T::to_search_event(event) {
148+ cx.subscribe(self, move |handle, event, cx| {
149+ let search_event = handle.update(cx, |handle, cx| handle.to_search_event(event, cx));
150+ if let Some(search_event) = search_event {
144151 handler(search_event, cx)
145152 }
146153 })
@@ -165,6 +172,12 @@ impl<T: SearchableItem> SearchableItemHandle for ViewHandle<T> { · 18 unmodified lines
165172 let matches = downcast_matches(matches);
166173 self.update(cx, |this, cx| this.activate_match(index, matches, cx));
167174 }
175+
176+ fn select_matches(&self, matches: &Vec<Box<dyn Any + Send>>, cx: &mut WindowContext) {
177+ let matches = downcast_matches(matches);
178+ self.update(cx, |this, cx| this.select_matches(matches, cx));
179+ }
180+
168181 fn match_index_for_direction(
169182 &self,
170183 matches: &Vec<Box<dyn Any + Send>>,
crates/workspace/src/workspace.rs+113−25
@@ -1,8 +1,4 @@
11 pub mod dock;
2−/// NOTE: Focus only 'takes' after an update has flushed_effects.
3−///
4−/// This may cause issues when you're trying to write tests that use workspace focus to add items at
5−/// specific locations.
62 pub mod item;
73 pub mod notifications;
84 pub mod pane;
@@ -207,6 +203,7 @@ pub type WorkspaceId = i64; · 198 unmodified lines
207203
208204 pub fn init_settings(cx: &mut AppContext) {
209205 settings::register::<WorkspaceSettings>(cx);
206+ settings::register::<item::ItemSettings>(cx);
210207 }
211208
212209 pub fn init(app_state: Arc<AppState>, cx: &mut AppContext) {
@@ -508,6 +505,7 @@ pub struct Workspace { · 295 unmodified lines
508505 subscriptions: Vec<Subscription>,
509506 _apply_leader_updates: Task<Result<()>>,
510507 _observe_current_user: Task<Result<()>>,
508+ _schedule_serialize: Option<Task<()>>,
511509 pane_history_timestamp: Arc<AtomicUsize>,
512510 }
513511
@@ -722,6 +720,7 @@ impl Workspace { · 208 unmodified lines
722720 app_state,
723721 _observe_current_user,
724722 _apply_leader_updates,
723+ _schedule_serialize: None,
725724 leader_updates_tx,
726725 subscriptions,
727726 pane_history_timestamp,
@@ -1823,6 +1822,13 @@ impl Workspace { · 1095 unmodified lines
18231822 .update(cx, |pane, cx| pane.add_item(item, true, true, None, cx));
18241823 }
18251824
1825+ pub fn split_item(&mut self, item: Box<dyn ItemHandle>, cx: &mut ViewContext<Self>) {
1826+ let new_pane = self.split_pane(self.active_pane.clone(), SplitDirection::Right, cx);
1827+ new_pane.update(cx, move |new_pane, cx| {
1828+ new_pane.add_item(item, true, true, None, cx)
1829+ })
1830+ }
1831+
18261832 pub fn open_abs_path(
18271833 &mut self,
18281834 abs_path: PathBuf,
@@ -1853,6 +1859,21 @@ impl Workspace { · 24 unmodified lines
18531859 })
18541860 }
18551861
1862+ pub fn split_abs_path(
1863+ &mut self,
1864+ abs_path: PathBuf,
1865+ visible: bool,
1866+ cx: &mut ViewContext<Self>,
1867+ ) -> Task<anyhow::Result<Box<dyn ItemHandle>>> {
1868+ let project_path_task =
1869+ Workspace::project_path_for_path(self.project.clone(), &abs_path, visible, cx);
1870+ cx.spawn(|this, mut cx| async move {
1871+ let (_, path) = project_path_task.await?;
1872+ this.update(&mut cx, |this, cx| this.split_path(path, cx))?
1873+ .await
1874+ })
1875+ }
1876+
18561877 pub fn open_path(
18571878 &mut self,
18581879 path: impl Into<ProjectPath>,
@@ -1878,6 +1899,38 @@ impl Workspace { · 19 unmodified lines
18781899 })
18791900 }
18801901
1902+ pub fn split_path(
1903+ &mut self,
1904+ path: impl Into<ProjectPath>,
1905+ cx: &mut ViewContext<Self>,
1906+ ) -> Task<Result<Box<dyn ItemHandle>, anyhow::Error>> {
1907+ let pane = self.last_active_center_pane.clone().unwrap_or_else(|| {
1908+ self.panes
1909+ .first()
1910+ .expect("There must be an active pane")
1911+ .downgrade()
1912+ });
1913+
1914+ if let Member::Pane(center_pane) = &self.center.root {
1915+ if center_pane.read(cx).items_len() == 0 {
1916+ return self.open_path(path, Some(pane), true, cx);
1917+ }
1918+ }
1919+
1920+ let task = self.load_path(path.into(), cx);
1921+ cx.spawn(|this, mut cx| async move {
1922+ let (project_entry_id, build_item) = task.await?;
1923+ this.update(&mut cx, move |this, cx| -> Option<_> {
1924+ let pane = pane.upgrade(cx)?;
1925+ let new_pane = this.split_pane(pane, SplitDirection::Right, cx);
1926+ new_pane.update(cx, |new_pane, cx| {
1927+ Some(new_pane.open_item(project_entry_id, true, cx, build_item))
1928+ })
1929+ })
1930+ .map(|option| option.ok_or_else(|| anyhow!("pane was dropped")))?
1931+ })
1932+ }
1933+
18811934 pub(crate) fn load_path(
18821935 &mut self,
18831936 path: ProjectPath,
@@ -1928,6 +1981,30 @@ impl Workspace { · 44 unmodified lines
19281981 item
19291982 }
19301983
1984+ pub fn split_project_item<T>(
1985+ &mut self,
1986+ project_item: ModelHandle<T::Item>,
1987+ cx: &mut ViewContext<Self>,
1988+ ) -> ViewHandle<T>
1989+ where
1990+ T: ProjectItem,
1991+ {
1992+ use project::Item as _;
1993+
1994+ let entry_id = project_item.read(cx).entry_id(cx);
1995+ if let Some(item) = entry_id
1996+ .and_then(|entry_id| self.active_pane().read(cx).item_for_entry(entry_id, cx))
1997+ .and_then(|item| item.downcast())
1998+ {
1999+ self.activate_item(&item, cx);
2000+ return item;
2001+ }
2002+
2003+ let item = cx.add_view(|cx| T::for_project_item(self.project().clone(), project_item, cx));
2004+ self.split_item(Box::new(item.clone()), cx);
2005+ item
2006+ }
2007+
19312008 pub fn open_shared_screen(&mut self, peer_id: PeerId, cx: &mut ViewContext<Self>) {
19322009 if let Some(shared_screen) = self.shared_screen_for_peer(peer_id, &self.active_pane, cx) {
19332010 self.active_pane.update(cx, |pane, cx| {
@@ -1955,7 +2032,7 @@ impl Workspace { · 21 unmodified lines
19552032 if let Some(pane) = panes.get(action.0).map(|p| (*p).clone()) {
19562033 cx.focus(&pane);
19572034 } else {
1958− self.split_pane(self.active_pane.clone(), SplitDirection::Right, cx);
2035+ self.split_and_clone(self.active_pane.clone(), SplitDirection::Right, cx);
19592036 }
19602037 }
19612038
@@ -2008,7 +2085,7 @@ impl Workspace { · 46 unmodified lines
20082085 match event {
20092086 pane::Event::AddItem { item } => item.added_to_pane(self, pane, cx),
20102087 pane::Event::Split(direction) => {
2011− self.split_pane(pane, *direction, cx);
2088+ self.split_and_clone(pane, *direction, cx);
20122089 }
20132090 pane::Event::Remove => self.remove_pane(pane, cx),
20142091 pane::Event::ActivateItem { local } => {
@@ -2059,6 +2136,20 @@ impl Workspace { · 44 unmodified lines
20592136 }
20602137
20612138 pub fn split_pane(
2139+ &mut self,
2140+ pane_to_split: ViewHandle<Pane>,
2141+ split_direction: SplitDirection,
2142+ cx: &mut ViewContext<Self>,
2143+ ) -> ViewHandle<Pane> {
2144+ let new_pane = self.add_pane(cx);
2145+ self.center
2146+ .split(&pane_to_split, &new_pane, split_direction)
2147+ .unwrap();
2148+ cx.notify();
2149+ new_pane
2150+ }
2151+
2152+ pub fn split_and_clone(
20622153 &mut self,
20632154 pane: ViewHandle<Pane>,
20642155 direction: SplitDirection,
@@ -2897,6 +2988,14 @@ impl Workspace { · 832 unmodified lines
28972988 cx.notify();
28982989 }
28992990
2991+ fn schedule_serialize(&mut self, cx: &mut ViewContext<Self>) {
2992+ self._schedule_serialize = Some(cx.spawn(|this, cx| async move {
2993+ cx.background().timer(Duration::from_millis(100)).await;
2994+ this.read_with(&cx, |this, cx| this.serialize_workspace(cx))
2995+ .ok();
2996+ }));
2997+ }
2998+
29002999 fn serialize_workspace(&self, cx: &ViewContext<Self>) {
29013000 fn serialize_pane_handle(
29023001 pane_handle: &ViewHandle<Pane>,
@@ -2927,12 +3026,17 @@ impl Workspace { · 24 unmodified lines
29273026 cx: &AppContext,
29283027 ) -> SerializedPaneGroup {
29293028 match pane_group {
2930− Member::Axis(PaneAxis { axis, members }) => SerializedPaneGroup::Group {
3029+ Member::Axis(PaneAxis {
3030+ axis,
3031+ members,
3032+ flexes,
3033+ }) => SerializedPaneGroup::Group {
29313034 axis: *axis,
29323035 children: members
29333036 .iter()
29343037 .map(|member| build_serialized_pane_group(member, cx))
29353038 .collect::<Vec<_>>(),
3039+ flexes: Some(flexes.borrow().clone()),
29363040 },
29373041 Member::Pane(pane_handle) => {
29383042 SerializedPaneGroup::Pane(serialize_pane_handle(&pane_handle, cx))
@@ -3399,27 +3503,11 @@ fn notify_if_database_failed(workspace: &WeakViewHandle<Workspace>, cx: &mut Asy · 460 unmodified lines
33993503 if (*db::ALL_FILE_DB_FAILED).load(std::sync::atomic::Ordering::Acquire) {
34003504 workspace.show_notification_once(0, cx, |cx| {
34013505 cx.add_view(|_| {
3402− MessageNotification::new("Failed to load any database file.")
3506+ MessageNotification::new("Failed to load the database file.")
34033507 .with_click_message("Click to let us know about this error")
34043508 .on_click(|cx| cx.platform().open_url(REPORT_ISSUE_URL))
34053509 })
34063510 });
3407− } else {
3408− let backup_path = (*db::BACKUP_DB_PATH).read();
3409− if let Some(backup_path) = backup_path.clone() {
3410− workspace.show_notification_once(1, cx, move |cx| {
3411− cx.add_view(move |_| {
3412− MessageNotification::new(format!(
3413− "Database file was corrupted. Old database backed up to {}",
3414− backup_path.display()
3415− ))
3416− .with_click_message("Click to show old database in finder")
3417− .on_click(move |cx| {
3418− cx.platform().open_url(&backup_path.to_string_lossy())
3419− })
3420− })
3421− });
3422− }
34233511 }
34243512 })
34253513 .log_err();
@@ -4235,7 +4323,7 @@ mod tests { · 809 unmodified lines
42354323 });
42364324
42374325 workspace
4238− .split_pane(left_pane.clone(), SplitDirection::Right, cx)
4326+ .split_and_clone(left_pane.clone(), SplitDirection::Right, cx)
42394327 .unwrap();
42404328
42414329 left_pane
crates/zed/Cargo.toml+22−19
@@ -104,25 +104,28 @@ thiserror.workspace = true · 103 unmodified lines
104104 tiny_http = "0.8"
105105 toml.workspace = true
106106 tree-sitter.workspace = true
107−tree-sitter-c = "0.20.1"
108−tree-sitter-cpp = "0.20.0"
109−tree-sitter-css = { git = "https://github.com/tree-sitter/tree-sitter-css", rev = "769203d0f9abe1a9a691ac2b9fe4bb4397a73c51" }
110−tree-sitter-elixir = { git = "https://github.com/elixir-lang/tree-sitter-elixir", rev = "4ba9dab6e2602960d95b2b625f3386c27e08084e" }
111−tree-sitter-embedded-template = "0.20.0"
112−tree-sitter-go = { git = "https://github.com/tree-sitter/tree-sitter-go", rev = "aeb2f33b366fd78d5789ff104956ce23508b85db" }
113−tree-sitter-heex = { git = "https://github.com/phoenixframework/tree-sitter-heex", rev = "2e1348c3cf2c9323e87c2744796cf3f3868aa82a" }
114−tree-sitter-json = { git = "https://github.com/tree-sitter/tree-sitter-json", rev = "40a81c01a40ac48744e0c8ccabbaba1920441199" }
115−tree-sitter-rust = "0.20.3"
116−tree-sitter-markdown = { git = "https://github.com/MDeiml/tree-sitter-markdown", rev = "330ecab87a3e3a7211ac69bbadc19eabecdb1cca" }
117−tree-sitter-python = "0.20.2"
118−tree-sitter-toml = { git = "https://github.com/tree-sitter/tree-sitter-toml", rev = "342d9be207c2dba869b9967124c679b5e6fd0ebe" }
119−tree-sitter-typescript = { git = "https://github.com/tree-sitter/tree-sitter-typescript", rev = "5d20856f34315b068c41edaee2ac8a100081d259" }
120−tree-sitter-ruby = "0.20.0"
121−tree-sitter-html = "0.19.0"
122−tree-sitter-scheme = { git = "https://github.com/6cdh/tree-sitter-scheme", rev = "af0fd1fa452cb2562dc7b5c8a8c55551c39273b9"}
123−tree-sitter-racket = { git = "https://github.com/zed-industries/tree-sitter-racket", rev = "eb010cf2c674c6fd9a6316a84e28ef90190fe51a"}
124−tree-sitter-yaml = { git = "https://github.com/zed-industries/tree-sitter-yaml", rev = "f545a41f57502e1b5ddf2a6668896c1b0620f930"}
125−tree-sitter-lua = "0.0.14"
107+tree-sitter-c.workspace = true
108+tree-sitter-cpp.workspace = true
109+tree-sitter-css.workspace = true
110+tree-sitter-elixir.workspace = true
111+tree-sitter-embedded-template.workspace = true
112+tree-sitter-go.workspace = true
113+tree-sitter-heex.workspace = true
114+tree-sitter-json.workspace = true
115+tree-sitter-rust.workspace = true
116+tree-sitter-markdown.workspace = true
117+tree-sitter-python.workspace = true
118+tree-sitter-toml.workspace = true
119+tree-sitter-typescript.workspace = true
120+tree-sitter-ruby.workspace = true
121+tree-sitter-html.workspace = true
122+tree-sitter-php.workspace = true
123+tree-sitter-scheme.workspace = true
124+tree-sitter-svelte.workspace = true
125+tree-sitter-racket.workspace = true
126+tree-sitter-yaml.workspace = true
127+tree-sitter-lua.workspace = true
128+
126129 url = "2.2"
127130 urlencoding = "2.1.2"
128131 uuid = { version = "1.1.2", features = ["v4"] }
crates/zed/src/languages.rs+15−1
@@ -13,9 +13,11 @@ mod json; · 12 unmodified lines
1313 #[cfg(feature = "plugin_runtime")]
1414 mod language_plugin;
1515 mod lua;
16+mod php;
1617 mod python;
1718 mod ruby;
1819 mod rust;
20+mod svelte;
1921 mod typescript;
2022 mod yaml;
2123
@@ -135,7 +137,19 @@ pub fn init(languages: Arc<LanguageRegistry>, node_runtime: Arc<NodeRuntime>) { · 113 unmodified lines
135137 language(
136138 "yaml",
137139 tree_sitter_yaml::language(),
138− vec![Arc::new(yaml::YamlLspAdapter::new(node_runtime))],
140+ vec![Arc::new(yaml::YamlLspAdapter::new(node_runtime.clone()))],
141+ );
142+ language(
143+ "svelte",
144+ tree_sitter_svelte::language(),
145+ vec![Arc::new(svelte::SvelteLspAdapter::new(
146+ node_runtime.clone(),
147+ ))],
148+ );
149+ language(
150+ "php",
151+ tree_sitter_php::language(),
152+ vec![Arc::new(php::IntelephenseLspAdapter::new(node_runtime))],
139153 );
140154 }
141155
crates/zed/src/languages/heex/config.toml+1−1
@@ -4,4 +4,4 @@ autoclose_before = ">})" · 3 unmodified lines
44 brackets = [
55 { start = "<", end = ">", close = true, newline = true },
66 ]
7−block_comment = ["<%#", "%>"]
7+block_comment = ["<%!-- ", " --%>"]
crates/zed/src/languages/heex/highlights.scm+3−3
@@ -1,10 +1,7 @@
11 ; HEEx delimiters
22 [
3− "--%>"
4− "-->"
53 "/>"
64 "<!"
7− "<!--"
85 "<"
96 "</"
107 "</:"
@@ -21,6 +18,9 @@ · 10 unmodified lines
2118 "<%%="
2219 "<%="
2320 "%>"
21+ "--%>"
22+ "-->"
23+ "<!--"
2424 ] @keyword
2525
2626 ; HEEx operators are highlighted as such
crates/zed/src/languages/php.rs+133−0
@@ -0,0 +1,133 @@
1+use anyhow::{anyhow, Result};
2+
3+use async_trait::async_trait;
4+use collections::HashMap;
5+
6+use language::{LanguageServerName, LspAdapter, LspAdapterDelegate};
7+use lsp::LanguageServerBinary;
8+use node_runtime::NodeRuntime;
9+
10+use smol::{fs, stream::StreamExt};
11+use std::{
12+ any::Any,
13+ ffi::OsString,
14+ path::{Path, PathBuf},
15+ sync::Arc,
16+};
17+use util::ResultExt;
18+
19+fn intelephense_server_binary_arguments(server_path: &Path) -> Vec<OsString> {
20+ vec![server_path.into(), "--stdio".into()]
21+}
22+
23+pub struct IntelephenseVersion(String);
24+
25+pub struct IntelephenseLspAdapter {
26+ node: Arc<NodeRuntime>,
27+}
28+
29+impl IntelephenseLspAdapter {
30+ const SERVER_PATH: &'static str = "node_modules/intelephense/lib/intelephense.js";
31+
32+ #[allow(unused)]
33+ pub fn new(node: Arc<NodeRuntime>) -> Self {
34+ Self { node }
35+ }
36+}
37+
38+#[async_trait]
39+impl LspAdapter for IntelephenseLspAdapter {
40+ async fn name(&self) -> LanguageServerName {
41+ LanguageServerName("intelephense".into())
42+ }
43+
44+ async fn fetch_latest_server_version(
45+ &self,
46+ _delegate: &dyn LspAdapterDelegate,
47+ ) -> Result<Box<dyn 'static + Send + Any>> {
48+ Ok(Box::new(IntelephenseVersion(
49+ self.node.npm_package_latest_version("intelephense").await?,
50+ )) as Box<_>)
51+ }
52+
53+ async fn fetch_server_binary(
54+ &self,
55+ version: Box<dyn 'static + Send + Any>,
56+ container_dir: PathBuf,
57+ _delegate: &dyn LspAdapterDelegate,
58+ ) -> Result<LanguageServerBinary> {
59+ let version = version.downcast::<IntelephenseVersion>().unwrap();
60+ let server_path = container_dir.join(Self::SERVER_PATH);
61+
62+ if fs::metadata(&server_path).await.is_err() {
63+ self.node
64+ .npm_install_packages(&container_dir, [("intelephense", version.0.as_str())])
65+ .await?;
66+ }
67+ Ok(LanguageServerBinary {
68+ path: self.node.binary_path().await?,
69+ arguments: intelephense_server_binary_arguments(&server_path),
70+ })
71+ }
72+
73+ async fn cached_server_binary(
74+ &self,
75+ container_dir: PathBuf,
76+ _: &dyn LspAdapterDelegate,
77+ ) -> Option<LanguageServerBinary> {
78+ get_cached_server_binary(container_dir, &self.node).await
79+ }
80+
81+ async fn installation_test_binary(
82+ &self,
83+ container_dir: PathBuf,
84+ ) -> Option<LanguageServerBinary> {
85+ get_cached_server_binary(container_dir, &self.node).await
86+ }
87+
88+ async fn label_for_completion(
89+ &self,
90+ _item: &lsp::CompletionItem,
91+ _language: &Arc<language::Language>,
92+ ) -> Option<language::CodeLabel> {
93+ None
94+ }
95+
96+ async fn initialization_options(&self) -> Option<serde_json::Value> {
97+ None
98+ }
99+ async fn language_ids(&self) -> HashMap<String, String> {
100+ HashMap::from_iter([("PHP".into(), "php".into())])
101+ }
102+}
103+
104+async fn get_cached_server_binary(
105+ container_dir: PathBuf,
106+ node: &NodeRuntime,
107+) -> Option<LanguageServerBinary> {
108+ (|| async move {
109+ let mut last_version_dir = None;
110+ let mut entries = fs::read_dir(&container_dir).await?;
111+ while let Some(entry) = entries.next().await {
112+ let entry = entry?;
113+ if entry.file_type().await?.is_dir() {
114+ last_version_dir = Some(entry.path());
115+ }
116+ }
117+ let last_version_dir = last_version_dir.ok_or_else(|| anyhow!("no cached binary"))?;
118+ let server_path = last_version_dir.join(IntelephenseLspAdapter::SERVER_PATH);
119+ if server_path.exists() {
120+ Ok(LanguageServerBinary {
121+ path: node.binary_path().await?,
122+ arguments: intelephense_server_binary_arguments(&server_path),
123+ })
124+ } else {
125+ Err(anyhow!(
126+ "missing executable in directory {:?}",
127+ last_version_dir
128+ ))
129+ }
130+ })()
131+ .await
132+ .log_err()
133+}
crates/zed/src/languages/php/config.toml+11−0
@@ -0,0 +1,11 @@
1+name = "PHP"
2+path_suffixes = ["php"]
3+first_line_pattern = '^#!.*php'
4+line_comment = "// "
5+autoclose_before = ";:.,=}])>"
6+brackets = [
7+ { start = "{", end = "}", close = true, newline = true },
8+ { start = "[", end = "]", close = true, newline = true },
9+ { start = "(", end = ")", close = true, newline = true },
10+ { start = "\"", end = "\"", close = true, newline = false, not_in = ["string"] },
11+]
crates/zed/src/languages/php/highlights.scm+123−0
@@ -0,0 +1,123 @@
1+(php_tag) @tag
2+"?>" @tag
3+
4+; Types
5+
6+(primitive_type) @type.builtin
7+(cast_type) @type.builtin
8+(named_type (name) @type) @type
9+(named_type (qualified_name) @type) @type
10+
11+; Functions
12+
13+(array_creation_expression "array" @function.builtin)
14+(list_literal "list" @function.builtin)
15+
16+(method_declaration
17+ name: (name) @function.method)
18+
19+(function_call_expression
20+ function: [(qualified_name (name)) (name)] @function)
21+
22+(scoped_call_expression
23+ name: (name) @function)
24+
25+(member_call_expression
26+ name: (name) @function.method)
27+
28+(function_definition
29+ name: (name) @function)
30+
31+; Member
32+
33+(property_element
34+ (variable_name) @property)
35+
36+(member_access_expression
37+ name: (variable_name (name)) @property)
38+(member_access_expression
39+ name: (name) @property)
40+
41+; Variables
42+
43+(relative_scope) @variable.builtin
44+
45+((name) @constant
46+ (#match? @constant "^_?[A-Z][A-Z\\d_]+$"))
47+((name) @constant.builtin
48+ (#match? @constant.builtin "^__[A-Z][A-Z\d_]+__$"))
49+
50+((name) @constructor
51+ (#match? @constructor "^[A-Z]"))
52+
53+((name) @variable.builtin
54+ (#eq? @variable.builtin "this"))
55+
56+(variable_name) @variable
57+
58+; Basic tokens
59+[
60+ (string)
61+ (string_value)
62+ (encapsed_string)
63+ (heredoc)
64+ (heredoc_body)
65+ (nowdoc_body)
66+] @string
67+(boolean) @constant.builtin
68+(null) @constant.builtin
69+(integer) @number
70+(float) @number
71+(comment) @comment
72+
73+"$" @operator
74+
75+; Keywords
76+
77+"abstract" @keyword
78+"as" @keyword
79+"break" @keyword
80+"case" @keyword
81+"catch" @keyword
82+"class" @keyword
83+"const" @keyword
84+"continue" @keyword
85+"declare" @keyword
86+"default" @keyword
87+"do" @keyword
88+"echo" @keyword
89+"else" @keyword
90+"elseif" @keyword
91+"enum" @keyword
92+"enddeclare" @keyword
93+"endforeach" @keyword
94+"endif" @keyword
95+"endswitch" @keyword
96+"endwhile" @keyword
97+"extends" @keyword
98+"final" @keyword
99+"finally" @keyword
100+"foreach" @keyword
101+"function" @keyword
102+"global" @keyword
103+"if" @keyword
104+"implements" @keyword
105+"include_once" @keyword
106+"include" @keyword
107+"insteadof" @keyword
108+"interface" @keyword
109+"namespace" @keyword
110+"new" @keyword
111+"private" @keyword
112+"protected" @keyword
113+"public" @keyword
114+"require_once" @keyword
115+"require" @keyword
116+"return" @keyword
117+"static" @keyword
118+"switch" @keyword
119+"throw" @keyword
120+"trait" @keyword
121+"try" @keyword
122+"use" @keyword
123+"while" @keyword
crates/zed/src/languages/php/injections.scm+3−0
@@ -0,0 +1,3 @@
1+((text) @content
2+ (#set! "language" "html")
3+ (#set! "combined"))
crates/zed/src/languages/php/outline.scm+26−0
@@ -0,0 +1,26 @@
1+(class_declaration
2+ "class" @context
3+ name: (name) @name
4+ ) @item
5+
6+(function_definition
7+ "function" @context
8+ name: (_) @name
9+ ) @item
10+
11+
12+
13+(method_declaration
14+ "function" @context
15+ name: (_) @name
16+ ) @item
17+
18+(interface_declaration
19+ "interface" @context
20+ name: (_) @name
21+ ) @item
22+
23+(enum_declaration
24+ "enum" @context
25+ name: (_) @name
26+ ) @item
crates/zed/src/languages/php/tags.scm+40−0
@@ -0,0 +1,40 @@
1+(namespace_definition
2+ name: (namespace_name) @name) @module
3+
4+(interface_declaration
5+ name: (name) @name) @definition.interface
6+
7+(trait_declaration
8+ name: (name) @name) @definition.interface
9+
10+(class_declaration
11+ name: (name) @name) @definition.class
12+
13+(class_interface_clause [(name) (qualified_name)] @name) @impl
14+
15+(property_declaration
16+ (property_element (variable_name (name) @name))) @definition.field
17+
18+(function_definition
19+ name: (name) @name) @definition.function
20+
21+(method_declaration
22+ name: (name) @name) @definition.function
23+
24+(object_creation_expression
25+ [
26+ (qualified_name (name) @name)
27+ (variable_name (name) @name)
28+ ]) @reference.class
29+
30+(function_call_expression
31+ function: [
32+ (qualified_name (name) @name)
33+ (variable_name (name)) @name
34+ ]) @reference.call
35+
36+(scoped_call_expression
37+ name: (name) @name) @reference.call
38+
39+(member_call_expression
40+ name: (name) @name) @reference.call
crates/zed/src/languages/python/outline.scm+1−1
@@ -6,4 +6,4 @@ · 5 unmodified lines
66 (function_definition
77 "async"? @context
88 "def" @context
9− name: (_) @name) @item
9+ name: (_) @name) @item
crates/zed/src/languages/svelte.rs+125−0
@@ -0,0 +1,125 @@
1+use anyhow::{anyhow, Result};
2+use async_trait::async_trait;
3+use futures::StreamExt;
4+use language::{LanguageServerName, LspAdapter, LspAdapterDelegate};
5+use lsp::LanguageServerBinary;
6+use node_runtime::NodeRuntime;
7+use serde_json::json;
8+use smol::fs;
9+use std::{
10+ any::Any,
11+ ffi::OsString,
12+ path::{Path, PathBuf},
13+ sync::Arc,
14+};
15+use util::ResultExt;
16+
17+const SERVER_PATH: &'static str = "node_modules/svelte-language-server/bin/server.js";
18+
19+fn server_binary_arguments(server_path: &Path) -> Vec<OsString> {
20+ vec![server_path.into(), "--stdio".into()]
21+}
22+
23+pub struct SvelteLspAdapter {
24+ node: Arc<NodeRuntime>,
25+}
26+
27+impl SvelteLspAdapter {
28+ pub fn new(node: Arc<NodeRuntime>) -> Self {
29+ SvelteLspAdapter { node }
30+ }
31+}
32+
33+#[async_trait]
34+impl LspAdapter for SvelteLspAdapter {
35+ async fn name(&self) -> LanguageServerName {
36+ LanguageServerName("svelte-language-server".into())
37+ }
38+
39+ async fn fetch_latest_server_version(
40+ &self,
41+ _: &dyn LspAdapterDelegate,
42+ ) -> Result<Box<dyn 'static + Any + Send>> {
43+ Ok(Box::new(
44+ self.node
45+ .npm_package_latest_version("svelte-language-server")
46+ .await?,
47+ ) as Box<_>)
48+ }
49+
50+ async fn fetch_server_binary(
51+ &self,
52+ version: Box<dyn 'static + Send + Any>,
53+ container_dir: PathBuf,
54+ _: &dyn LspAdapterDelegate,
55+ ) -> Result<LanguageServerBinary> {
56+ let version = version.downcast::<String>().unwrap();
57+ let server_path = container_dir.join(SERVER_PATH);
58+
59+ if fs::metadata(&server_path).await.is_err() {
60+ self.node
61+ .npm_install_packages(
62+ &container_dir,
63+ [("svelte-language-server", version.as_str())],
64+ )
65+ .await?;
66+ }
67+
68+ Ok(LanguageServerBinary {
69+ path: self.node.binary_path().await?,
70+ arguments: server_binary_arguments(&server_path),
71+ })
72+ }
73+
74+ async fn cached_server_binary(
75+ &self,
76+ container_dir: PathBuf,
77+ _: &dyn LspAdapterDelegate,
78+ ) -> Option<LanguageServerBinary> {
79+ get_cached_server_binary(container_dir, &self.node).await
80+ }
81+
82+ async fn installation_test_binary(
83+ &self,
84+ container_dir: PathBuf,
85+ ) -> Option<LanguageServerBinary> {
86+ get_cached_server_binary(container_dir, &self.node).await
87+ }
88+
89+ async fn initialization_options(&self) -> Option<serde_json::Value> {
90+ Some(json!({
91+ "provideFormatter": true
92+ }))
93+ }
94+}
95+
96+async fn get_cached_server_binary(
97+ container_dir: PathBuf,
98+ node: &NodeRuntime,
99+) -> Option<LanguageServerBinary> {
100+ (|| async move {
101+ let mut last_version_dir = None;
102+ let mut entries = fs::read_dir(&container_dir).await?;
103+ while let Some(entry) = entries.next().await {
104+ let entry = entry?;
105+ if entry.file_type().await?.is_dir() {
106+ last_version_dir = Some(entry.path());
107+ }
108+ }
109+ let last_version_dir = last_version_dir.ok_or_else(|| anyhow!("no cached binary"))?;
110+ let server_path = last_version_dir.join(SERVER_PATH);
111+ if server_path.exists() {
112+ Ok(LanguageServerBinary {
113+ path: node.binary_path().await?,
114+ arguments: server_binary_arguments(&server_path),
115+ })
116+ } else {
117+ Err(anyhow!(
118+ "missing executable in directory {:?}",
119+ last_version_dir
120+ ))
121+ }
122+ })()
123+ .await
124+ .log_err()
125+}
crates/zed/src/languages/svelte/config.toml+18−0
@@ -0,0 +1,18 @@
1+name = "Svelte"
2+path_suffixes = ["svelte"]
3+line_comment = "// "
4+autoclose_before = ";:.,=}])>"
5+brackets = [
6+ { start = "{", end = "}", close = true, newline = true },
7+ { start = "[", end = "]", close = true, newline = true },
8+ { start = "(", end = ")", close = true, newline = true },
9+ { start = "<", end = ">", close = false, newline = true, not_in = ["string", "comment"] },
10+ { start = "\"", end = "\"", close = true, newline = false, not_in = ["string"] },
11+ { start = "'", end = "'", close = true, newline = false, not_in = ["string", "comment"] },
12+ { start = "`", end = "`", close = true, newline = false, not_in = ["string"] },
13+ { start = "/*", end = " */", close = true, newline = false, not_in = ["string", "comment"] },
14+]
15+
16+[overrides.element]
17+line_comment = { remove = true }
18+block_comment = ["{/* ", " */}"]
crates/zed/src/languages/svelte/folds.scm+9−0
@@ -0,0 +1,9 @@
1+[
2+ (style_element)
3+ (script_element)
4+ (element)
5+ (if_statement)
6+ (else_statement)
7+ (each_statement)
8+ (await_statement)
9+] @fold
crates/zed/src/languages/svelte/highlights.scm+42−0
@@ -0,0 +1,42 @@
1+; Special identifiers
2+;--------------------
3+
4+; TODO:
5+(tag_name) @tag
6+(attribute_name) @property
7+(erroneous_end_tag_name) @keyword
8+(comment) @comment
9+
10+[
11+ (attribute_value)
12+ (quoted_attribute_value)
13+] @string
14+
15+[
16+ (text)
17+ (raw_text_expr)
18+] @none
19+
20+[
21+ (special_block_keyword)
22+ (then)
23+ (as)
24+] @keyword
25+
26+[
27+ "{"
28+ "}"
29+] @punctuation.bracket
30+
31+"=" @operator
32+
33+[
34+ "<"
35+ ">"
36+ "</"
37+ "/>"
38+ "#"
39+ ":"
40+ "/"
41+ "@"
42+] @tag.delimiter
crates/zed/src/languages/svelte/indents.scm+8−0
@@ -0,0 +1,8 @@
1+[
2+ (element)
3+ (if_statement)
4+ (each_statement)
5+ (await_statement)
6+ (script_element)
7+ (style_element)
8+] @indent
crates/zed/src/languages/svelte/injections.scm+28−0
@@ -0,0 +1,28 @@
1+; injections.scm
2+; --------------
3+(script_element
4+ (raw_text) @content
5+ (#set! "language" "javascript"))
6+
7+ ((script_element
8+ (start_tag
9+ (attribute
10+ (quoted_attribute_value (attribute_value) @_language)))
11+ (raw_text) @content)
12+ (#eq? @_language "ts")
13+ (#set! "language" "typescript"))
14+
15+((script_element
16+ (start_tag
17+ (attribute
18+ (quoted_attribute_value (attribute_value) @_language)))
19+ (raw_text) @content)
20+ (#eq? @_language "typescript")
21+ (#set! "language" "typescript"))
22+
23+(style_element
24+ (raw_text) @content
25+ (#set! "language" "css"))
26+
27+((raw_text_expr) @content
28+ (#set! "language" "javascript"))
crates/zed/src/main.rs+10−2
@@ -36,7 +36,7 @@ use std::{ · 35 unmodified lines
3636 path::{Path, PathBuf},
3737 str,
3838 sync::{
39− atomic::{AtomicBool, Ordering},
39+ atomic::{AtomicBool, AtomicU32, Ordering},
4040 Arc, Weak,
4141 },
4242 thread,
@@ -405,11 +405,18 @@ struct PanicRequest { · 362 unmodified lines
405405 token: String,
406406 }
407407
408+static PANIC_COUNT: AtomicU32 = AtomicU32::new(0);
409+
408410 fn init_panic_hook(app: &App, installation_id: Option<String>) {
409411 let is_pty = stdout_is_a_pty();
410412 let platform = app.platform();
411413
412414 panic::set_hook(Box::new(move |info| {
415+ let prior_panic_count = PANIC_COUNT.fetch_add(1, Ordering::SeqCst);
416+ if prior_panic_count > 0 {
417+ std::panic::resume_unwind(Box::new(()));
418+ }
419+
413420 let app_version = ZED_APP_VERSION
414421 .or_else(|| platform.app_version().ok())
415422 .map_or("dev".to_string(), |v| v.to_string());
@@ -464,7 +471,6 @@ fn init_panic_hook(app: &App, installation_id: Option<String>) { · 48 unmodified lines
464471 if is_pty {
465472 if let Some(panic_data_json) = serde_json::to_string_pretty(&panic_data).log_err() {
466473 eprintln!("{}", panic_data_json);
467− return;
468474 }
469475 } else {
470476 if let Some(panic_data_json) = serde_json::to_string(&panic_data).log_err() {
@@ -481,6 +487,8 @@ fn init_panic_hook(app: &App, installation_id: Option<String>) { · 10 unmodified lines
481487 }
482488 }
483489 }
490+
491+ std::process::abort();
484492 }));
485493 }
486494
crates/zed/src/zed.rs+15−11
@@ -517,11 +517,7 @@ pub fn handle_keymap_file_changes( · 516 unmodified lines
517517 let mut settings_subscription = None;
518518 while let Some(user_keymap_content) = user_keymap_file_rx.next().await {
519519 if let Ok(keymap_content) = KeymapFile::parse(&user_keymap_content) {
520− cx.update(|cx| {
521− cx.clear_bindings();
522− load_default_keymap(cx);
523− keymap_content.clone().add_to_cx(cx).log_err();
524− });
520+ cx.update(|cx| reload_keymaps(cx, &keymap_content));
525521
526522 let mut old_base_keymap = cx.read(|cx| *settings::get::<BaseKeymap>(cx));
527523 drop(settings_subscription);
@@ -530,10 +526,7 @@ pub fn handle_keymap_file_changes( · 2 unmodified lines
530526 let new_base_keymap = *settings::get::<BaseKeymap>(cx);
531527 if new_base_keymap != old_base_keymap {
532528 old_base_keymap = new_base_keymap.clone();
533−
534− cx.clear_bindings();
535− load_default_keymap(cx);
536− keymap_content.clone().add_to_cx(cx).log_err();
529+ reload_keymaps(cx, &keymap_content);
537530 }
538531 })
539532 .detach();
@@ -544,6 +537,13 @@ pub fn handle_keymap_file_changes( · 4 unmodified lines
544537 .detach();
545538 }
546539
540+fn reload_keymaps(cx: &mut AppContext, keymap_content: &KeymapFile) {
541+ cx.clear_bindings();
542+ load_default_keymap(cx);
543+ keymap_content.clone().add_to_cx(cx).log_err();
544+ cx.set_menus(menus::menus());
545+}
546+
547547 fn open_local_settings_file(
548548 workspace: &mut Workspace,
549549 _: &OpenLocalSettings,
@@ -1021,7 +1021,7 @@ mod tests { · 471 unmodified lines
10211021 // Split the pane with the first entry, then open the second entry again.
10221022 workspace
10231023 .update(cx, |w, cx| {
1024− w.split_pane(w.active_pane().clone(), SplitDirection::Right, cx);
1024+ w.split_and_clone(w.active_pane().clone(), SplitDirection::Right, cx);
10251025 w.open_path(file2.clone(), None, true, cx)
10261026 })
10271027 .await
@@ -1344,7 +1344,11 @@ mod tests { · 316 unmodified lines
13441344 cx.dispatch_action(window_id, NewFile);
13451345 workspace
13461346 .update(cx, |workspace, cx| {
1347− workspace.split_pane(workspace.active_pane().clone(), SplitDirection::Right, cx);
1347+ workspace.split_and_clone(
1348+ workspace.active_pane().clone(),
1349+ SplitDirection::Right,
1350+ cx,
1351+ );
13481352 workspace.open_path((worktree.read(cx).id(), "the-new-name.rs"), None, true, cx)
13491353 })
13501354 .await
styles/src/style_tree/editor.ts+1−1
@@ -114,7 +114,7 @@ export default function editor(): any { · 113 unmodified lines
114114 color: foreground(layer, "default"),
115115 },
116116 hovered: {
117− color: foreground(layer, "variant"),
117+ color: foreground(layer, "on"),
118118 },
119119 },
120120 },
styles/src/style_tree/feedback.ts+5−0
@@ -33,6 +33,11 @@ export default function feedback(): any { · 32 unmodified lines
3333 background: background(theme.highest, "on", "hovered"),
3434 border: border(theme.highest, "on", "hovered"),
3535 },
36+ disabled: {
37+ ...text(theme.highest, "mono", "on", "disabled"),
38+ background: background(theme.highest, "on", "disabled"),
39+ border: border(theme.highest, "on", "disabled"),
40+ }
3641 },
3742 }),
3843 button_margin: 8,
styles/src/style_tree/search.ts+29−0
@@ -83,6 +83,35 @@ export default function search(): any { · 82 unmodified lines
8383 },
8484 },
8585 }),
86+ action_button: interactive({
87+ base: {
88+ ...text(theme.highest, "mono", "on"),
89+ background: background(theme.highest, "on"),
90+ corner_radius: 6,
91+ border: border(theme.highest, "on"),
92+ margin: {
93+ right: 4,
94+ },
95+ padding: {
96+ bottom: 2,
97+ left: 10,
98+ right: 10,
99+ top: 2,
100+ },
101+ },
102+ state: {
103+ hovered: {
104+ ...text(theme.highest, "mono", "on", "hovered"),
105+ background: background(theme.highest, "on", "hovered"),
106+ border: border(theme.highest, "on", "hovered"),
107+ },
108+ clicked: {
109+ ...text(theme.highest, "mono", "on", "pressed"),
110+ background: background(theme.highest, "on", "pressed"),
111+ border: border(theme.highest, "on", "pressed"),
112+ },
113+ },
114+ }),
86115 editor,
87116 invalid_editor: {
88117 ...editor,
styles/src/style_tree/tab_bar.ts+14−0
@@ -6,6 +6,8 @@ import { useTheme } from "../common" · 5 unmodified lines
66 export default function tab_bar(): any {
77 const theme = useTheme()
88
9+ const { is_light } = theme
10+
911 const height = 32
1012
1113 const active_layer = theme.highest
@@ -38,6 +40,18 @@ export default function tab_bar(): any { · 26 unmodified lines
3840 icon_conflict: foreground(layer, "warning"),
3941 icon_dirty: foreground(layer, "accent"),
4042
43+ git: {
44+ modified: is_light
45+ ? theme.ramps.yellow(0.6).hex()
46+ : theme.ramps.yellow(0.5).hex(),
47+ inserted: is_light
48+ ? theme.ramps.green(0.45).hex()
49+ : theme.ramps.green(0.5).hex(),
50+ conflict: is_light
51+ ? theme.ramps.red(0.6).hex()
52+ : theme.ramps.red(0.5).hex(),
53+ },
54+
4155 // When two tabs of the same name are open, a label appears next to them
4256 description: {
4357 margin: { left: 8 },

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t