Skip to content

Commit 41dbff6

Browse files
authored
Merge branch 'master' into jeremypw/rework-word-completion/no-unnecessary-reparse
2 parents f40086a + b2fba80 commit 41dbff6

File tree

630 files changed

+44520
-22049
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

630 files changed

+44520
-22049
lines changed

.github/workflows/ci.yml

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -32,37 +32,35 @@ jobs:
3232
3333
flatpak:
3434
name: Flatpak
35-
runs-on: ubuntu-latest
35+
runs-on: ${{ matrix.configuration.runs-on }}
3636

3737
strategy:
3838
matrix:
39-
arch: [x86_64, aarch64]
39+
configuration:
40+
- arch: x86_64
41+
runs-on: ubuntu-latest
42+
- arch: aarch64
43+
runs-on: ubuntu-24.04-arm
4044
# Don't fail the whole workflow if one architecture fails
4145
fail-fast: false
4246

4347
container:
44-
image: ghcr.io/elementary/flatpak-platform/runtime:7.1-${{ matrix.arch }}
48+
image: ghcr.io/elementary/flatpak-platform/runtime:8-${{ matrix.configuration.arch }}
4549
options: --privileged
4650

4751
steps:
4852
- name: Checkout
4953
uses: actions/checkout@v4
5054

51-
- name: Set up QEMU for aarch64 emulation
52-
if: ${{ matrix.arch != 'x86_64' }}
53-
uses: docker/setup-qemu-action@v3
54-
with:
55-
platforms: arm64
56-
5755
- name: Build
58-
uses: flatpak/flatpak-github-actions/flatpak-builder@v6
56+
uses: flatpak/flatpak-github-actions/flatpak-builder@v6.5
5957
with:
6058
bundle: code.flatpak
6159
manifest-path: io.elementary.code.yml
6260
repository-name: appcenter
6361
repository-url: https://flatpak.elementary.io/repo.flatpakrepo
6462
cache-key: "flatpak-builder-${{ github.sha }}"
65-
arch: ${{ matrix.arch }}
63+
arch: ${{ matrix.configuration.arch }}
6664

6765
lint:
6866
name: Lint

data/icons/48/open-project.svg

Lines changed: 354 additions & 0 deletions
Loading

data/io.elementary.code.gresource.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
<file alias="scalable/actions/panel-right-symbolic.svg" compressed="true" preprocess="xml-stripblanks">icons/panel-right-symbolic.svg</file>
3131
</gresource>
3232
<gresource prefix="/io/elementary/code/icons">
33+
<file alias="48x48/actions/open-project.svg" compressed="true" preprocess="xml-stripblanks">icons/48/open-project.svg</file>
3334
<file alias="scalable/actions/filter-symbolic.svg" compressed="true" preprocess="xml-stripblanks">icons/filter-symbolic.svg</file>
3435
<file alias="scalable/emblems/emblem-git-modified-symbolic.svg" compressed="true" preprocess="xml-stripblanks">icons/emblem-git-modified-symbolic.svg</file>
3536
<file alias="scalable/emblems/emblem-git-new-symbolic.svg" compressed="true" preprocess="xml-stripblanks">icons/emblem-git-new-symbolic.svg</file>

data/io.elementary.code.gschema.xml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,11 @@
152152
<summary>Remember the last focused document.</summary>
153153
<description>Restore the focused document from a previous session when opening Code.</description>
154154
</key>
155+
<key name="active-project-path" type="s">
156+
<default>''</default>
157+
<summary>The active project path.</summary>
158+
<description>The path to the folder containing the active project.</description>
159+
</key>
155160
<key name="default-build-directory" type="s">
156161
<default>''</default>
157162
<summary>The default build directory's relative path.</summary>

plugins/editorconfig/editorconfig.vala

Lines changed: 52 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -32,60 +32,65 @@ public class Scratch.Plugins.EditorConfigPlugin: Peas.ExtensionBase, Peas.Activa
3232
});
3333

3434
plugins.hook_document.connect ((d) => {
35-
// Ensure use global settings by default
36-
format_bar.tab_style_set_by_editor_config = false;
37-
format_bar.tab_width_set_by_editor_config = false;
38-
format_bar.set_document (d);
35+
update_config.begin (d);
36+
});
3937

40-
Scratch.Widgets.SourceView view = d.source_view;
41-
File file = d.file;
38+
}
4239

43-
if (file == null || !file.query_exists ()) {
44-
return;
45-
}
40+
private async void update_config (Scratch.Services.Document d) {
41+
// Ensure use global settings by default
42+
format_bar.tab_style_set_by_editor_config = false;
43+
format_bar.tab_width_set_by_editor_config = false;
44+
format_bar.set_document (d);
4645

47-
var handle = new EditorConfig.Handle ();
48-
handle.set_conf_file_name (".editorconfig");
49-
if (handle.parse (file.get_path ()) != 0) {
50-
return;
51-
}
46+
Scratch.Widgets.SourceView view = d.source_view;
47+
File file = d.file;
5248

53-
for (int i = 0; i < handle.get_name_value_count (); i++) {
54-
string name, val;
55-
handle.get_name_value (i, out name, out val);
56-
/* These are all properties (https://github.com/editorconfig/editorconfig/wiki/EditorConfig-Properties) */
57-
switch (name) {
58-
case "indent_style":
59-
format_bar.tab_style_set_by_editor_config = true;
60-
var use_spaces = (val != "tab");
61-
format_bar.set_insert_spaces_instead_of_tabs (use_spaces);
62-
break;
63-
case "indent_size":
64-
case "tab_width":
65-
format_bar.tab_width_set_by_editor_config = true;
66-
var indent_width = (int.parse (val)).clamp (2, 16);
67-
format_bar.set_tab_width (indent_width);
68-
break;
69-
case "end_of_line":
70-
break;
71-
case "charset":
72-
break;
73-
case "trim_trailing_whitespace":
74-
break;
75-
case "insert_final_newline":
76-
break;
77-
case "max_line_length":
78-
view.right_margin_position = int.parse (val);
79-
break;
80-
default:
81-
warning ("unrecognised name/value %s/%s", name, val);
82-
break;
83-
}
49+
if (file == null || !file.query_exists ()) {
50+
return;
51+
}
52+
53+
var handle = new EditorConfig.Handle ();
54+
handle.set_conf_file_name (".editorconfig");
55+
if (handle.parse (file.get_path ()) != 0) {
56+
return;
57+
}
58+
59+
for (int i = 0; i < handle.get_name_value_count (); i++) {
60+
string name, val;
61+
handle.get_name_value (i, out name, out val);
62+
/* These are all properties (https://github.com/editorconfig/editorconfig/wiki/EditorConfig-Properties) */
63+
switch (name) {
64+
case "indent_style":
65+
format_bar.tab_style_set_by_editor_config = true;
66+
var use_spaces = (val != "tab");
67+
format_bar.set_insert_spaces_instead_of_tabs (use_spaces);
68+
break;
69+
case "indent_size":
70+
case "tab_width":
71+
format_bar.tab_width_set_by_editor_config = true;
72+
var indent_width = (int.parse (val)).clamp (2, 16);
73+
format_bar.set_tab_width (indent_width);
74+
break;
75+
case "end_of_line":
76+
break;
77+
case "charset":
78+
break;
79+
case "trim_trailing_whitespace":
80+
break;
81+
case "insert_final_newline":
82+
break;
83+
case "max_line_length":
84+
view.right_margin_position = int.parse (val);
85+
break;
86+
default:
87+
warning ("unrecognised name/value %s/%s", name, val);
88+
break;
8489
}
85-
});
90+
}
8691
}
8792

88-
public void deactivate () { }
93+
public void deactivate () { debug ("Editor config deactivate");}
8994
}
9095

9196
[ModuleInit]

plugins/highlight-word-selection/highlight-word-selection.vala

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,7 @@ public class Scratch.Plugins.HighlightSelectedWords : Peas.ExtensionBase, Peas.A
2323
Scratch.MainWindow? main_window = null;
2424
Gtk.SourceSearchContext? current_search_context = null;
2525

26-
// Consts
27-
// Pneumonoultramicroscopicsilicovolcanoconiosis longest word in a major dictionary @ 45
28-
private const uint SELECTION_HIGHLIGHT_MAX_CHARS = 45;
26+
private const uint SELECTION_HIGHLIGHT_MAX_CHARS = 255;
2927

3028
Scratch.Services.Interface plugins;
3129
public Object object { owned get; construct; }
@@ -50,12 +48,8 @@ public class Scratch.Plugins.HighlightSelectedWords : Peas.ExtensionBase, Peas.A
5048
});
5149
}
5250

53-
public void on_selection_changed (ref Gtk.TextIter start, ref Gtk.TextIter end) {
54-
var window_search_context = main_window != null ? main_window.search_bar.search_context : null;
55-
56-
if (window_search_context == null ||
57-
window_search_context.settings.search_text == "" ||
58-
window_search_context.get_occurrences_count () == 0) {
51+
public void on_selection_changed (ref Gtk.TextIter start, ref Gtk.TextIter end) requires (main_window != null) {
52+
if (!main_window.has_successful_search ()) {
5953
// Perform plugin selection when there is no ongoing and successful search
6054
current_search_context = new Gtk.SourceSearchContext (
6155
(Gtk.SourceBuffer)current_source.buffer,

plugins/word-completion/meson.build

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ module_name = 'word-completion'
22

33
module_files = [
44
'prefix-tree.vala',
5+
'prefix-tree-node.vala',
56
'completion-provider.vala',
67
'engine.vala',
78
'plugin.vala'
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
/*
2+
* Copyright 2024 elementary, Inc. <https://elementary.io>
3+
* 2011 Lucas Baudin <xapantu@gmail.com>
4+
* *
5+
* This is a free software; you can redistribute it and/or
6+
* modify it under the terms of the GNU General Public License as
7+
* published by the Free Software Foundation; either version 2 of the
8+
* License, or (at your option) any later version.
9+
*
10+
* This is distributed in the hope that it will be useful,
11+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
12+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13+
* General Public License for more details.
14+
*
15+
* You should have received a copy of the GNU General Public
16+
* License along with this program; see the file COPYING. If not,
17+
* write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
18+
* Boston, MA 02110-1301 USA.
19+
*
20+
*/
21+
22+
public class Scratch.Plugins.PrefixNode : Object {
23+
public enum NodeType {
24+
ROOT,
25+
CHAR,
26+
WORD_END
27+
}
28+
29+
private const unichar WORD_END_CHAR = '\0';
30+
private uint occurrences; // Only used for WORD_END nodes
31+
32+
public unichar uc { get; construct; }
33+
public NodeType node_type { get; construct; }
34+
public PrefixNode? parent { get; construct; }
35+
public unichar value { get; construct; }
36+
37+
public Gee.ArrayList<PrefixNode> children;
38+
39+
public PrefixNode.from_unichar (unichar c, PrefixNode? _parent) requires (c != WORD_END_CHAR) {
40+
Object (
41+
value: c,
42+
parent: _parent,
43+
uc: c,
44+
node_type: NodeType.CHAR
45+
);
46+
}
47+
48+
public PrefixNode.root () {
49+
Object (
50+
parent: null,
51+
uc: WORD_END_CHAR,
52+
node_type: NodeType.ROOT
53+
);
54+
}
55+
56+
public PrefixNode.word_end (PrefixNode _parent) {
57+
Object (
58+
parent: _parent,
59+
uc: WORD_END_CHAR,
60+
node_type: NodeType.WORD_END
61+
);
62+
63+
occurrences = 1;
64+
}
65+
66+
construct {
67+
children = new Gee.ArrayList<PrefixNode> ();
68+
}
69+
}

plugins/word-completion/prefix-tree.vala

Lines changed: 4 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,5 @@
11

22
namespace Scratch.Plugins {
3-
private class PrefixNode : Object {
4-
public GLib.List<PrefixNode> children;
5-
public unichar value { get; set; }
6-
7-
construct {
8-
children = new List<PrefixNode> ();
9-
}
10-
}
11-
123
public class PrefixTree : Object {
134
private PrefixNode root;
145
public bool completed { get; set; default = false; }
@@ -18,9 +9,7 @@ namespace Scratch.Plugins {
189
}
1910

2011
public void clear () {
21-
root = new PrefixNode () {
22-
value = '\0'
23-
};
12+
root = new PrefixNode ();
2413
}
2514

2615
public void insert (string word) {
@@ -48,10 +37,9 @@ namespace Scratch.Plugins {
4837
}
4938
}
5039

51-
var new_child = new PrefixNode () {
52-
value = curr
53-
};
54-
node.children.insert_sorted (new_child, (c1, c2) => {
40+
var new_child = new PrefixNode.from_unichar (curr, null);
41+
node.children.insert (0, new_child);
42+
node.children.sort ((c1, c2) => {
5543
if (c1.value > c2.value) {
5644
return 1;
5745
} else if (c1.value == c2.value) {

po/POTFILES

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ src/Dialogs/GlobalSearchDialog.vala
55
src/Dialogs/NewBranchDialog.vala
66
src/Dialogs/PreferencesDialog.vala
77
src/Dialogs/RestoreConfirmationDialog.vala
8+
src/Dialogs/CloseProjectsConfirmationDialog.vala
9+
src/Dialogs/OverwriteUncommittedConfirmationDialog.vala
810
src/FolderManager/File.vala
911
src/FolderManager/FileItem.vala
1012
src/FolderManager/FileView.vala
@@ -13,6 +15,7 @@ src/FolderManager/Item.vala
1315
src/FolderManager/ProjectFolderItem.vala
1416
src/Services/Document.vala
1517
src/Services/FileHandler.vala
18+
src/Services/MonitoredRepository.vala
1619
src/Services/PluginManager.vala
1720
src/Services/Settings.vala
1821
src/Services/TemplateManager.vala

0 commit comments

Comments
 (0)