Skip to content
This repository has been archived by the owner on Dec 11, 2024. It is now read-only.

Commit

Permalink
Fix ameba warnings and other fixable stuff due to new fixes on GICrys…
Browse files Browse the repository at this point in the history
…tal.
  • Loading branch information
hugopl committed Aug 27, 2024
1 parent caaee1a commit ea253b6
Show file tree
Hide file tree
Showing 16 changed files with 29 additions and 29 deletions.
4 changes: 2 additions & 2 deletions src/application_window.cr
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,7 @@ class ApplicationWindow < Adw::ApplicationWindow

if view.resource.nil?
save_current_view_as
elsif !view.readonly? && view.modified
elsif !view.readonly? && view.modified?
view.save
else
Log.info { "Skipping save for readonly and/or unmodified documents" }
Expand Down Expand Up @@ -333,7 +333,7 @@ class ApplicationWindow < Adw::ApplicationWindow

def show_open_file_dialog
dialog = Gtk::FileDialog.new(initial_folder: Gio::File.new_for_path(@project.root.dirname))
dialog.open(self, nil) do |obj, result|
dialog.open(self, nil) do |_, result|
path = dialog.open_finish(result).try(&.path)
open(path) if path
rescue e : Gtk::DialogError::Dismissed
Expand Down
2 changes: 1 addition & 1 deletion src/code_commenter.cr
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ module CodeCommenter

private def uncomment_lines(iter : Gtk::TextIter, count : Int32)
line_comment = language.line_comment
indent = find_text_indent(iter.copy, count)
find_text_indent(iter.copy, count)

buffer.user_action do
count.times do
Expand Down
6 changes: 3 additions & 3 deletions src/config.cr
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,11 @@ class Config

# editor
getter editor_font_size : Int32
getter editor_insert_spaces_instead_of_tabs : Bool
getter? editor_insert_spaces_instead_of_tabs : Bool
getter editor_tab_width : Int32
getter editor_show_right_margin : Bool
getter? editor_show_right_margin : Bool
getter editor_right_margin_position : Int32
getter editor_highlight_current_line : Bool
getter? editor_highlight_current_line : Bool

def self.instance
@@instance ||= begin
Expand Down
6 changes: 3 additions & 3 deletions src/document_view.cr
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@ abstract class DocumentView < View
property project : Project?
property? readonly = false
@[GObject::Property]
property modified = false
property? modified = false
@[GObject::Property]
property externally_modified = false
property? externally_modified = false
@[GObject::Property]
property deleted = false
property? deleted = false

@@untitled_count = 0
@resource_actions = [] of Gio::SimpleAction
Expand Down
4 changes: 2 additions & 2 deletions src/find_replace.cr
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class FindReplace < Gtk::Box
@offset_when_show : Int32 = 0

@[GObject::Property]
property active : Bool = false
property? active : Bool = false

def initialize(@editor : CodeEditor)
super()
Expand Down Expand Up @@ -46,7 +46,7 @@ class FindReplace < Gtk::Box
def find_prev
@search_context.highlight = true

start, end_ = @buffer.selection_bounds
start, _ = @buffer.selection_bounds
found, start, end_, _wrap = @search_context.backward(start)
return unless found

Expand Down
2 changes: 1 addition & 1 deletion src/git_branch_model.cr
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ class GitBranchModel < GObject::Object
def menu_model=(menu_model : Gio::Menu)
@menu_model = menu_model
menu_model.remove_all
local_branches.each.with_index do |branch_name, index|
local_branches.each do |branch_name|
variant = GLib::Variant.new(branch_name)
menu_model.append(branch_name, "win.change_git_branch(#{variant})")
end
Expand Down
1 change: 0 additions & 1 deletion src/lame_regex_crystal_code_model.cr
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ class LameRegexCrystalCodeModel < CodeModel
private def scan_symbols(source : Path) : Array(CodeSymbol)
symbols = [] of CodeSymbol
line_number = -1
is_spec = source =~ /_spec\...\z/

File.open(source).each_line do |line|
line_number += 1
Expand Down
2 changes: 1 addition & 1 deletion src/lsp/server_capabilities.cr
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ module LSP
@[JSON::Field(key: "willSave")]
getter? will_save : Bool = false
@[JSON::Field(key: "willSaveWaitUntil")]
getter will_save_wait_until : Bool = false
getter? will_save_wait_until : Bool = false
getter save : SaveOptions | Bool = false
end

Expand Down
6 changes: 3 additions & 3 deletions src/macros/license.cr
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,15 @@ def render_license(io : IO, title : String, license_file : Path | String)
io << "</tt>\n\n"
end

license = String.build do |s|
license = String.build do |str|
if File.exists?("./LICENSE")
title = Dir.current.split("/").last.capitalize
render_license(s, title, "./LICENSE")
render_license(str, title, "./LICENSE")
end

Dir.glob("./lib/*/LICENSE", "./lib/*/license").each do |path|
title = path.match(/^\.\/lib\/([^\/]+)\//).try(&.[1]).to_s.capitalize
render_license(s, title, path)
render_license(str, title, path)
end
end

Expand Down
2 changes: 1 addition & 1 deletion src/project.cr
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ class Project < GObject::Object
files.each do |file|
@files.add?(file)
end
directories.each { |f| @directories.add(f) }
directories.each { |directory| @directories.add(directory) }
end
end

Expand Down
14 changes: 7 additions & 7 deletions src/text_view.cr
Original file line number Diff line number Diff line change
Expand Up @@ -91,10 +91,10 @@ class TextView < DocumentView

@editor.wrap_mode = config.wrap_mode
@editor.tab_width = is_make_file ? 4 : config.editor_tab_width
@editor.insert_spaces_instead_of_tabs = is_make_file ? false : config.editor_insert_spaces_instead_of_tabs
@editor.show_right_margin = config.editor_show_right_margin
@editor.insert_spaces_instead_of_tabs = is_make_file ? false : config.editor_insert_spaces_instead_of_tabs?
@editor.show_right_margin = config.editor_show_right_margin?
@editor.right_margin_position = config.editor_right_margin_position
@editor.highlight_current_line = config.editor_highlight_current_line
@editor.highlight_current_line = config.editor_highlight_current_line?
end

# Line and col starts at zero in code, but at 1 in UI
Expand Down Expand Up @@ -125,8 +125,8 @@ class TextView < DocumentView
buffer.remove_trailing_spaces!

saver = GtkSource::FileSaver.new(buffer: buffer, file: @source_file, flags: :ignore_modification_time)
saver.save_async(:default) do |obj, result|
v = saver.save_finish(result)
saver.save_async(:default) do |_, result|
saver.save_finish(result)
buffer.modified = false
self.externally_modified = false
rescue ex
Expand All @@ -141,8 +141,8 @@ class TextView < DocumentView
saver = GtkSource::FileSaver.new_with_target(buffer: buffer, file: @source_file,
target_location: Gio::File.new_for_path(resource.to_s))
saver.flags = :ignore_modification_time
saver.save_async(:default) do |obj, result|
v = saver.save_finish(result)
saver.save_async(:default) do |_, result|
saver.save_finish(result)
buffer.modified = false
self.externally_modified = false
rescue ex
Expand Down
2 changes: 1 addition & 1 deletion src/view.cr
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ abstract class View < Gtk::Box

@[GObject::Virtual]
def grab_focus : Bool
@contents.grab_focus
@contents.grab_focus
end

private def key_pressed(key_val : UInt32, key_code : UInt32, modifier : Gdk::ModifierType) : Bool
Expand Down
2 changes: 1 addition & 1 deletion src/view_manager.cr
Original file line number Diff line number Diff line change
Expand Up @@ -330,7 +330,7 @@ class ViewManager < Gtk::Widget
root.each_view_node do |node|
@ordered_view_nodes << node
end
@ordered_view_nodes.sort! { |a, b| b.last_used <=> a.last_used }
@ordered_view_nodes.sort! { |view_a, view_b| view_b.last_used <=> view_a.last_used }

items_changed(0, old_size, @ordered_view_nodes.size)
end
Expand Down
1 change: 1 addition & 0 deletions src/view_manager_split_node.cr
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ class ViewManagerSplitNode < ViewManagerNode
end

delegate index, to: @children
delegate index!, to: @children

def child_count : Int32
@children.size
Expand Down
2 changes: 1 addition & 1 deletion src/view_manager_view_node.cr
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ class ViewManagerViewNode < ViewManagerNode
moved_view = remove_visible_view

if old_parent && old_parent.orientation == orientation
idx = old_parent.index(self).not_nil!
idx = old_parent.index!(self)
idx += 1 if position.end?
new_node = ViewManagerViewNode.new(moved_view)
old_parent.add_child(idx, new_node)
Expand Down
2 changes: 1 addition & 1 deletion src/welcome_widget.cr
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ class WelcomeWidget < Gtk::Box
message = "Tijolo is meant to be used with git projects but no git projects were found under " \
"<span allow_breaks=\"false\" font_family=\"monospace\">#{Path.home}</span>. " \
"Create a git project somewhere and ask Tijolo to rescan projects."
dialog = Gtk::MessageDialog.ok(message_type: :info,
Gtk::MessageDialog.ok(message_type: :info,
text: "No Git projects were found", secondary_text: message,
secondary_use_markup: true, transient_for: ApplicationWindow.cast(root.not_nil!)) do
end
Expand Down

0 comments on commit ea253b6

Please sign in to comment.