aboutsummaryrefslogtreecommitdiff
path: root/ide/coqide.ml
diff options
context:
space:
mode:
authorppedrot2013-02-20 15:49:13 +0000
committerppedrot2013-02-20 15:49:13 +0000
commit209ec7628f7d64cac76f0edae5ca2be4c952ced5 (patch)
tree16a3131691b2b415fa83da7afbb9937300cea6d6 /ide/coqide.ml
parent62a474168c3416777138615c469560fcb85b86fc (diff)
CoqIDE: Including autocompletion in word proposals
git-svn-id: svn+ssh://scm.gforge.inria.fr/svn/coq/trunk@16227 85f007b7-540e-0410-9357-904b9bb8a0f7
Diffstat (limited to 'ide/coqide.ml')
-rw-r--r--ide/coqide.ml25
1 files changed, 14 insertions, 11 deletions
diff --git a/ide/coqide.ml b/ide/coqide.ml
index bb3114569f..8a64e5184e 100644
--- a/ide/coqide.ml
+++ b/ide/coqide.ml
@@ -538,17 +538,20 @@ let printopts_callback opts v =
(** Templates menu *)
-let get_current_word () = match Ideutils.cb#text with
- |Some t -> Minilib.log ("get_current_word : selection = " ^ t); t
- |None ->
- Minilib.log "get_current_word : none selected";
- let b = current_buffer () in
- let it = b#get_iter_at_mark `INSERT in
- let start = find_word_start it in
- let stop = find_word_end start in
- b#move_mark `SEL_BOUND ~where:start;
- b#move_mark `INSERT ~where:stop;
- b#get_text ~slice:true ~start ~stop ()
+let get_current_word () =
+ let term = notebook#current_term in
+ (** First look to find if autocompleting *)
+ match term.script#complete_popup#proposal with
+ | Some p -> p
+ | None ->
+ (** Then look at the current selected word *)
+ if term.script#buffer#has_selection then
+ let (start, stop) = term.script#buffer#selection_bounds in
+ term.script#buffer#get_text ~slice:true ~start ~stop ()
+ (** Otherwise try to recover the clipboard *)
+ else match Ideutils.cb#text with
+ | Some t -> t
+ | None -> ""
let print_branch c l =
Format.fprintf c " | @[<hov 1>%a@]=> _@\n"