Compare commits

...

4 Commits

Author SHA1 Message Date
Mahmoud Al-Qudsi f5ebe28925 Add missing completion for `status current-commandline`
`status current-commandline` shipped in fish 3.6.0 but we missed adding this
completion.

(cherry picked from commit 256713b670)
2023-01-15 18:06:41 -06:00
Fabian Boehm 544ea70569 webconfig: Remove the abbreviations tab
Since the new expanded abbreviations in 3.6.0, abbr no longer accepts
new universal variables. That means this tab is now
non-functional (except that it could technically remove abbrs that
were set in universal variables).

Because making it work with the expanded abbreviations requires some
awkwardness like a dedicated conf.d snippet (or writing into
config.fish!), we simply remove it.

(cherry picked from commit 4ceb497bfb)
2023-01-11 16:27:57 +08:00
Fabian Boehm ce8adb30e0 completions/git: Remove awkward newline symbol
Konsole draws ⏎  with a width of 2, but widechar_width says it's 1.
That leads to awkward display.

It's also a surprising and distracting symbol in this use.

So just use spaces.

(cherry picked from commit 905f788b3e)
2023-01-11 16:27:57 +08:00
Fabian Boehm af9fd3b64b completions/git: Fix git-foo commands
Broken in f5711ad5ed, this neglected to
remove the `git-` part from the command

Fixes #9457.

(cherry picked from commit 2da1a4ae77)
2023-01-11 16:27:57 +08:00
10 changed files with 25 additions and 163 deletions

View File

@ -816,8 +816,8 @@ nohelpers\t'exclude helper commands'
config\t'list completion.commands'"
# Options shared between multiple commands
set -l format_pretty_args "oneline\t'hash titleline' short\t'hash author titleline' medium\t'hash author authordate title message' full\t'hash author committer title message'
fuller\t'hash author authordate committer committerdate title message' email\t'hash date author authordate title message' raw\t'Show raw commit as stored in commit object' format:\t'Specify format string'"
set -l format_pretty_args "oneline\t'hash titleline' short\t'hash author titleline' medium\t'hash author authordate title message' full\t'hash author committer title message'
fuller\t'hash author authordate committer committerdate title message' email\t'hash date author authordate title message' raw\t'Show raw commit as stored in commit object' format:\t'Specify format string'"
complete -f -c git -n '__fish_git_using_command log show diff-tree rev-list' -l pretty -a $format_pretty_args
complete -c git -n '__fish_git_using_command diff show range-diff' -l abbrev -d 'Show only a partial prefix instead of the full 40-byte hexadecimal object name'
@ -2226,15 +2226,13 @@ end
# source git-* commands' autocompletion file if exists
set -f __fish_git_custom_commands_completion
for file in $PATHgitdash
test ! -x $file
and continue
set -l subcommand (path basename $file)
for file in (path filter -xZ -- $PATHgitdash | path basename)
# Already seen this command earlier in $PATH.
contains -- $subcommand $__fish_git_custom_commands_completion
contains -- $file $__fish_git_custom_commands_completion
and continue
complete -c git -f -n "__fish_git_using_command $subcommand" -a "(__fish_git_complete_custom_command $subcommand)"
# Running `git foo` ends up running `git-foo`, so we need to ignore the `git-` here.
set -l cmd (string replace -r '^git-' '' -- $file)
complete -c git -f -n "__fish_git_using_command $cmd" -a "(__fish_git_complete_custom_command $cmd)"
set -a __fish_git_custom_commands_completion $subcommand
end

View File

@ -1,5 +1,5 @@
# Note that when a completion file is sourced a new block scope is created so `set -l` works.
set -l __fish_status_all_commands current-command current-filename current-function current-line-number features filename fish-path function is-block is-breakpoint is-command-substitution is-full-job-control is-interactive is-interactive-job-control is-login is-no-job-control job-control line-number print-stack-trace stack-trace test-feature
set -l __fish_status_all_commands current-command current-commandline current-filename current-function current-line-number features filename fish-path function is-block is-breakpoint is-command-substitution is-full-job-control is-interactive is-interactive-job-control is-login is-no-job-control job-control line-number print-stack-trace stack-trace test-feature
# These are the recognized flags.
complete -c status -s h -l help -d "Display help and exit"
@ -16,6 +16,7 @@ complete -f -c status -n "not __fish_seen_subcommand_from $__fish_status_all_com
# The subcommands that are not "is-something" which don't change the fish state.
complete -f -c status -n "not __fish_seen_subcommand_from $__fish_status_all_commands" -a current-command -d "Print the name of the currently running command or function"
complete -f -c status -n "not __fish_seen_subcommand_from $__fish_status_all_commands" -a current-commandline -d "Print the currently running command with its arguments"
complete -f -c status -n "not __fish_seen_subcommand_from $__fish_status_all_commands" -a current-filename -d "Print the filename of the currently running script"
complete -f -c status -n "not __fish_seen_subcommand_from $__fish_status_all_commands" -a filename -d "Print the filename of the currently running script"
complete -f -c status -n "not __fish_seen_subcommand_from $__fish_status_all_commands" -a current-function -d "Print the name of the current function"

View File

@ -293,19 +293,6 @@ body {
border-bottom: #444 dotted 1px;
}
.abbreviation_actions {
width: 8em;
text-align: right;
border-bottom: #444 dotted 1px;
}
.abbreviation_input {
height: 1.5em;
font: inherit;
padding: 3px;
margin: 0;
}
/* The CSS we apply when a table row is filtered */
.data_table_row_filtered {
display: none;

View File

@ -27,7 +27,6 @@
<div ng-class="{'tab': true, 'selected_tab': currentTab == 'variables'}" id="tab_variables" ng-click="changeView('variables')">variables</div>
<div ng-class="{'tab': true, 'selected_tab': currentTab == 'history'}" id="tab_history" ng-click="changeView('history')">history</div>
<div ng-class="{'tab': true, 'selected_tab': currentTab == 'bindings'}" id="tab_bindings" ng-click="changeView('bindings')">bindings</div>
<div ng-class="{'tab': true, 'selected_tab': currentTab == 'abbreviations'}" id="tab_abbreviations" ng-click="changeView('abbreviations')">abbreviations</div>
</div>
<div id="tab_contents">
<ng-view></ng-view>

View File

@ -34,10 +34,6 @@ fishconfig.config(
controller: "bindingsController",
templateUrl: "partials/bindings.html"
})
.when("/abbreviations", {
controller: "abbreviationsController",
templateUrl: "partials/abbreviations.html"
})
.otherwise({
redirectTo: "/colors"
})

View File

@ -395,49 +395,3 @@ controllers.controller("bindingsController", function($scope, $http) {
$scope.fetchBindings();
});
controllers.controller("abbreviationsController", function($scope, $http) {
$scope.abbreviations = [];
$scope.addBlank = function() {
// Add blank entry if it is missing
var hasBlank = {hasBlank: false}
angular.forEach($scope.abbreviations, function(value, key) {
if (value.phrase === "" && value.word === "") {
this.hasBlank = true;
}
}, hasBlank);
if (!$scope.abbreviations) $scope.abbreviations = [];
if (! hasBlank.hasBlank) {
$scope.abbreviations.push({phrase: "", word: "", editable: true})
}
}
$scope.fetchAbbreviations = function() {
$http.get("abbreviations/").then(function(arg) {
$scope.abbreviations = arg.data;
$scope.addBlank();
})};
$scope.editAbbreviation = function(abbreviation) {
abbreviation.editable = true;
}
$scope.saveAbbreviation = function(abbreviation) {
if (abbreviation.word && abbreviation.phrase) {
$http.post("save_abbreviation/", abbreviation).then(function(arg) {
abbreviation.editable = false;
$scope.addBlank();
});
}
};
$scope.removeAbbreviation = function(abbreviation) {
if (abbreviation.word) {
$http.post("remove_abbreviation/", abbreviation).then(function(arg) {
$scope.abbreviations.splice($scope.abbreviations.indexOf(abbreviation), 1);
$scope.addBlank();
});
}
};
$scope.fetchAbbreviations();
});

View File

@ -41,20 +41,3 @@ filters.filter("filterBinding", function() {
return result;
}
});
filters.filter("filterAbbreviations", function() {
return function(abbreviations, query) {
var result = []
if (abbreviations == undefined) return result;
if (query == null) { return abbreviations};
for(var i=0; i<abbreviations.length; ++i) {
var abbr = abbreviations[i];
if (abbr.word.toLowerCase().indexOf(query) != -1 || abbr.phrase.toLowerCase().indexOf(query.toLowerCase()) != -1) {
result.push(abbr);
}
}
return result;
}
});

View File

@ -1,22 +0,0 @@
<div id="table_filter_container" style="display: block;">
<input id="table_filter_text_box" class="filter_text_box text_box_transient" placeholder="Filter" ng-model="query">
</div>
<table class="data_table">
<tbody>
<tr class="data_table_row" ng-repeat="abbreviation in abbreviations | filterAbbreviations:query" ng-click="editAbbreviation(abbreviation)">
<td ng-class="{ data_table_cell: true }" style="text-align: right; padding-right: 30px;">
<span ng-hide="abbreviation.editable">{{ abbreviation.word }}</span>
<span ng-show="abbreviation.editable"><input ng-model="abbreviation.word" class="abbreviation_input" style="text-align: right; min-width: 10em;"></span>
</td>
<td ng-class="{ data_table_cell: true }" style="text-align: left; padding-right: 30px;">
<span ng-hide="abbreviation.editable">{{ abbreviation.phrase }}</span>
<span ng-show="abbreviation.editable"><input ng-model="abbreviation.phrase" class="abbreviation_input" style="text-align: left; min-width: 22em;"></span>
</td>
<td ng-class="{ data_table_cell: true }" class="abbreviation_actions">
<span ng-show="abbreviation.editable && abbreviation.word && abbreviation.phrase" ng-click="saveAbbreviation(abbreviation)"><button class="save_button" style="margin: inherit;">Save</button></span>
<a ng-show="abbreviation.word" ng-click="removeAbbreviation(abbreviation)"><img alt="Delete" src="delete.png" style="vertical-align: text-bottom"></a>
</td>
</tr>
</tbody>
</table>

View File

@ -1338,40 +1338,6 @@ class FishConfigHTTPRequestHandler(SimpleHTTPServer.SimpleHTTPRequestHandler):
result.extend([self.read_one_sample_prompt(path) for path in paths])
return result
def do_get_abbreviations(self):
# Example abbreviation line:
# abbr -a -U -- ls 'ls -a'
result = []
out, err = run_fish_cmd("abbr --show")
for line in out.rstrip().split("\n"):
if not line:
continue
_, abbr = line.split(" -- ", 1)
word, phrase = abbr.split(" ", 1)
result.append({"word": word, "phrase": phrase})
return result
def do_remove_abbreviation(self, abbreviation):
out, err = run_fish_cmd("abbr --erase %s" % abbreviation["word"])
if err:
return err
else:
return None
def do_save_abbreviation(self, abbreviation):
out, err = run_fish_cmd(
# Remove one layer of single-quotes because escape_fish_cmd adds them back.
"abbr --add %s %s"
% (
escape_fish_cmd(strip_one_layer(abbreviation["word"], "'")),
escape_fish_cmd(strip_one_layer(abbreviation["phrase"], "'")),
)
)
if err:
return err
else:
return None
def secure_startswith(self, haystack, needle):
if len(haystack) < len(needle):
return False
@ -1453,8 +1419,6 @@ class FishConfigHTTPRequestHandler(SimpleHTTPServer.SimpleHTTPRequestHandler):
output = self.do_get_color_for_variable(name)
elif p == "/bindings/":
output = self.do_get_bindings()
elif p == "/abbreviations/":
output = self.do_get_abbreviations()
else:
return SimpleHTTPServer.SimpleHTTPRequestHandler.do_GET(self)
@ -1577,18 +1541,6 @@ class FishConfigHTTPRequestHandler(SimpleHTTPServer.SimpleHTTPRequestHandler):
output = ["OK"]
else:
output = ["Unable to set prompt"]
elif p == "/save_abbreviation/":
errmsg = self.do_save_abbreviation(postvars)
if errmsg:
output = [errmsg]
else:
output = ["OK"]
elif p == "/remove_abbreviation/":
errmsg = self.do_remove_abbreviation(postvars)
if errmsg:
output = [errmsg]
else:
output = ["OK"]
else:
return self.send_error(404)
@ -1701,7 +1653,6 @@ if len(sys.argv) > 1:
"variables",
"history",
"bindings",
"abbreviations",
]:
if tab.startswith(sys.argv[1]):
initial_tab = "#!/" + tab

View File

@ -33,6 +33,19 @@ git init >/dev/null 2>&1
# First set up a test alias - *before loading the completions*
git config --local alias.re 'restore --staged'
# Test custom command completions by adding a command:
set -p PATH $PWD
echo "echo foo" > git-frobnicate
chmod +x git-frobnicate
complete -c git-frobnicate -xa 'foo bar baz'
complete -C'git frobnicate '
#CHECK: bar
#CHECK: baz
#CHECK: foo
complete -C'git ' | grep '^add'\t
# (note: actual tab character in the check here)
#CHECK: add Add file contents to the staging area
@ -41,9 +54,11 @@ touch foo
complete -C'git add '
#CHECK: foo Untracked file
#CHECK: git-frobnicate Untracked file
complete -C'git add :'
#CHECK: :/:foo Untracked file
#CHECK: :/:git-frobnicate Untracked file
git config alias.s status
complete 'git s --s'
@ -71,7 +86,7 @@ set -g __fish_git_prompt_show_informative_status 1
set -g __fish_git_prompt_showuntrackedfiles 1
fish_git_prompt
echo
#CHECK: (newbranch|1)
#CHECK: (newbranch|2)
set -e __fish_git_prompt_show_informative_status
set -e __fish_git_prompt_showuntrackedfiles