Skip to content

Commit

Permalink
auto-detect the tab type
Browse files Browse the repository at this point in the history
  • Loading branch information
eyelash committed Sep 27, 2023
1 parent 7a5170f commit fa60f01
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
9 changes: 6 additions & 3 deletions src/text-editor-widget.cc
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ static void atom_text_editor_widget_handle_pressed(GtkGestureMultiPress *, gint,
static void atom_text_editor_widget_handle_released(GtkGestureMultiPress *, gint, gdouble, gdouble, gpointer);
static void atom_text_editor_widget_handle_drag_update(GtkGestureDrag *, gdouble, gdouble, gpointer);
static void update(AtomTextEditorWidget *, bool = true);
static void autoscroll(AtomTextEditorWidget *, Range);
static void autoscroll(AtomTextEditorWidget *, const Range &);
static void start_blinking(AtomTextEditorWidget *);
static void stop_blinking(AtomTextEditorWidget *);
static Point get_screen_position(AtomTextEditorWidget *, double, double);
Expand Down Expand Up @@ -342,6 +342,9 @@ AtomTextEditorWidget *atom_text_editor_widget_new(GFile *file) {
}
grammar_registry.maintainLanguageMode(buffer);
priv->text_editor = new TextEditor(buffer);
if (optional<bool> uses_soft_tabs = priv->text_editor->usesSoftTabs()) {
priv->text_editor->setSoftTabs(*uses_soft_tabs);
}
priv->match_manager = new MatchManager(priv->text_editor);
priv->bracket_matcher = new BracketMatcher(priv->text_editor, priv->match_manager);
priv->bracket_matcher_view = new BracketMatcherView(priv->text_editor, priv->match_manager);
Expand All @@ -364,7 +367,7 @@ AtomTextEditorWidget *atom_text_editor_widget_new(GFile *file) {
g_object_notify(G_OBJECT(self), "selection-count");
start_blinking(self);
});
priv->text_editor->onDidRequestAutoscroll([self](Range range) {
priv->text_editor->onDidRequestAutoscroll([self](const Range &range) {
autoscroll(self, range);
});
priv->text_editor->onDidChangeTitle([self]() {
Expand Down Expand Up @@ -1422,7 +1425,7 @@ static void update(AtomTextEditorWidget *self, bool redraw) {
if (redraw) gtk_widget_queue_draw(GTK_WIDGET(self));
}

static void autoscroll(AtomTextEditorWidget *self, Range range) {
static void autoscroll(AtomTextEditorWidget *self, const Range &range) {
AtomTextEditorWidgetPrivate *priv = GET_PRIVATE(self);
const double min_value = std::min((range.end.row + 1) * priv->line_height + 50, gtk_adjustment_get_upper(priv->vadjustment)) - gtk_adjustment_get_page_size(priv->vadjustment);
const double max_value = std::max(range.start.row * priv->line_height - 50, 0.0);
Expand Down
2 changes: 1 addition & 1 deletion subprojects/atom-native
Submodule atom-native updated 67 files
+8 −28 atom/src/bracket-matcher-view.cc
+5 −5 atom/src/bracket-matcher-view.h
+3 −3 atom/src/cursor.cc
+3 −3 atom/src/cursor.h
+20 −1 atom/src/grammar-registry.cc
+1 −0 atom/src/grammar-registry.h
+5 −1 atom/src/grammar.h
+1 −1 atom/src/null-grammar.cc
+2 −2 atom/src/null-grammar.h
+3 −3 atom/src/select-next.cc
+3 −3 atom/src/select-next.h
+6 −6 atom/src/selection.cc
+6 −6 atom/src/selection.h
+73 −43 atom/src/syntax-scope-map.cc
+10 −7 atom/src/syntax-scope-map.h
+99 −39 atom/src/text-editor.cc
+44 −33 atom/src/text-editor.h
+1 −1 atom/src/text-mate-language-mode.h
+41 −38 atom/src/tree-sitter-grammar.cc
+90 −26 atom/src/tree-sitter-grammar.h
+347 −119 atom/src/tree-sitter-language-mode.cc
+47 −12 atom/src/tree-sitter-language-mode.h
+13 −0 atom/test/fixtures/sample.js
+5 −0 atom/test/tests.cc
+709 −0 atom/test/text-editor-spec.cc
+8,879 −0 atom/test/text-editor-spec.js
+36 −155 git-utils/CMakeLists.txt
+143 −125 language-c/grammars/tree-sitter-c.cc
+193 −175 language-c/grammars/tree-sitter-cpp.cc
+84 −78 language-css/grammars/tree-sitter-css.cc
+85 −81 language-go/grammars/tree-sitter-go.cc
+45 −28 language-html/grammars/tree-sitter-html.cc
+210 −204 language-javascript/grammars/tree-sitter-javascript.cc
+137 −133 language-python/grammars/tree-sitter-python.cc
+121 −117 language-rust/grammars/tree-sitter-rust.cc
+27 −10 superstring/CMakeLists.txt
+1 −1 text-buffer/src/default-history-provider.cc
+1 −1 text-buffer/src/default-history-provider.h
+80 −20 text-buffer/src/display-layer.cc
+21 −14 text-buffer/src/display-layer.h
+18 −14 text-buffer/src/display-marker-layer.cc
+9 −9 text-buffer/src/display-marker-layer.h
+9 −9 text-buffer/src/display-marker.cc
+9 −9 text-buffer/src/display-marker.h
+9 −0 text-buffer/src/helpers.h
+1 −1 text-buffer/src/language-mode.cc
+1 −1 text-buffer/src/language-mode.h
+11 −19 text-buffer/src/marker-layer.cc
+8 −8 text-buffer/src/marker-layer.h
+11 −11 text-buffer/src/marker.cc
+11 −11 text-buffer/src/marker.h
+16 −0 text-buffer/src/point.cc
+3 −0 text-buffer/src/point.h
+8 −4 text-buffer/src/range.cc
+1 −0 text-buffer/src/range.h
+23 −23 text-buffer/src/text-buffer.cc
+24 −24 text-buffer/src/text-buffer.h
+1 −0 tree-sitter/CMakeLists.txt
+1 −0 tree-sitter/meson.build
+3 −2 tree-sitter/src/parser.cc
+1 −1 tree-sitter/src/parser.h
+2 −8 tree-sitter/src/tree-cursor.cc
+1 −5 tree-sitter/src/tree-cursor.h
+139 −0 tree-sitter/src/tree-sitter.cc
+18 −0 tree-sitter/src/tree-sitter.h
+4 −10 tree-sitter/src/tree.cc
+1 −5 tree-sitter/src/tree.h

0 comments on commit fa60f01

Please sign in to comment.